Browse Source

CLDC-3257: Default to current collection year for BU guidance pages (#2695)

* CLDC-3257: Default to current collection year for BU guidance pages

* Ignore rubocop RSpec/AnyInstance when necessary
pull/2710/head
Rachael Booth 2 months ago committed by GitHub
parent
commit
2e6e56720d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      app/models/forms/bulk_upload_lettings/guidance.rb
  2. 7
      app/models/forms/bulk_upload_sales/guidance.rb
  3. 17
      spec/models/forms/bulk_upload_lettings/guidance_spec.rb
  4. 17
      spec/models/forms/bulk_upload_sales/guidance_spec.rb

7
app/models/forms/bulk_upload_lettings/guidance.rb

@ -4,11 +4,18 @@ module Forms
include ActiveModel::Model
include ActiveModel::Attributes
include Rails.application.routes.url_helpers
include CollectionTimeHelper
attribute :year, :integer
attribute :referrer
attribute :organisation_id, :integer
def initialize(params)
super(params)
self.year = current_collection_start_year if year.nil?
end
def view_path
"bulk_upload_shared/guidance"
end

7
app/models/forms/bulk_upload_sales/guidance.rb

@ -4,11 +4,18 @@ module Forms
include ActiveModel::Model
include ActiveModel::Attributes
include Rails.application.routes.url_helpers
include CollectionTimeHelper
attribute :year, :integer
attribute :referrer
attribute :organisation_id, :integer
def initialize(params)
super(params)
self.year = current_collection_start_year if year.nil?
end
def view_path
"bulk_upload_shared/guidance"
end

17
spec/models/forms/bulk_upload_lettings/guidance_spec.rb

@ -6,6 +6,7 @@ RSpec.describe Forms::BulkUploadLettings::Guidance do
subject(:bu_guidance) { described_class.new(year:, referrer:) }
let(:year) { 2024 }
let(:referrer) { nil }
describe "#back_path" do
context "when referrer is prepare-your-file" do
@ -40,4 +41,20 @@ RSpec.describe Forms::BulkUploadLettings::Guidance do
end
end
end
describe "year" do
context "when year is not provided" do
let(:year) { nil }
before do
# rubocop:disable RSpec/AnyInstance
allow_any_instance_of(CollectionTimeHelper).to receive(:current_collection_start_year).and_return(2030)
# rubocop:enable RSpec/AnyInstance
end
it "is set to the current collection start year" do
expect(bu_guidance.year).to eq(2030)
end
end
end
end

17
spec/models/forms/bulk_upload_sales/guidance_spec.rb

@ -6,6 +6,7 @@ RSpec.describe Forms::BulkUploadSales::Guidance do
subject(:bu_guidance) { described_class.new(year:, referrer:) }
let(:year) { 2024 }
let(:referrer) { nil }
describe "#back_path" do
context "when referrer is prepare-your-file" do
@ -40,4 +41,20 @@ RSpec.describe Forms::BulkUploadSales::Guidance do
end
end
end
describe "year" do
context "when year is not provided" do
let(:year) { nil }
before do
# rubocop:disable RSpec/AnyInstance
allow_any_instance_of(CollectionTimeHelper).to receive(:current_collection_start_year).and_return(2030)
# rubocop:enable RSpec/AnyInstance
end
it "is set to the current collection start year" do
expect(bu_guidance.year).to eq(2030)
end
end
end
end

Loading…
Cancel
Save