|
|
|
|
@ -1221,210 +1221,228 @@ RSpec.describe OrganisationsController, type: :request do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the user is a support user" do |
|
|
|
|
let(:user) { create(:user, :support) } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
allow(user).to receive(:need_two_factor_authentication?).and_return(false) |
|
|
|
|
sign_in user |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when they view the lettings logs tab" do |
|
|
|
|
before do |
|
|
|
|
create(:lettings_log, owning_organisation: organisation) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "has CSV download buttons with the correct paths if at least 1 log exists" do |
|
|
|
|
get "/organisations/#{organisation.id}/lettings-logs" |
|
|
|
|
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}/lettings-logs/csv-download?codes_only=true") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when you download the CSV" do |
|
|
|
|
let(:other_organisation) { create(:organisation) } |
|
|
|
|
context "when they view the lettings logs tab" do |
|
|
|
|
let(:tenancycode) { "42" } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
create_list(:lettings_log, 2, owning_organisation: organisation) |
|
|
|
|
create(:lettings_log, owning_organisation: organisation, status: "pending", skip_update_status: true) |
|
|
|
|
create_list(:lettings_log, 2, owning_organisation: other_organisation) |
|
|
|
|
create(:lettings_log, owning_organisation: organisation, tenancycode:) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "only includes logs from that organisation" do |
|
|
|
|
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false" |
|
|
|
|
context "when there is at least one log visible" do |
|
|
|
|
before do |
|
|
|
|
get lettings_logs_organisation_path(organisation, search: tenancycode) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "shows the delete logs button with the correct path" do |
|
|
|
|
expect(page).to have_link "Delete logs", href: delete_lettings_logs_organisation_path(search: tenancycode) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
expect(page).to have_text("You've selected 3 logs.") |
|
|
|
|
it "has CSV download buttons with the correct paths" do |
|
|
|
|
expect(page).to have_link "Download (CSV)", href: lettings_logs_csv_download_organisation_path(organisation, codes_only: false, search: tenancycode) |
|
|
|
|
expect(page).to have_link "Download (CSV, codes only)", href: lettings_logs_csv_download_organisation_path(organisation, codes_only: true, search: tenancycode) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "provides the organisation to the mail job" do |
|
|
|
|
expect { |
|
|
|
|
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) |
|
|
|
|
end |
|
|
|
|
context "when there are no visible logs" do |
|
|
|
|
before do |
|
|
|
|
LettingsLog.destroy_all |
|
|
|
|
get lettings_logs_organisation_path(organisation) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "provides the export type to the mail job" do |
|
|
|
|
codes_only_export_type = false |
|
|
|
|
expect { |
|
|
|
|
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) |
|
|
|
|
codes_only_export_type = true |
|
|
|
|
expect { |
|
|
|
|
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) |
|
|
|
|
it "does not show the delete logs button " do |
|
|
|
|
expect(page).not_to have_link "Delete logs" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "does not show the csv download buttons" do |
|
|
|
|
expect(page).not_to have_link "Download (CSV)" |
|
|
|
|
expect(page).not_to have_link "Download (CSV, codes only)" |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when they view the sales logs tab" do |
|
|
|
|
before do |
|
|
|
|
create(:sales_log, owning_organisation: organisation) |
|
|
|
|
end |
|
|
|
|
context "when you download the CSV" do |
|
|
|
|
let(:other_organisation) { create(:organisation) } |
|
|
|
|
|
|
|
|
|
it "has CSV download buttons with the correct paths if at least 1 log exists" do |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs" |
|
|
|
|
expect(page).to have_link("Download (CSV)", href: "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=false") |
|
|
|
|
expect(page).to have_link("Download (CSV, codes only)", href: "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=true") |
|
|
|
|
end |
|
|
|
|
before do |
|
|
|
|
create_list(:lettings_log, 2, owning_organisation: organisation) |
|
|
|
|
create(:lettings_log, owning_organisation: organisation, status: "pending", skip_update_status: true) |
|
|
|
|
create_list(:lettings_log, 2, owning_organisation: other_organisation) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when you download the CSV" do |
|
|
|
|
let(:other_organisation) { create(:organisation) } |
|
|
|
|
it "only includes logs from that organisation" do |
|
|
|
|
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false" |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
create_list(:sales_log, 2, owning_organisation: organisation) |
|
|
|
|
create(:sales_log, owning_organisation: organisation, status: "pending", skip_update_status: true) |
|
|
|
|
create_list(:sales_log, 2, owning_organisation: other_organisation) |
|
|
|
|
end |
|
|
|
|
expect(page).to have_text("You've selected 3 logs.") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "only includes logs from that organisation" do |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=false" |
|
|
|
|
it "provides the organisation to the mail job" do |
|
|
|
|
expect { |
|
|
|
|
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) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
expect(page).to have_text("You've selected 3 logs.") |
|
|
|
|
it "provides the export type to the mail job" do |
|
|
|
|
codes_only_export_type = false |
|
|
|
|
expect { |
|
|
|
|
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) |
|
|
|
|
codes_only_export_type = true |
|
|
|
|
expect { |
|
|
|
|
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) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "provides the organisation to the mail job" do |
|
|
|
|
expect { |
|
|
|
|
post "/organisations/#{organisation.id}/sales-logs/email-csv?status[]=completed&codes_only=false", headers:, params: {} |
|
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, { "status" => %w[completed] }, false, organisation, false, "sales") |
|
|
|
|
context "when they view the sales logs tab" do |
|
|
|
|
before do |
|
|
|
|
create(:sales_log, owning_organisation: organisation) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "provides the log type to the mail job" do |
|
|
|
|
log_type = "sales" |
|
|
|
|
expect { |
|
|
|
|
post "/organisations/#{organisation.id}/sales-logs/email-csv?status[]=completed&codes_only=false", headers:, params: {} |
|
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, { "status" => %w[completed] }, false, organisation, false, log_type) |
|
|
|
|
it "has CSV download buttons with the correct paths if at least 1 log exists" do |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs" |
|
|
|
|
expect(page).to have_link("Download (CSV)", href: "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=false") |
|
|
|
|
expect(page).to have_link("Download (CSV, codes only)", href: "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=true") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "provides the export type to the mail job" do |
|
|
|
|
codes_only_export_type = false |
|
|
|
|
expect { |
|
|
|
|
post "/organisations/#{organisation.id}/sales-logs/email-csv?codes_only=#{codes_only_export_type}", headers:, params: {} |
|
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, organisation, codes_only_export_type, "sales") |
|
|
|
|
codes_only_export_type = true |
|
|
|
|
expect { |
|
|
|
|
post "/organisations/#{organisation.id}/sales-logs/email-csv?codes_only=#{codes_only_export_type}", headers:, params: {} |
|
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, organisation, codes_only_export_type, "sales") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
context "when you download the CSV" do |
|
|
|
|
let(:other_organisation) { create(:organisation) } |
|
|
|
|
|
|
|
|
|
describe "GET #download_lettings_csv" do |
|
|
|
|
it "renders a page with the correct header" do |
|
|
|
|
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
|
header = page.find_css("h1") |
|
|
|
|
expect(header.text).to include("Download CSV") |
|
|
|
|
end |
|
|
|
|
before do |
|
|
|
|
create_list(:sales_log, 2, owning_organisation: organisation) |
|
|
|
|
create(:sales_log, owning_organisation: organisation, status: "pending", skip_update_status: true) |
|
|
|
|
create_list(:sales_log, 2, owning_organisation: other_organisation) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "renders a form with the correct target containing a button with the correct text" do |
|
|
|
|
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
|
form = page.find("form.button_to") |
|
|
|
|
expect(form[:method]).to eq("post") |
|
|
|
|
expect(form[:action]).to eq("/organisations/#{organisation.id}/lettings-logs/email-csv") |
|
|
|
|
expect(form).to have_button("Send email") |
|
|
|
|
end |
|
|
|
|
it "only includes logs from that organisation" do |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=false" |
|
|
|
|
|
|
|
|
|
it "when codes_only query parameter is false, form contains hidden field with correct value" do |
|
|
|
|
codes_only = false |
|
|
|
|
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") |
|
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
|
end |
|
|
|
|
expect(page).to have_text("You've selected 3 logs.") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "when codes_only query parameter is true, form contains hidden field with correct value" do |
|
|
|
|
codes_only = true |
|
|
|
|
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") |
|
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
|
end |
|
|
|
|
it "provides the organisation to the mail job" do |
|
|
|
|
expect { |
|
|
|
|
post "/organisations/#{organisation.id}/sales-logs/email-csv?status[]=completed&codes_only=false", headers:, params: {} |
|
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, { "status" => %w[completed] }, false, organisation, false, "sales") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "when query string contains search parameter, form contains hidden field with correct value" do |
|
|
|
|
search_term = "blam" |
|
|
|
|
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") |
|
|
|
|
expect(hidden_field.value).to eq(search_term) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
it "provides the log type to the mail job" do |
|
|
|
|
log_type = "sales" |
|
|
|
|
expect { |
|
|
|
|
post "/organisations/#{organisation.id}/sales-logs/email-csv?status[]=completed&codes_only=false", headers:, params: {} |
|
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, { "status" => %w[completed] }, false, organisation, false, log_type) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "GET #download_sales_csv" do |
|
|
|
|
it "renders a page with the correct header" do |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
|
header = page.find_css("h1") |
|
|
|
|
expect(header.text).to include("Download CSV") |
|
|
|
|
it "provides the export type to the mail job" do |
|
|
|
|
codes_only_export_type = false |
|
|
|
|
expect { |
|
|
|
|
post "/organisations/#{organisation.id}/sales-logs/email-csv?codes_only=#{codes_only_export_type}", headers:, params: {} |
|
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, organisation, codes_only_export_type, "sales") |
|
|
|
|
codes_only_export_type = true |
|
|
|
|
expect { |
|
|
|
|
post "/organisations/#{organisation.id}/sales-logs/email-csv?codes_only=#{codes_only_export_type}", headers:, params: {} |
|
|
|
|
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, organisation, codes_only_export_type, "sales") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "renders a form with the correct target containing a button with the correct text" do |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
|
form = page.find("form.button_to") |
|
|
|
|
expect(form[:method]).to eq("post") |
|
|
|
|
expect(form[:action]).to eq("/organisations/#{organisation.id}/sales-logs/email-csv") |
|
|
|
|
expect(form).to have_button("Send email") |
|
|
|
|
end |
|
|
|
|
describe "GET #download_lettings_csv" do |
|
|
|
|
it "renders a page with the correct header" do |
|
|
|
|
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
|
header = page.find_css("h1") |
|
|
|
|
expect(header.text).to include("Download CSV") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "when codes_only query parameter is false, form contains hidden field with correct value" do |
|
|
|
|
codes_only = false |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=#{codes_only}", headers:, params: {} |
|
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
|
end |
|
|
|
|
it "renders a form with the correct target containing a button with the correct text" do |
|
|
|
|
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
|
form = page.find("form.button_to") |
|
|
|
|
expect(form[:method]).to eq("post") |
|
|
|
|
expect(form[:action]).to eq("/organisations/#{organisation.id}/lettings-logs/email-csv") |
|
|
|
|
expect(form).to have_button("Send email") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "when codes_only query parameter is true, form contains hidden field with correct value" do |
|
|
|
|
codes_only = true |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=#{codes_only}", headers:, params: {} |
|
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
|
end |
|
|
|
|
it "when codes_only query parameter is false, form contains hidden field with correct value" do |
|
|
|
|
codes_only = false |
|
|
|
|
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") |
|
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "when query string contains search parameter, form contains hidden field with correct value" do |
|
|
|
|
search_term = "blam" |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=true&search=#{search_term}", headers:, params: {} |
|
|
|
|
hidden_field = page.find("form.button_to").find_field("search", type: "hidden") |
|
|
|
|
expect(hidden_field.value).to eq(search_term) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
it "when codes_only query parameter is true, form contains hidden field with correct value" do |
|
|
|
|
codes_only = true |
|
|
|
|
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") |
|
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when they view the users tab" do |
|
|
|
|
before do |
|
|
|
|
get "/organisations/#{organisation.id}/users" |
|
|
|
|
it "when query string contains search parameter, form contains hidden field with correct value" do |
|
|
|
|
search_term = "blam" |
|
|
|
|
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") |
|
|
|
|
expect(hidden_field.value).to eq(search_term) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "has a CSV download button with the correct path" do |
|
|
|
|
expect(page).to have_link("Download (CSV)", href: "/organisations/#{organisation.id}/users.csv") |
|
|
|
|
end |
|
|
|
|
describe "GET #download_sales_csv" do |
|
|
|
|
it "renders a page with the correct header" do |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
|
header = page.find_css("h1") |
|
|
|
|
expect(header.text).to include("Download CSV") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when you download the CSV" do |
|
|
|
|
let(:headers) { { "Accept" => "text/csv" } } |
|
|
|
|
let(:other_organisation) { create(:organisation) } |
|
|
|
|
it "renders a form with the correct target containing a button with the correct text" do |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
|
form = page.find("form.button_to") |
|
|
|
|
expect(form[:method]).to eq("post") |
|
|
|
|
expect(form[:action]).to eq("/organisations/#{organisation.id}/sales-logs/email-csv") |
|
|
|
|
expect(form).to have_button("Send email") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "when codes_only query parameter is false, form contains hidden field with correct value" do |
|
|
|
|
codes_only = false |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=#{codes_only}", headers:, params: {} |
|
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "when codes_only query parameter is true, form contains hidden field with correct value" do |
|
|
|
|
codes_only = true |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=#{codes_only}", headers:, params: {} |
|
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "when query string contains search parameter, form contains hidden field with correct value" do |
|
|
|
|
search_term = "blam" |
|
|
|
|
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=true&search=#{search_term}", headers:, params: {} |
|
|
|
|
hidden_field = page.find("form.button_to").find_field("search", type: "hidden") |
|
|
|
|
expect(hidden_field.value).to eq(search_term) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when they view the users tab" do |
|
|
|
|
before do |
|
|
|
|
create_list(:user, 3, organisation:) |
|
|
|
|
create_list(:user, 2, organisation: other_organisation) |
|
|
|
|
get "/organisations/#{organisation.id}/users" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "has a CSV download button with the correct path" do |
|
|
|
|
expect(page).to have_link("Download (CSV)", href: "/organisations/#{organisation.id}/users.csv") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "only includes users from that organisation" do |
|
|
|
|
get "/organisations/#{other_organisation.id}/users", headers:, params: {} |
|
|
|
|
csv = CSV.parse(response.body) |
|
|
|
|
expect(csv.count).to eq(other_organisation.users.count + 1) |
|
|
|
|
context "when you download the CSV" do |
|
|
|
|
let(:headers) { { "Accept" => "text/csv" } } |
|
|
|
|
let(:other_organisation) { create(:organisation) } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
create_list(:user, 3, organisation:) |
|
|
|
|
create_list(:user, 2, organisation: other_organisation) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "only includes users from that organisation" do |
|
|
|
|
get "/organisations/#{other_organisation.id}/users", headers:, params: {} |
|
|
|
|
csv = CSV.parse(response.body) |
|
|
|
|
expect(csv.count).to eq(other_organisation.users.count + 1) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|