Skip to content

Commit

Permalink
Merge pull request #2504 from DFE-Digital/AQTS-645-part3
Browse files Browse the repository at this point in the history
AQTS-645-support-interface-testing-part3
  • Loading branch information
syed87 authored Nov 13, 2024
2 parents 63c720f + 5784e45 commit 0638486
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec/factories/countries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
factory :country do
sequence :code, Country::CODES.cycle

trait :eligibility_skip_questions do
eligibility_skip_questions { true }
end

trait :subject_limited do
subject_limited { true }
end
Expand Down
64 changes: 64 additions & 0 deletions spec/forms/support_interface/country_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,68 @@
end
end
end

describe "#for_existing_country" do
subject(:form) { described_class.for_existing_country(country) }

let(:country) do
create(
:country,
other_information:,
status_information:,
sanction_information:,
teaching_qualification_information:,
)
end
let(:other_information) { "Other information" }
let(:status_information) { "Status information" }
let(:sanction_information) { "Sanction information" }
let(:teaching_qualification_information) do
"Teaching qualification information"
end

it "returns a CountryForm for the country" do
expect(subject).to have_attributes(
eligibility_enabled: true,
eligibility_route: "standard",
has_regions: false,
region_names: "",
other_information: "Other information",
status_information: "Status information",
sanction_information: "Sanction information",
teaching_qualification_information:
"Teaching qualification information",
)
end

context "when the country is subject limited" do
let(:country) { create(:country, :subject_limited) }

it "sets the eligibility route to expanded" do
expect(subject).to have_attributes(eligibility_route: "expanded")
end
end

context "when the country has eligibility skip questions" do
let(:country) { create(:country, :eligibility_skip_questions) }

it "sets the eligibility route to reduced" do
expect(subject).to have_attributes(eligibility_route: "reduced")
end
end

context "when the country has regions" do
before do
create(:region, name: "Madrid", country:)
create(:region, name: "Barcelona", country:)
end

it "sets has_regions to true" do
expect(subject).to have_attributes(
has_regions: true,
region_names: "Madrid\nBarcelona",
)
end
end
end
end

0 comments on commit 0638486

Please sign in to comment.