From 3c62e947b9965fbea508c4b314773ee59cf60cd5 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:17:45 +0000 Subject: [PATCH] Update 2024 discount max (#2213) --- app/models/form/sales/questions/discount.rb | 2 +- .../form/sales/pages/about_price_rtb_spec.rb | 4 ++++ .../models/form/sales/questions/discount_spec.rb | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/models/form/sales/questions/discount.rb b/app/models/form/sales/questions/discount.rb index ee39b8916..4c4595ce1 100644 --- a/app/models/form/sales/questions/discount.rb +++ b/app/models/form/sales/questions/discount.rb @@ -6,7 +6,7 @@ class Form::Sales::Questions::Discount < ::Form::Question @header = "What was the percentage discount?" @type = "numeric" @min = 0 - @max = 100 + @max = form.start_year_after_2024? ? 70 : 100 @step = 1 @width = 5 @suffix = "%" diff --git a/spec/models/form/sales/pages/about_price_rtb_spec.rb b/spec/models/form/sales/pages/about_price_rtb_spec.rb index c73a83b61..81cfbc6fc 100644 --- a/spec/models/form/sales/pages/about_price_rtb_spec.rb +++ b/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(: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 expect(page.subsection).to eq(subsection) end diff --git a/spec/models/form/sales/questions/discount_spec.rb b/spec/models/form/sales/questions/discount_spec.rb index f40b2eded..c3b7d24a1 100644 --- a/spec/models/form/sales/questions/discount_spec.rb +++ b/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_definition) { nil } 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 expect(question.page).to eq(page) @@ -52,4 +58,14 @@ RSpec.describe Form::Sales::Questions::Discount, type: :model do it "has correct max" do expect(question.max).to eq(100) 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