|
|
|
@ -375,7 +375,7 @@ RSpec.describe OrganisationsController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
it "prevents CSV download" do |
|
|
|
it "prevents CSV download" do |
|
|
|
expect { |
|
|
|
expect { |
|
|
|
post "/organisations/#{unauthorised_organisation.id}/logs/email-csv", headers:, params: {} |
|
|
|
post "/organisations/#{unauthorised_organisation.id}/lettings-logs/email-csv", headers:, params: {} |
|
|
|
}.not_to enqueue_job(EmailCsvJob) |
|
|
|
}.not_to enqueue_job(EmailCsvJob) |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
end |
|
|
|
end |
|
|
|
@ -389,7 +389,7 @@ RSpec.describe OrganisationsController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
it "prevents CSV download" do |
|
|
|
it "prevents CSV download" do |
|
|
|
expect { |
|
|
|
expect { |
|
|
|
post "/organisations/#{organisation.id}/logs/email-csv", headers:, params: {} |
|
|
|
post "/organisations/#{organisation.id}/lettings-logs/email-csv", headers:, params: {} |
|
|
|
}.not_to enqueue_job(EmailCsvJob) |
|
|
|
}.not_to enqueue_job(EmailCsvJob) |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
end |
|
|
|
end |
|
|
|
@ -552,7 +552,7 @@ RSpec.describe OrganisationsController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
it "prevents CSV download" do |
|
|
|
it "prevents CSV download" do |
|
|
|
expect { |
|
|
|
expect { |
|
|
|
post "/organisations/#{unauthorised_organisation.id}/logs/email-csv", headers:, params: {} |
|
|
|
post "/organisations/#{unauthorised_organisation.id}/lettings-logs/email-csv", headers:, params: {} |
|
|
|
}.not_to enqueue_job(EmailCsvJob) |
|
|
|
}.not_to enqueue_job(EmailCsvJob) |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
end |
|
|
|
end |
|
|
|
@ -566,7 +566,7 @@ RSpec.describe OrganisationsController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
it "prevents CSV download" do |
|
|
|
it "prevents CSV download" do |
|
|
|
expect { |
|
|
|
expect { |
|
|
|
post "/organisations/#{organisation.id}/logs/email-csv", headers:, params: {} |
|
|
|
post "/organisations/#{organisation.id}/lettings-logs/email-csv", headers:, params: {} |
|
|
|
}.not_to enqueue_job(EmailCsvJob) |
|
|
|
}.not_to enqueue_job(EmailCsvJob) |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
end |
|
|
|
end |
|
|
|
@ -1183,8 +1183,8 @@ RSpec.describe OrganisationsController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
it "has CSV download buttons with the correct paths if at least 1 log exists" do |
|
|
|
it "has CSV download buttons with the correct paths if at least 1 log exists" do |
|
|
|
get "/organisations/#{organisation.id}/lettings-logs" |
|
|
|
get "/organisations/#{organisation.id}/lettings-logs" |
|
|
|
expect(page).to have_link("Download (CSV)", href: "/organisations/#{organisation.id}/logs/csv-download?codes_only=false") |
|
|
|
expect(page).to have_link("Download (CSV)", href: "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false") |
|
|
|
expect(page).to have_link("Download (CSV, codes only)", href: "/organisations/#{organisation.id}/logs/csv-download?codes_only=true") |
|
|
|
expect(page).to have_link("Download (CSV, codes only)", href: "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=true") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when you download the CSV" do |
|
|
|
context "when you download the CSV" do |
|
|
|
@ -1197,25 +1197,25 @@ RSpec.describe OrganisationsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "only includes logs from that organisation" do |
|
|
|
it "only includes logs from that organisation" do |
|
|
|
get "/organisations/#{organisation.id}/logs/csv-download?codes_only=false" |
|
|
|
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false" |
|
|
|
|
|
|
|
|
|
|
|
expect(page).to have_text("You've selected 3 logs.") |
|
|
|
expect(page).to have_text("You've selected 3 logs.") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "provides the organisation to the mail job" do |
|
|
|
it "provides the organisation to the mail job" do |
|
|
|
expect { |
|
|
|
expect { |
|
|
|
post "/organisations/#{organisation.id}/logs/email-csv?status[]=completed&codes_only=false", headers:, params: {} |
|
|
|
post "/organisations/#{organisation.id}/lettings-logs/email-csv?status[]=completed&codes_only=false", headers:, params: {} |
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, { "status" => %w[completed] }, false, organisation, false) |
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, { "status" => %w[completed] }, false, organisation, false) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "provides the export type to the mail job" do |
|
|
|
it "provides the export type to the mail job" do |
|
|
|
codes_only_export_type = false |
|
|
|
codes_only_export_type = false |
|
|
|
expect { |
|
|
|
expect { |
|
|
|
post "/organisations/#{organisation.id}/logs/email-csv?codes_only=#{codes_only_export_type}", headers:, params: {} |
|
|
|
post "/organisations/#{organisation.id}/lettings-logs/email-csv?codes_only=#{codes_only_export_type}", headers:, params: {} |
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, organisation, codes_only_export_type) |
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, organisation, codes_only_export_type) |
|
|
|
codes_only_export_type = true |
|
|
|
codes_only_export_type = true |
|
|
|
expect { |
|
|
|
expect { |
|
|
|
post "/organisations/#{organisation.id}/logs/email-csv?codes_only=#{codes_only_export_type}", headers:, params: {} |
|
|
|
post "/organisations/#{organisation.id}/lettings-logs/email-csv?codes_only=#{codes_only_export_type}", headers:, params: {} |
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, organisation, codes_only_export_type) |
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, organisation, codes_only_export_type) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
@ -1223,36 +1223,36 @@ RSpec.describe OrganisationsController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
describe "GET #download_csv" do |
|
|
|
describe "GET #download_csv" do |
|
|
|
it "renders a page with the correct header" do |
|
|
|
it "renders a page with the correct header" do |
|
|
|
get "/organisations/#{organisation.id}/logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
header = page.find_css("h1") |
|
|
|
header = page.find_css("h1") |
|
|
|
expect(header.text).to include("Download CSV") |
|
|
|
expect(header.text).to include("Download CSV") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "renders a form with the correct target containing a button with the correct text" do |
|
|
|
it "renders a form with the correct target containing a button with the correct text" do |
|
|
|
get "/organisations/#{organisation.id}/logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
form = page.find("form.button_to") |
|
|
|
form = page.find("form.button_to") |
|
|
|
expect(form[:method]).to eq("post") |
|
|
|
expect(form[:method]).to eq("post") |
|
|
|
expect(form[:action]).to eq("/organisations/#{organisation.id}/logs/email-csv") |
|
|
|
expect(form[:action]).to eq("/organisations/#{organisation.id}/lettings-logs/email-csv") |
|
|
|
expect(form).to have_button("Send email") |
|
|
|
expect(form).to have_button("Send email") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "when codes_only query parameter is false, form contains hidden field with correct value" do |
|
|
|
it "when codes_only query parameter is false, form contains hidden field with correct value" do |
|
|
|
codes_only = false |
|
|
|
codes_only = false |
|
|
|
get "/organisations/#{organisation.id}/logs/csv-download?codes_only=#{codes_only}", headers:, params: {} |
|
|
|
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=#{codes_only}", headers:, params: {} |
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "when codes_only query parameter is true, form contains hidden field with correct value" do |
|
|
|
it "when codes_only query parameter is true, form contains hidden field with correct value" do |
|
|
|
codes_only = true |
|
|
|
codes_only = true |
|
|
|
get "/organisations/#{organisation.id}/logs/csv-download?codes_only=#{codes_only}", headers:, params: {} |
|
|
|
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=#{codes_only}", headers:, params: {} |
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "when query string contains search parameter, form contains hidden field with correct value" do |
|
|
|
it "when query string contains search parameter, form contains hidden field with correct value" do |
|
|
|
search_term = "blam" |
|
|
|
search_term = "blam" |
|
|
|
get "/organisations/#{organisation.id}/logs/csv-download?codes_only=true&search=#{search_term}", headers:, params: {} |
|
|
|
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=true&search=#{search_term}", headers:, params: {} |
|
|
|
hidden_field = page.find("form.button_to").find_field("search", type: "hidden") |
|
|
|
hidden_field = page.find("form.button_to").find_field("search", type: "hidden") |
|
|
|
expect(hidden_field.value).to eq(search_term) |
|
|
|
expect(hidden_field.value).to eq(search_term) |
|
|
|
end |
|
|
|
end |
|
|
|
|