Skip to content

Commit a956764

Browse files
committed
added tests for_existing_region
1 parent ab67e0d commit a956764

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

spec/forms/support_interface/region_form_spec.rb

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,73 @@
258258
end
259259
end
260260
end
261+
262+
describe ".for_existing_region" do
263+
subject(:form) { described_class.for_existing_region(region) }
264+
265+
let(:region) do
266+
create(
267+
:region,
268+
application_form_skip_work_history: false,
269+
other_information: "Other information",
270+
reduced_evidence_accepted: false,
271+
requires_preliminary_check: false,
272+
sanction_check: "none",
273+
sanction_information: "Sanction information",
274+
status_check: "none",
275+
status_information: "Status information",
276+
teaching_authority_address: "Teaching Authority Address",
277+
teaching_authority_certificate: "Teaching Authority Certificate",
278+
teaching_authority_emails: %w[http://site1.com http://site2.com],
279+
written_statement_optional: true,
280+
)
281+
end
282+
283+
it "returns a RegionForm for the region" do
284+
expect(subject).to have_attributes(
285+
all_sections_necessary: true,
286+
other_information: "Other information",
287+
requires_preliminary_check: false,
288+
sanction_check: "none",
289+
sanction_information: "Sanction information",
290+
status_check: "none",
291+
status_information: "Status information",
292+
teaching_authority_address: "Teaching Authority Address",
293+
teaching_authority_certificate: "Teaching Authority Certificate",
294+
teaching_authority_emails_string: "http://site1.com\nhttp://site2.com",
295+
teaching_authority_name: "",
296+
teaching_authority_online_checker_url: "",
297+
teaching_authority_provides_written_statement: false,
298+
teaching_authority_requires_submission_email: false,
299+
teaching_authority_websites_string: "",
300+
teaching_qualification_information: "",
301+
work_history_section_to_omit: nil,
302+
written_statement_optional: true,
303+
)
304+
end
305+
306+
context "when application_form_skip_work_history is true" do
307+
let(:region) { create(:region, application_form_skip_work_history: true) }
308+
309+
it "sets all_sections_necessary to false" do
310+
expect(subject.all_sections_necessary).to be(false)
311+
end
312+
313+
it "sets work_history_section_to_omit to whole_section" do
314+
expect(subject.work_history_section_to_omit).to eq("whole_section")
315+
end
316+
end
317+
318+
context "when reduced_evidence_accepted is true" do
319+
let(:region) { create(:region, reduced_evidence_accepted: true) }
320+
321+
it "sets all_sections_necessary to false" do
322+
expect(subject.all_sections_necessary).to be(false)
323+
end
324+
325+
it "sets work_history_section_to_omit to contact_details" do
326+
expect(subject.work_history_section_to_omit).to eq("contact_details")
327+
end
328+
end
329+
end
261330
end

0 commit comments

Comments
 (0)