Browse Source

Include specific managing and owning orgs in filter count (#1791)

* feat: update filter count to include managing/owning org select

* feat: update tests

* feat: fix when org filters display

* feat: update tests

* feat: update tests

* feat: update tests

* feat: update tests
pull/1798/head
natdeanlewissoftwire 1 year ago committed by GitHub
parent
commit
0c7f2aceb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/helpers/filters_helper.rb
  2. 14
      spec/features/lettings_log_spec.rb
  3. 5
      spec/helpers/filters_helper_spec.rb

4
app/helpers/filters_helper.rb

@ -91,8 +91,8 @@ private
filters.each.sum do |category, category_filters|
if %w[status years bulk_upload_id].include?(category)
category_filters.count(&:present?)
elsif %w[assigned_to organisation].include?(category)
category_filters != "all" ? 1 : 0
elsif %w[user owning_organisation managing_organisation].include?(category)
1
else
0
end

14
spec/features/lettings_log_spec.rb

@ -59,9 +59,17 @@ RSpec.describe "Lettings Log Features" do
context "when filtering logs" do
let(:user) { create(:user, last_sign_in_at: Time.zone.now) }
let(:stock_owner_1) { create(:organisation, name: "stock owner 1") }
let(:stock_owner_2) { create(:organisation, name: "stock owner 2") }
let(:managing_agent_1) { create(:organisation, name: "managing agent 1") }
let(:managing_agent_2) { create(:organisation, name: "managing agent 2") }
context "when I am signed in" do
before do
FactoryBot.create(:organisation_relationship, child_organisation: user.organisation, parent_organisation: stock_owner_1)
FactoryBot.create(:organisation_relationship, child_organisation: user.organisation, parent_organisation: stock_owner_2)
FactoryBot.create(:organisation_relationship, child_organisation: managing_agent_1, parent_organisation: user.organisation)
FactoryBot.create(:organisation_relationship, child_organisation: managing_agent_2, parent_organisation: user.organisation)
visit("/lettings-logs")
fill_in("user[email]", with: user.email)
fill_in("user[password]", with: user.password)
@ -80,11 +88,15 @@ RSpec.describe "Lettings Log Features" do
check("Not started")
check("In progress")
choose("You")
choose("Specific owning organisation")
select(stock_owner_1.name, from: "owning_organisation")
choose("Specific managing organisation")
select(managing_agent_1.name, from: "managing_organisation")
click_button("Apply filters")
end
it "displays the filters component with a correct count and clear button" do
expect(page).to have_content("3 filters applied")
expect(page).to have_content("5 filters applied")
expect(page).to have_content("Clear")
end

5
spec/helpers/filters_helper_spec.rb

@ -222,7 +222,7 @@ RSpec.describe FiltersHelper do
"assigned_to" => "all",
"status" => [""],
"years" => [""],
"organisation" => "all",
"organisation_select" => "all",
}
end
@ -237,7 +237,8 @@ RSpec.describe FiltersHelper do
"assigned_to" => "all",
"status" => %w[in_progress completed],
"years" => [""],
"organisation" => 2,
"organisation_select" => "specific_org",
"managing_organisation" => 2,
}
end

Loading…
Cancel
Save