Browse Source

update organisations controller

pull/858/head
Kat 3 years ago
parent
commit
7347b8c30e
  1. 8
      app/controllers/organisations_controller.rb
  2. 2
      spec/requests/organisations_controller_spec.rb

8
app/controllers/organisations_controller.rb

@ -101,10 +101,6 @@ class OrganisationsController < ApplicationController
@total_count = organisation_logs.size
render "logs", layout: "application"
end
format.csv do
send_data byte_order_mark + unpaginated_filtered_logs.to_csv, filename: "lettings-logs-#{@organisation.name}-#{Time.zone.now}.csv"
end
end
end
@ -112,7 +108,7 @@ class OrganisationsController < ApplicationController
organisation_logs = LettingsLog.all.where(owning_organisation_id: @organisation.id)
unpaginated_filtered_logs = filtered_logs(organisation_logs, search_term, @session_filters)
render "lettings_logs/download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: logs_email_csv_organisation_path }
render "logs/download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: logs_email_csv_organisation_path }
end
def email_csv
@ -150,7 +146,7 @@ private
end
def authenticate_scope!
if %w[create new logs download_csv email_csv].include? action_name
if %w[create new lettings_logs download_csv email_csv].include? action_name
head :unauthorized and return unless current_user.support?
elsif current_user.organisation != @organisation && !current_user.support?
render_not_found

2
spec/requests/organisations_controller_spec.rb

@ -520,7 +520,7 @@ RSpec.describe OrganisationsController, type: :request do
it "prevents CSV download" do
expect {
post "/organisations/#{organisation.id}/lettings-logs/email-csv", headers:, params: {}
post "/organisations/#{organisation.id}/logs/email-csv", headers:, params: {}
}.not_to enqueue_job(EmailCsvJob)
expect(response).to have_http_status(:unauthorized)
end

Loading…
Cancel
Save