Skip to content

Commit

Permalink
Show all active partners on distributions page unrestricted by filter
Browse files Browse the repository at this point in the history
  • Loading branch information
coalest committed Dec 9, 2024
1 parent d60dfae commit 1ff6759
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/distributions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def index
@items = current_organization.items.alphabetized
@item_categories = current_organization.item_categories
@storage_locations = current_organization.storage_locations.active_locations.alphabetized
@partners = @distributions.collect(&:partner).uniq.sort_by(&:name)
@partners = current_organization.partners.active.alphabetized.select(:id, :name)
@selected_item = filter_params[:by_item_id].presence
@total_value_all_distributions = total_value(@distributions)
@total_items_all_distributions = total_items(@distributions, @selected_item)
Expand Down
4 changes: 4 additions & 0 deletions spec/factories/partners.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
18 changes: 18 additions & 0 deletions spec/requests/distributions_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@
expect(response.body).to match(/Has Inactive Items/)
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
end

describe "POST #create" do
Expand Down

0 comments on commit 1ff6759

Please sign in to comment.