From 4a5d95c99f50f6db201036cbd368c119a0177e27 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 31 Mar 2022 13:00:14 +0100 Subject: [PATCH] Check CSV only downloads collection --- spec/requests/case_logs_controller_spec.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/spec/requests/case_logs_controller_spec.rb b/spec/requests/case_logs_controller_spec.rb index 3a4dff2ef..e251a2d5b 100644 --- a/spec/requests/case_logs_controller_spec.rb +++ b/spec/requests/case_logs_controller_spec.rb @@ -205,10 +205,10 @@ RSpec.describe CaseLogsController, type: :request do it "does not have pagination in the title" do expect(page).to have_title("Logs") end - end - it "shows the download csv link" do - expect(page).to have_link("Download (CSV)", href: "/logs.csv") + it "shows the download csv link" do + expect(page).to have_link("Download (CSV)", href: "/logs.csv") + end end context "when there are more than 20 logs" do @@ -497,15 +497,20 @@ RSpec.describe CaseLogsController, type: :request do before do sign_in user + FactoryBot.create(:case_log) get "/logs", headers: headers, params: {} end it "downloads a CSV file with headers" do csv = CSV.parse(response.body) - expect(csv.count).to eq(2) expect(csv.first.first).to eq("id") expect(csv.second.first).to eq(case_log.id.to_s) end + + it "does not download other orgs logs" do + csv = CSV.parse(response.body) + expect(csv.count).to eq(2) + end end describe "PATCH" do