diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb index a1875081c..7f906b4ea 100644 --- a/app/helpers/filters_helper.rb +++ b/app/helpers/filters_helper.rb @@ -27,4 +27,12 @@ module FiltersHelper organisation_options = user.support? ? Organisation.all : [user.organisation] + user.organisation.managing_agents [OpenStruct.new(id: "", name: "Select an option")] + organisation_options.map { |org| OpenStruct.new(id: org.id, name: org.name) } end + + def collection_year_options + if FeatureToggle.collection_2023_2024_year_enabled? + { "2023": "2023/24", "2022": "2022/23", "2021": "2021/22" } + else + { "2022": "2022/23", "2021": "2021/22" } + end + end end diff --git a/app/views/logs/_log_filters.erb b/app/views/logs/_log_filters.erb index 8fb4f2ba4..a1aa752c3 100644 --- a/app/views/logs/_log_filters.erb +++ b/app/views/logs/_log_filters.erb @@ -6,7 +6,6 @@
<%= form_with html: { method: :get } do |f| %> - <% years = { "2021": "2021/22", "2022": "2022/23" } %> <% all_or_yours = { "all": { label: "All" }, "yours": { label: "Yours" } } %> <% if bulk_upload_options(@bulk_upload).present? %> @@ -23,7 +22,7 @@ <%= render partial: "filters/checkbox_filter", locals: { f: f, - options: years, + options: collection_year_options, label: "Collection year", category: "years", } %> diff --git a/config/initializers/feature_toggle.rb b/config/initializers/feature_toggle.rb index d31ee184b..60a97c95c 100644 --- a/config/initializers/feature_toggle.rb +++ b/config/initializers/feature_toggle.rb @@ -42,4 +42,8 @@ class FeatureToggle def self.validate_valid_radio_options? !(Rails.env.production? || Rails.env.staging?) end + + def self.collection_2023_2024_year_enabled? + !Rails.env.production? + end end diff --git a/spec/helpers/filters_helper_spec.rb b/spec/helpers/filters_helper_spec.rb index 656578326..3eccac743 100644 --- a/spec/helpers/filters_helper_spec.rb +++ b/spec/helpers/filters_helper_spec.rb @@ -116,4 +116,30 @@ RSpec.describe FiltersHelper do end end end + + describe "#collection_year_options" do + context "when not production" do + it "includes 2023/2024 option" do + expect(collection_year_options).to eq( + { + "2021": "2021/22", "2022": "2022/23", "2023": "2023/24" + }, + ) + end + end + + context "when production" do + before do + allow(Rails.env).to receive(:production?).and_return(true) + end + + it "includes 2023/2024 option" do + expect(collection_year_options).to eq( + { + "2021": "2021/22", "2022": "2022/23" + }, + ) + end + end + end end