Skip to content

Commit

Permalink
Merge branch '4818-fix-product-drive-print' of https://github.com/gab…
Browse files Browse the repository at this point in the history
…eparra01/human-essentials into 4818-fix-product-drive-print
  • Loading branch information
Gabe authored and Gabe committed Dec 11, 2024
2 parents e3b10d0 + 8f63509 commit eef0854
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
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.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
Expand Down
3 changes: 2 additions & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ----------------------------------------------------------------------------
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 @@ -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 } } }
Expand Down

0 comments on commit eef0854

Please sign in to comment.