Browse Source

CLDC-1909 Add 2023-2024 collection year filter (#1314)

pull/1319/head
Jack 2 years ago committed by GitHub
parent
commit
b6ff8bf896
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/helpers/filters_helper.rb
  2. 3
      app/views/logs/_log_filters.erb
  3. 4
      config/initializers/feature_toggle.rb
  4. 26
      spec/helpers/filters_helper_spec.rb

8
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

3
app/views/logs/_log_filters.erb

@ -6,7 +6,6 @@
<div class="app-filter__content">
<%= 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",
} %>

4
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

26
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

Loading…
Cancel
Save