diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 0952d12ac..4612e6bc9 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -33,7 +33,7 @@ class OrganisationsController < ApplicationController organisation_schemes = Scheme.where(owning_organisation: [@organisation] + @organisation.parent_organisations) unpaginated_filtered_schemes = filter_manager.filtered_schemes(organisation_schemes, search_term, session_filters) - render "schemes/download_csv", locals: { search_term:, post_path: email_csv_schemes_path, download_type: params[:download_type], schemes: unpaginated_filtered_schemes } + render "schemes/download_csv", locals: { search_term:, post_path: schemes_email_csv_organisation_path, download_type: params[:download_type], schemes: unpaginated_filtered_schemes } end def email_schemes_csv diff --git a/spec/features/organisation_spec.rb b/spec/features/organisation_spec.rb index 43c0a9d8e..8737ed1c1 100644 --- a/spec/features/organisation_spec.rb +++ b/spec/features/organisation_spec.rb @@ -327,6 +327,19 @@ RSpec.describe "User Features" do end end + context "when viewing schemes for specific organisation" do + before do + create(:scheme, owning_organisation: organisation) + visit("/organisations/#{org_id}/schemes") + end + + it "allows downloading schemes csv for the specific org" do + click_link("Download schemes (CSV)") + click_button("Send email") + expect(page).to have_current_path("/organisations/#{org_id}/schemes/csv-confirmation") + end + end + context "and the organisation does not hold housing stock" do before do organisation.update!(holds_own_stock: false)