Browse Source

Update 2024 discount max (#2213)

pull/2224/head
kosiakkatrina 11 months ago committed by GitHub
parent
commit
3c62e947b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/models/form/sales/questions/discount.rb
  2. 4
      spec/models/form/sales/pages/about_price_rtb_spec.rb
  3. 16
      spec/models/form/sales/questions/discount_spec.rb

2
app/models/form/sales/questions/discount.rb

@ -6,7 +6,7 @@ class Form::Sales::Questions::Discount < ::Form::Question
@header = "What was the percentage discount?" @header = "What was the percentage discount?"
@type = "numeric" @type = "numeric"
@min = 0 @min = 0
@max = 100 @max = form.start_year_after_2024? ? 70 : 100
@step = 1 @step = 1
@width = 5 @width = 5
@suffix = "%" @suffix = "%"

4
spec/models/form/sales/pages/about_price_rtb_spec.rb

@ -7,6 +7,10 @@ RSpec.describe Form::Sales::Pages::AboutPriceRtb, type: :model do
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(:form).and_return(instance_double(Form, start_year_after_2024?: false))
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

16
spec/models/form/sales/questions/discount_spec.rb

@ -6,6 +6,12 @@ RSpec.describe Form::Sales::Questions::Discount, type: :model do
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
before do
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_after_2024?: false))
end
it "has correct page" do it "has correct page" do
expect(question.page).to eq(page) expect(question.page).to eq(page)
@ -52,4 +58,14 @@ RSpec.describe Form::Sales::Questions::Discount, type: :model do
it "has correct max" do it "has correct max" do
expect(question.max).to eq(100) expect(question.max).to eq(100)
end end
context "with form start year after 2024" do
before do
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_after_2024?: true))
end
it "has correct max" do
expect(question.max).to eq(70)
end
end
end end

Loading…
Cancel
Save