Browse Source

CLDC-3202 Update year filters for 24/25 (#2216)

* feat: replace 21/22 filter with 24/25 filter, add feature toggle so this appears everywhere but prod

* feat: update filters automatically year-on-year

* feat: update filters automatically year-on-year and test

* refactor: lint

* refactor: minor renaming

* feat: time travel for PO

* feat: time travel for PO without breaking tests

* feat: update tests

* Revert time travelling

---------

Co-authored-by: Kat <katrina@kosiak.co.uk>
pull/2233/head
natdeanlewissoftwire 10 months ago committed by GitHub
parent
commit
c9345ecaf1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/helpers/collection_time_helper.rb
  2. 12
      app/helpers/filters_helper.rb
  3. 8
      spec/features/organisation_spec.rb
  4. 38
      spec/helpers/filters_helper_spec.rb

4
app/helpers/collection_time_helper.rb

@ -46,6 +46,10 @@ module CollectionTimeHelper
current_collection_start_date - 1.year
end
def archived_collection_start_year
current_collection_start_year - 2
end
def quarter_for_date(date: Time.zone.now)
quarters = [
{ quarter: "Q3", cutoff_date: Time.zone.local(2024, 1, 12), start_date: Time.zone.local(2023, 10, 1), end_date: Time.zone.local(2023, 12, 31) },

12
app/helpers/filters_helper.rb

@ -1,4 +1,6 @@
module FiltersHelper
include CollectionTimeHelper
def filter_selected?(filter, value, filter_type)
return false unless session[session_name_for(filter_type)]
@ -93,7 +95,11 @@ module FiltersHelper
end
def collection_year_options
{ "2023": "2023/24", "2022": "2022/23", "2021": "2021/22" }
{
current_collection_start_year.to_s => year_combo(current_collection_start_year),
previous_collection_start_year.to_s => year_combo(previous_collection_start_year),
archived_collection_start_year.to_s => year_combo(archived_collection_start_year),
}
end
def filters_applied_text(filter_type)
@ -174,4 +180,8 @@ private
end
end
end
def year_combo(year)
"#{year}/#{year - 2000 + 1}"
end
end

8
spec/features/organisation_spec.rb

@ -196,9 +196,9 @@ RSpec.describe "User Features" do
end
it "can filter lettings logs by year" do
check("years-2021-field")
check("years-2022-field")
click_button("Apply filters")
expect(page).to have_current_path("/organisations/#{org_id}/lettings-logs?years[]=&years[]=2021&status[]=&needstypes[]=&assigned_to=all&user=&owning_organisation_select=all&owning_organisation=&managing_organisation_select=all&managing_organisation=")
expect(page).to have_current_path("/organisations/#{org_id}/lettings-logs?years[]=&years[]=2022&status[]=&needstypes[]=&assigned_to=all&user=&owning_organisation_select=all&owning_organisation=&managing_organisation_select=all&managing_organisation=")
expect(page).not_to have_link first_log.id.to_s, href: "/lettings-logs/#{first_log.id}"
end
@ -241,9 +241,9 @@ RSpec.describe "User Features" do
organisation.sales_logs.map(&:id).each do |sales_log_id|
expect(page).to have_link sales_log_id.to_s, href: "/sales-logs/#{sales_log_id}"
end
check("years-2021-field")
check("years-2022-field")
click_button("Apply filters")
expect(page).to have_current_path("/organisations/#{org_id}/sales-logs?years[]=&years[]=2021&status[]=&assigned_to=all&user=&owning_organisation_select=all&owning_organisation=&managing_organisation_select=all&managing_organisation=")
expect(page).to have_current_path("/organisations/#{org_id}/sales-logs?years[]=&years[]=2022&status[]=&assigned_to=all&user=&owning_organisation_select=all&owning_organisation=&managing_organisation_select=all&managing_organisation=")
expect(page).not_to have_link first_log.id.to_s, href: "/sales-logs/#{first_log.id}"
end
end

38
spec/helpers/filters_helper_spec.rb

@ -240,12 +240,38 @@ RSpec.describe FiltersHelper do
end
describe "#collection_year_options" do
it "includes 2023/2024 option" do
expect(collection_year_options).to eq(
{
"2021": "2021/22", "2022": "2022/23", "2023": "2023/24"
},
)
context "with 23/24 as the current collection year" do
around do |example|
Timecop.freeze(Time.zone.local(2023, 5, 1)) do
example.run
end
Timecop.return
end
it "has the correct options" do
expect(collection_year_options).to eq(
{
"2023" => "2023/24", "2022" => "2022/23", "2021" => "2021/22"
},
)
end
end
context "with 24/25 as the current collection year" do
around do |example|
Timecop.freeze(Time.zone.local(2024, 5, 1)) do
example.run
end
Timecop.return
end
it "has the correct options" do
expect(collection_year_options).to eq(
{
"2024" => "2024/25", "2023" => "2023/24", "2022" => "2022/23"
},
)
end
end
end

Loading…
Cancel
Save