Browse Source

Format date on check answers page

pull/183/head
baarkerlounger 3 years ago
parent
commit
5e2222675e
  1. 1
      app/models/form/question.rb
  2. 12
      spec/models/form/question_spec.rb

1
app/models/form/question.rb

@ -26,6 +26,7 @@ class Form::Question
def answer_label(case_log)
return checkbox_answer_label(case_log) if type == "checkbox"
return case_log[id].strftime("%d %b %Y") if type == "date"
case_log[id].to_s
end

12
spec/models/form/question_spec.rb

@ -110,6 +110,18 @@ RSpec.describe Form::Question, type: :model do
expect(subject.update_answer_link_name(case_log)).to eq("Change")
end
context "when type is date" do
let(:section_id) { "local_authority" }
let(:subsection_id) { "local_authority" }
let(:page_id) { "property_major_repairs" }
let(:question_id) { "mrcdate" }
it "displays a formatted answer label" do
case_log.mrcdate = Time.zone.local(2021, 10, 11)
expect(subject.answer_label(case_log)).to eq("11 Oct 2021")
end
end
context "when type is checkbox" do
let(:section_id) { "household" }
let(:subsection_id) { "household_needs" }

Loading…
Cancel
Save