Browse Source

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

pull/2216/head
natdeanlewissoftwire 2 years ago
parent
commit
94d72553ae
  1. 1
      db/schema.rb
  2. 39
      spec/helpers/filters_helper_spec.rb

1
db/schema.rb

@ -303,6 +303,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_01_30_084707) do
t.integer "scharge_value_check" t.integer "scharge_value_check"
t.integer "pscharge_value_check" t.integer "pscharge_value_check"
t.integer "duplicate_set_id" t.integer "duplicate_set_id"
t.integer "accessible_register"
t.integer "nationality_all" t.integer "nationality_all"
t.integer "nationality_all_group" t.integer "nationality_all_group"
t.index ["bulk_upload_id"], name: "index_lettings_logs_on_bulk_upload_id" t.index ["bulk_upload_id"], name: "index_lettings_logs_on_bulk_upload_id"

39
spec/helpers/filters_helper_spec.rb

@ -1,4 +1,6 @@
require "rails_helper" require "rails_helper"
require "timecop"
include CollectionTimeHelper
RSpec.describe FiltersHelper do RSpec.describe FiltersHelper do
describe "#filter_selected?" do describe "#filter_selected?" do
@ -240,12 +242,37 @@ RSpec.describe FiltersHelper do
end end
describe "#collection_year_options" do describe "#collection_year_options" do
it "includes 2023/2024 option" do context "with 23/24 as the current collection year" do
expect(collection_year_options).to eq( around do |example|
{ Timecop.freeze(Time.zone.local(2023, 5, 1)) do
"2021": "2021/22", "2022": "2022/23", "2023": "2023/24" 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
end end

Loading…
Cancel
Save