|
|
@ -2,10 +2,6 @@ require "rails_helper" |
|
|
|
require_relative "../../request_helper" |
|
|
|
require_relative "../../request_helper" |
|
|
|
|
|
|
|
|
|
|
|
RSpec.describe "form/page" do |
|
|
|
RSpec.describe "form/page" do |
|
|
|
before do |
|
|
|
|
|
|
|
RequestHelper.stub_http_requests |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let(:case_log) { FactoryBot.create(:case_log, :in_progress) } |
|
|
|
let(:case_log) { FactoryBot.create(:case_log, :in_progress) } |
|
|
|
let(:form) { case_log.form } |
|
|
|
let(:form) { case_log.form } |
|
|
|
let(:subsection) { form.get_subsection("income_and_benefits") } |
|
|
|
let(:subsection) { form.get_subsection("income_and_benefits") } |
|
|
@ -23,6 +19,7 @@ RSpec.describe "form/page" do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
before do |
|
|
|
|
|
|
|
RequestHelper.stub_http_requests |
|
|
|
assign(:case_log, case_log) |
|
|
|
assign(:case_log, case_log) |
|
|
|
assign(:page, page) |
|
|
|
assign(:page, page) |
|
|
|
assign(:subsection, subsection) |
|
|
|
assign(:subsection, subsection) |
|
|
@ -38,7 +35,7 @@ RSpec.describe "form/page" do |
|
|
|
assign_attributes(question, initial_question_attributes) |
|
|
|
assign_attributes(question, initial_question_attributes) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "given a page with a description" do |
|
|
|
context "with a page containing a description" do |
|
|
|
let(:description) { "Test description <a class=\"govuk-link\" href=\"/files/privacy-notice.pdf\">with link</a>." } |
|
|
|
let(:description) { "Test description <a class=\"govuk-link\" href=\"/files/privacy-notice.pdf\">with link</a>." } |
|
|
|
let(:page_attributes) { { description: description } } |
|
|
|
let(:page_attributes) { { description: description } } |
|
|
|
let(:expected_html) { '<p class="govuk-body govuk-body-m">Test description <a class="govuk-link" href="/files/privacy-notice.pdf">with link</a>.</p>' } |
|
|
|
let(:expected_html) { '<p class="govuk-body govuk-body-m">Test description <a class="govuk-link" href="/files/privacy-notice.pdf">with link</a>.</p>' } |
|
|
@ -48,14 +45,14 @@ RSpec.describe "form/page" do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "given a page with a header" do |
|
|
|
context "with a page containing a header" do |
|
|
|
it "renders the header and the subsection label" do |
|
|
|
it "renders the header and the subsection label" do |
|
|
|
expect(rendered).to match(page.header) |
|
|
|
expect(rendered).to match(page.header) |
|
|
|
expect(rendered).to match(subsection.label) |
|
|
|
expect(rendered).to match(subsection.label) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "given a page with a header and hide_subsection_label true" do |
|
|
|
context "with a page containing a header and hide_subsection_label true" do |
|
|
|
let(:page_attributes) { { hide_subsection_label: true } } |
|
|
|
let(:page_attributes) { { hide_subsection_label: true } } |
|
|
|
|
|
|
|
|
|
|
|
it "renders the header but not the subsection label" do |
|
|
|
it "renders the header but not the subsection label" do |
|
|
@ -64,7 +61,7 @@ RSpec.describe "form/page" do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "given a numeric question with prefix and suffix" do |
|
|
|
context "when rendering a numeric question with prefix and suffix" do |
|
|
|
let(:question_attributes) { { type: "numeric", prefix: "£", suffix: "every week" } } |
|
|
|
let(:question_attributes) { { type: "numeric", prefix: "£", suffix: "every week" } } |
|
|
|
|
|
|
|
|
|
|
|
it "renders prefix and suffix text" do |
|
|
|
it "renders prefix and suffix text" do |
|
|
@ -75,7 +72,7 @@ RSpec.describe "form/page" do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "given a question with extra guidance" do |
|
|
|
context "with a question containing extra guidance" do |
|
|
|
let(:expected_guidance) { /What counts as income?/ } |
|
|
|
let(:expected_guidance) { /What counts as income?/ } |
|
|
|
|
|
|
|
|
|
|
|
context "with radio type" do |
|
|
|
context "with radio type" do |
|
|
|