|
|
@ -99,17 +99,17 @@ RSpec.describe Form::Question, type: :model do |
|
|
|
|
|
|
|
|
|
|
|
context "with a case log" do |
|
|
|
context "with a case log" do |
|
|
|
let(:case_log) { FactoryBot.build(:case_log, :in_progress) } |
|
|
|
let(:case_log) { FactoryBot.build(:case_log, :in_progress) } |
|
|
|
|
|
|
|
let(:question_id) { "incfreq" } |
|
|
|
|
|
|
|
|
|
|
|
it "has an answer label" do |
|
|
|
it "has an answer label" do |
|
|
|
case_log.earnings = 100 |
|
|
|
case_log.incfreq = "Weekly" |
|
|
|
expect(question.answer_label(case_log)).to eq("100") |
|
|
|
expect(question.answer_label(case_log)).to eq("Weekly") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "has an update answer link text helper" do |
|
|
|
it "has an update answer link text helper" do |
|
|
|
expect(question.update_answer_link_name(case_log)).to eq("Answer<span class=\"govuk-visually-hidden\"> income</span>") |
|
|
|
expect(question.update_answer_link_name(case_log)).to match(/Answer/) |
|
|
|
case_log[question_id] = 5 |
|
|
|
|
|
|
|
case_log["incfreq"] = "Weekly" |
|
|
|
case_log["incfreq"] = "Weekly" |
|
|
|
expect(question.update_answer_link_name(case_log)).to eq("Change<span class=\"govuk-visually-hidden\"> income</span>") |
|
|
|
expect(question.update_answer_link_name(case_log)).to match(/Change/) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when type is date" do |
|
|
|
context "when type is date" do |
|
|
@ -156,6 +156,23 @@ RSpec.describe Form::Question, type: :model do |
|
|
|
expect(question.enabled?(case_log)).to be true |
|
|
|
expect(question.enabled?(case_log)).to be true |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when answers have a suffix dependent on another answer" do |
|
|
|
|
|
|
|
let(:section_id) { "rent_and_charges" } |
|
|
|
|
|
|
|
let(:subsection_id) { "income_and_benefits" } |
|
|
|
|
|
|
|
let(:page_id) { "net_income" } |
|
|
|
|
|
|
|
let(:question_id) { "earnings" } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "displays the correct label for given suffix and answer the suffix depends on" do |
|
|
|
|
|
|
|
case_log.incfreq = "Weekly" |
|
|
|
|
|
|
|
case_log.earnings = 500 |
|
|
|
|
|
|
|
expect(question.answer_label(case_log)).to eq("£500.00 every week") |
|
|
|
|
|
|
|
case_log.incfreq = "Monthly" |
|
|
|
|
|
|
|
expect(question.answer_label(case_log)).to eq("£500.00 every month") |
|
|
|
|
|
|
|
case_log.incfreq = "Yearly" |
|
|
|
|
|
|
|
expect(question.answer_label(case_log)).to eq("£500.00 every year") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe ".completed?" do |
|
|
|
describe ".completed?" do |
|
|
|