From 967fd9714c9d56e17de8123f5074d3137ec30097 Mon Sep 17 00:00:00 2001 From: bellitabellota <136174454+bellitabellota@users.noreply.github.com> Date: Tue, 26 Aug 2025 09:22:30 +0100 Subject: [PATCH 1/3] Include inactive donation sites in csv export when corresponding filter is selected and add test --- app/views/donation_sites/index.html.erb | 2 +- spec/system/donation_site_system_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/views/donation_sites/index.html.erb b/app/views/donation_sites/index.html.erb index 099ef4935c..7301fe4dc2 100644 --- a/app/views/donation_sites/index.html.erb +++ b/app/views/donation_sites/index.html.erb @@ -45,7 +45,7 @@ <%= clear_filter_button %> <%= modal_button_to("#csvImportModal", {icon: "upload", text: "Import Donation Sites", size: "md"}) if @donation_sites.empty? %> - <%= download_button_to(donation_sites_path(format: :csv, filters: filter_params), {text: "Export Donation Sites", size: "md"}) if @donation_sites.any? %> + <%= download_button_to(donation_sites_path(format: :csv, include_inactive_donation_sites: @include_inactive_donation_sites, filters: filter_params), {text: "Export Donation Sites", size: "md"}) if @donation_sites.any? %> <%= new_button_to new_donation_site_path, {text: "New Donation Site"} %> diff --git a/spec/system/donation_site_system_spec.rb b/spec/system/donation_site_system_spec.rb index 767bf8d64a..e0a0394557 100644 --- a/spec/system/donation_site_system_spec.rb +++ b/spec/system/donation_site_system_spec.rb @@ -20,6 +20,22 @@ expect(page.find(:xpath, "//table/tbody/tr[1]/td[1]")).to have_content(@first.name) expect(page.find(:xpath, "//table/tbody/tr[3]/td[1]")).to have_content(@third.name) end + + context "and exports a csv with include inactive donation sites selected" do + it "includes active and inactive donation sites" do + active_donation_site = create(:donation_site, name: "Active Donation Site") + inactive_donation_site = create(:donation_site, name: "Inactive Donation Site", active: false) + visit subject + check "Also include inactive donation sites" + click_on "Filter" + click_on "Export Donation Sites" + wait_for_download + @csv_content = File.read(download) + + expect(@csv_content).to have_content(active_donation_site.name) + expect(@csv_content).to have_content(inactive_donation_site.name) + end + end end context "When creating a new donation site" do From c7193f2c83fcd849dee3e1536c74be31faececaa Mon Sep 17 00:00:00 2001 From: bellitabellota <136174454+bellitabellota@users.noreply.github.com> Date: Sat, 13 Sep 2025 13:01:20 +0100 Subject: [PATCH 2/3] Update description of context block --- spec/system/donation_site_system_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/donation_site_system_spec.rb b/spec/system/donation_site_system_spec.rb index e0a0394557..f5693b3bca 100644 --- a/spec/system/donation_site_system_spec.rb +++ b/spec/system/donation_site_system_spec.rb @@ -21,7 +21,7 @@ expect(page.find(:xpath, "//table/tbody/tr[3]/td[1]")).to have_content(@third.name) end - context "and exports a csv with include inactive donation sites selected" do + context "when exporting a csv with include inactive donation sites selected" do it "includes active and inactive donation sites" do active_donation_site = create(:donation_site, name: "Active Donation Site") inactive_donation_site = create(:donation_site, name: "Inactive Donation Site", active: false) From 129aa053e47de3f040a0e2a270ff7db8bde69332 Mon Sep 17 00:00:00 2001 From: bellitabellota <136174454+bellitabellota@users.noreply.github.com> Date: Sat, 13 Sep 2025 13:03:34 +0100 Subject: [PATCH 3/3] Make donation site names hardcoded values --- spec/system/donation_site_system_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/system/donation_site_system_spec.rb b/spec/system/donation_site_system_spec.rb index f5693b3bca..b73dbdeb07 100644 --- a/spec/system/donation_site_system_spec.rb +++ b/spec/system/donation_site_system_spec.rb @@ -23,8 +23,8 @@ context "when exporting a csv with include inactive donation sites selected" do it "includes active and inactive donation sites" do - active_donation_site = create(:donation_site, name: "Active Donation Site") - inactive_donation_site = create(:donation_site, name: "Inactive Donation Site", active: false) + create(:donation_site, name: "Active Donation Site") + create(:donation_site, name: "Inactive Donation Site", active: false) visit subject check "Also include inactive donation sites" click_on "Filter" @@ -32,8 +32,8 @@ wait_for_download @csv_content = File.read(download) - expect(@csv_content).to have_content(active_donation_site.name) - expect(@csv_content).to have_content(inactive_donation_site.name) + expect(@csv_content).to have_content("Active Donation Site") + expect(@csv_content).to have_content("Inactive Donation Site") end end end