Browse Source

Update routing for LaNominations

pull/2203/head
Kat 2 years ago
parent
commit
e3a90a54e4
  1. 6
      app/models/form/sales/pages/la_nominations.rb
  2. 53
      spec/models/form/sales/pages/la_nominations_spec.rb

6
app/models/form/sales/pages/la_nominations.rb

@ -9,4 +9,10 @@ class Form::Sales::Pages::LaNominations < ::Form::Page
Form::Sales::Questions::LaNominations.new(nil, nil, self), Form::Sales::Questions::LaNominations.new(nil, nil, self),
] ]
end end
def routed_to?(log, _current_user)
return false if log.staircase == 1 && log.form.start_year_after_2024?
super
end
end end

53
spec/models/form/sales/pages/la_nominations_spec.rb

@ -3,10 +3,16 @@ require "rails_helper"
RSpec.describe Form::Sales::Pages::LaNominations, type: :model do RSpec.describe Form::Sales::Pages::LaNominations, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) } subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:log) { create(:sales_log, :completed) }
let(:page_id) { nil } let(:page_id) { nil }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) } let(:subsection) { instance_double(Form::Subsection) }
before do
allow(subsection).to receive(:depends_on).and_return(nil)
end
it "has correct subsection" do it "has correct subsection" do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
end end
@ -26,4 +32,51 @@ RSpec.describe Form::Sales::Pages::LaNominations, type: :model do
it "has the correct description" do it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end end
context "with 23/24 log" do
before do
Timecop.freeze(Time.zone.local(2023, 4, 2))
Singleton.__init__(FormHandler)
end
after do
Timecop.return
end
it "has correct routed to" do
log.staircase = 1
expect(page.routed_to?(log, nil)).to eq(true)
end
end
context "with 24/25 log" do
before do
Timecop.freeze(Time.zone.local(2024, 4, 2))
Singleton.__init__(FormHandler)
end
after do
Timecop.return
end
it "has correct routed to when staircase is yes" do
log.staircase = 1
expect(page.routed_to?(log, nil)).to eq(false)
end
it "has correct routed to when staircase is nil" do
log.staircase = nil
expect(page.routed_to?(log, nil)).to eq(true)
end
it "has correct routed to when staircase is no" do
log.staircase = 2
expect(page.routed_to?(log, nil)).to eq(true)
end
it "has correct routed to when staircase is don't know" do
log.staircase = 3
expect(page.routed_to?(log, nil)).to eq(true)
end
end
end end

Loading…
Cancel
Save