diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb index 11c6058bd..b6794729d 100644 --- a/app/helpers/filters_helper.rb +++ b/app/helpers/filters_helper.rb @@ -117,7 +117,7 @@ module FiltersHelper end def logs_for_both_needstypes_present? - [1, 2].all? { |needstype| current_user.lettings_logs.where(needstype:).count.positive? } + [1, 2].all? { |needstype| current_user.lettings_logs.visible.where(needstype:).count.positive? } end def non_support_with_multiple_owning_orgs? diff --git a/app/views/logs/_log_filters.html.erb b/app/views/logs/_log_filters.html.erb index dbac67326..3b531301c 100644 --- a/app/views/logs/_log_filters.html.erb +++ b/app/views/logs/_log_filters.html.erb @@ -42,7 +42,7 @@ category: "status", } %> - <% if logs_for_both_needstypes_present? && user_or_org_lettings_path? %> + <% if (current_user.support? || logs_for_both_needstypes_present?) && user_or_org_lettings_path? %> <%= render partial: "filters/checkbox_filter", locals: { f:, diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index b3ee773d1..d657ea3dc 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -756,10 +756,10 @@ RSpec.describe "User Features" do expect(page).to have_field("owning-organisation-field", with: "") find("#owning-organisation-field").click.native.send_keys("F", "i", "l", "t", :down, :enter) click_button("Apply filters") - expect(page).to have_current_path("/lettings-logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&assigned_to=all&owning_organisation_select=specific_org&owning_organisation=#{parent_organisation.id}&managing_organisation_select=all") + expect(page).to have_current_path("/lettings-logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&%5Bneedstypes%5D%5B%5D=&assigned_to=all&owning_organisation_select=specific_org&owning_organisation=#{parent_organisation.id}&managing_organisation_select=all") choose("owning-organisation-select-all-field", allow_label_click: true) click_button("Apply filters") - expect(page).to have_current_path("/lettings-logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&assigned_to=all&owning_organisation_select=all&managing_organisation_select=all") + expect(page).to have_current_path("/lettings-logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&%5Bneedstypes%5D%5B%5D=&assigned_to=all&owning_organisation_select=all&managing_organisation_select=all") end end end