From 903f974343eae788ece070974804e27cc3ef1a30 Mon Sep 17 00:00:00 2001 From: Cory Streiff <90390502+coalest@users.noreply.github.com> Date: Wed, 11 Dec 2024 00:56:46 +0100 Subject: [PATCH 1/2] Show all active partners on distributions page unrestricted by filter (#4836) * Show all active partners on distributions page unrestricted by filter * Move spec to make PR diff more legible --- app/controllers/distributions_controller.rb | 2 +- spec/factories/partners.rb | 4 ++++ spec/requests/distributions_requests_spec.rb | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/controllers/distributions_controller.rb b/app/controllers/distributions_controller.rb index d2776bf981..ffc3711da6 100644 --- a/app/controllers/distributions_controller.rb +++ b/app/controllers/distributions_controller.rb @@ -50,7 +50,7 @@ def index @items = current_organization.items.alphabetized.select(:id, :name) @item_categories = current_organization.item_categories.select(:id, :name) @storage_locations = current_organization.storage_locations.active_locations.alphabetized.select(:id, :name) - @partners = Partner.joins(:distributions).where(distributions: @distributions).distinct.order(:name).select(:id, :name) + @partners = current_organization.partners.active.alphabetized.select(:id, :name) @selected_item = filter_params[:by_item_id].presence @distribution_totals = DistributionTotalsService.new(current_organization.distributions, scope_filters) @total_value_all_distributions = @distribution_totals.total_value diff --git a/spec/factories/partners.rb b/spec/factories/partners.rb index ba34f27bbe..894dd6ff62 100644 --- a/spec/factories/partners.rb +++ b/spec/factories/partners.rb @@ -40,6 +40,10 @@ status { :awaiting_review } end + trait :deactivated do + status { :deactivated } + end + after(:create) do |partner, evaluator| next if evaluator.try(:without_profile) diff --git a/spec/requests/distributions_requests_spec.rb b/spec/requests/distributions_requests_spec.rb index 8ce7533ed6..0f0d15a3a3 100644 --- a/spec/requests/distributions_requests_spec.rb +++ b/spec/requests/distributions_requests_spec.rb @@ -104,6 +104,24 @@ end end + context "with filters" do + it "shows all active partners in dropdown filter unrestricted by current filter" do + inactive_partner_name = create(:partner, :deactivated, organization:).name + active_partner_name = distribution.partner.name + + # Filter by date with no distributions + params = { filters: { date_range: "January 1,9999 - January 1,9999"} } + + get distributions_path, params: params + page = Nokogiri::HTML(response.body) + partner_select = page.at_css("select[name='filters[by_partner]']") + + expect(partner_select).to be_present + expect(partner_select.text).to include(active_partner_name) + expect(partner_select.text).not_to include(inactive_partner_name) + end + end + context "when filtering by item id" do let!(:item_2) { create(:item, value_in_cents: 100, organization: organization) } let(:params) { { filters: { by_item_id: item.id } } } From de827ae88e1ee79d7f43bdba2b88d53be0aab916 Mon Sep 17 00:00:00 2001 From: CL Fisher Date: Tue, 10 Dec 2024 18:57:14 -0500 Subject: [PATCH 2/2] adding partner_step_form to seed so it will be in place for staging and local (#4838) --- db/seeds.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/seeds.rb b/db/seeds.rb index efb93dc358..0746d2f6ca 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -739,7 +739,8 @@ def seed_quantity(item_name, organization, storage_location, quantity) Flipper::Adapters::ActiveRecord::Feature.find_or_create_by(key: "new_logo") Flipper::Adapters::ActiveRecord::Feature.find_or_create_by(key: "read_events") Flipper.enable(:read_events) - +Flipper::Adapters::ActiveRecord::Feature.find_or_create_by(key: "partner_step_form") +Flipper.enable(:partner_step_form) # ---------------------------------------------------------------------------- # Account Requests # ----------------------------------------------------------------------------