Browse Source

Update csv count for sales

pull/2477/head
Kat 2 years ago
parent
commit
59209fd578
  1. 2
      app/controllers/sales_logs_controller.rb
  2. 24
      spec/requests/sales_logs_controller_spec.rb

2
app/controllers/sales_logs_controller.rb

@ -64,7 +64,7 @@ class SalesLogsController < LogsController
def download_csv
redirect_to filters_years_sales_logs_path(search: search_term, codes_only: codes_only_export?) and return if session_filters["years"].blank? || session_filters["years"].count != 1
unpaginated_filtered_logs = filter_manager.filtered_logs(current_user.sales_logs, search_term, session_filters)
unpaginated_filtered_logs = filter_manager.filtered_logs(current_user.sales_logs.visible, search_term, session_filters)
render "download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: email_csv_sales_logs_path, codes_only: codes_only_export?, session_filters:, filter_type: "sales_logs", download_csv_back_link: sales_logs_path }
end

24
spec/requests/sales_logs_controller_spec.rb

@ -1042,6 +1042,30 @@ RSpec.describe SalesLogsController, type: :request do
expect(response).to have_http_status(:unauthorized)
end
end
context "and filtering by organisation and year" do
let(:other_organisation) { FactoryBot.create(:organisation) }
let(:sales_logs) { create_list(:sales_log, 2, :in_progress, assigned_to: user, owning_organisation: other_organisation, managing_organisation: user.organisation) }
let(:params) do
{
years: [sales_logs[0].form.start_date.year],
owning_organisation: other_organisation.id,
owning_organisation_select: "specific_org",
codes_only: false,
}
end
before do
create(:organisation_relationship, parent_organisation: other_organisation, child_organisation: user.organisation)
create_list(:sales_log, 2, :in_progress, assigned_to: user, owning_organisation: other_organisation, managing_organisation: user.organisation, discarded_at: Time.zone.yesterday)
end
it "does not count deleted logs" do
get csv_download_sales_logs_path, headers:, params: params
expect(page).to have_content("You've selected 2 logs.")
end
end
end
context "when user is support" do

Loading…
Cancel
Save