Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove preliminary check from country #1664

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/controllers/support_interface/countries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def edit
other_information: country.other_information,
qualifications_information: country.qualifications_information,
region_names: country.regions.pluck(:name).join("\n"),
requires_preliminary_check: country.requires_preliminary_check,
sanction_information: country.sanction_information,
status_information: country.status_information,
teaching_authority_address: country.teaching_authority_address,
Expand Down Expand Up @@ -70,7 +69,6 @@ def country_params
:other_information,
:qualifications_information,
:region_names,
:requires_preliminary_check,
:sanction_information,
:status_information,
:teaching_authority_address,
Expand Down
3 changes: 0 additions & 3 deletions app/forms/support_interface/country_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class SupportInterface::CountryForm
attribute :other_information, :string
attribute :qualifications_information, :string
attribute :region_names, :string
attribute :requires_preliminary_check, :boolean
attribute :sanction_information, :string
attribute :status_information, :string
attribute :teaching_authority_address, :string
Expand All @@ -27,7 +26,6 @@ class SupportInterface::CountryForm
validates :eligibility_skip_questions, inclusion: { in: [true, false] }
validates :has_regions, inclusion: { in: [true, false] }
validates :region_names, presence: true, if: :has_regions
validates :requires_preliminary_check, inclusion: { in: [true, false] }

def save!
ActiveRecord::Base.transaction do
Expand Down Expand Up @@ -55,7 +53,6 @@ def assign_country_attributes
eligibility_skip_questions:,
other_information:,
qualifications_information:,
requires_preliminary_check:,
sanction_information:,
status_information:,
teaching_authority_address:,
Expand Down
3 changes: 1 addition & 2 deletions app/lib/application_form_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def needs_registration_number
end

def requires_preliminary_check
region.requires_preliminary_check ||
region.country.requires_preliminary_check
region.requires_preliminary_check
end
end
1 change: 0 additions & 1 deletion app/models/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# eligibility_skip_questions :boolean default(FALSE), not null
# other_information :text default(""), not null
# qualifications_information :text default(""), not null
# requires_preliminary_check :boolean default(FALSE), not null
# sanction_information :string default(""), not null
# status_information :string default(""), not null
# teaching_authority_address :text default(""), not null
Expand Down
7 changes: 0 additions & 7 deletions app/models/region.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ class Region < ApplicationRecord

validates :teaching_authority_online_checker_url, url: { allow_blank: true }

scope :requires_preliminary_check,
-> {
joins(:country).where(requires_preliminary_check: true).or(
where(country: { requires_preliminary_check: true }),
)
}

def checks_available?
!sanction_check_none? && !status_check_none?
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/backfill_preliminary_checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def call
attr_reader :user

def regions
@regions ||= Region.requires_preliminary_check
@regions ||= Region.where(requires_preliminary_check: true)
end

def applications_forms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</p>
<% end %>

<% if region.requires_preliminary_check || region.country.requires_preliminary_check %>
<% if region.requires_preliminary_check %>
<p class="govuk-body govuk-!-font-weight-bold">
Do not request this document yet – we’ll carry out some checks on your application first. If your application passes these checks, we’ll then email you and ask you to request the document.
</p>
Expand Down

This file was deleted.

22 changes: 9 additions & 13 deletions app/views/support_interface/countries/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@
<%= form_with model: @form, url: [:support_interface, @country], method: :put do |f| %>
<%= f.govuk_error_summary %>

<%= f.govuk_radio_buttons_fieldset :has_regions, legend: { size: "m", text: "Regions" }, hint: { text: "Does this country have regions within it that have a different teaching authority or service journey?" } do %>
<%= f.govuk_radio_buttons_fieldset :has_regions, legend: { text: "Regions" }, hint: { text: "Does this country have regions within it that have a different teaching authority or service journey?" } do %>
<%= f.govuk_radio_button :has_regions, :false, label: { text: "No" }, link_errors: true %>
<%= f.govuk_radio_button :has_regions, :true, label: { text: "Yes" } do %>
<%= f.govuk_text_area :region_names, label: nil, hint: { text: "Add regions below, one region per line. (This will allow you to customise the service for each region.) " }, rows: 10 %>
<% end %>
<% end %>

<%= f.govuk_fieldset legend: { text: "Application form" } do %>
<%= f.govuk_collection_radio_buttons :eligibility_enabled,
[
OpenStruct.new(value: :true, label: "Yes"),
OpenStruct.new(value: :false, label: "No")
],
:value,
:label,
legend: { text: "Do we accept applications from this country?", size: "s" } %>

<%= render "shared/support_interface/forms/requires_preliminary_check", f: %>
<% end %>
<%= f.govuk_collection_radio_buttons :eligibility_enabled,
[
OpenStruct.new(value: :true, label: "Yes"),
OpenStruct.new(value: :false, label: "No")
],
:value,
:label,
legend: { text: "Do we accept applications from this country?" } %>

<%= f.govuk_collection_radio_buttons :eligibility_skip_questions,
[
Expand Down
6 changes: 0 additions & 6 deletions app/views/support_interface/countries/preview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
<p class="govuk-body"><%= govuk_boolean_tag(@country.eligibility_enabled) %></p>
<% end %>

<% if @country.requires_preliminary_check_changed? %>
<h3 class="govuk-heading-s">Preliminary check</h3>
<p class="govuk-body"><%= govuk_boolean_tag(@country.requires_preliminary_check) %></p>
<% end %>

<% if @country.changes.keys.select { |k| k.starts_with?("teaching_authority_") }.any? %>
<h3 class="govuk-heading-s">Teaching authority</h3>

Expand Down Expand Up @@ -75,7 +70,6 @@
<%= f.hidden_field :other_information, value: @form.other_information %>
<%= f.hidden_field :qualifications_information, value: @form.qualifications_information %>
<%= f.hidden_field :region_names, value: @form.region_names %>
<%= f.hidden_field :requires_preliminary_check, value: @form.requires_preliminary_check %>
<%= f.hidden_field :sanction_information, value: @form.sanction_information %>
<%= f.hidden_field :status_information, value: @form.status_information %>
<%= f.hidden_field :teaching_authority_address, value: @form.teaching_authority_address %>
Expand Down
12 changes: 10 additions & 2 deletions app/views/support_interface/regions/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@

<%= f.govuk_check_box :application_form_skip_work_history, 1, 0, multiple: false, link_errors: true, small: true, label: { text: "Skip work history" } %>

<%= render "shared/support_interface/forms/requires_preliminary_check", f: %>
<%= f.govuk_collection_radio_buttons :requires_preliminary_check,
[
OpenStruct.new(value: :true, label: "Yes"),
OpenStruct.new(value: :false, label: "No")
],
:value,
:label,
legend: { text: "Will applications be subject to a preliminary check?", size: "s" } %>

<%= render "shared/support_interface/forms/status_sanctions_checks", f: %>
<%= render "shared/support_interface/forms/teaching_authority_form_fields", f: %>

<%= f.govuk_radio_buttons_fieldset(:teaching_authority_requires_submission_email, legend: { size: 'm', text: 'Automatically notify the teaching authority (via email) every time a QTS application is submitted?' }) do %>
<%= f.govuk_radio_buttons_fieldset :teaching_authority_requires_submission_email, legend: { size: 'm', text: 'Automatically notify the teaching authority (via email) every time a QTS application is submitted?' } do %>
<%= f.govuk_radio_button :teaching_authority_requires_submission_email, 'yes', label: { text: 'Yes' }, link_errors: true %>
<%= f.govuk_radio_button :teaching_authority_requires_submission_email, 'no', label: { text: 'No' }%>
<% end %>
Expand Down
1 change: 0 additions & 1 deletion config/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
- id
- other_information
- qualifications_information
- requires_preliminary_check
- sanction_information
- status_information
- teaching_authority_address
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class RemoveRequiresPreliminaryCheckFromCountries < ActiveRecord::Migration[7.0]
def change
remove_column :countries,
:requires_preliminary_check,
:boolean,
default: false,
null: false
end
end
15 changes: 7 additions & 8 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions spec/factories/application_forms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
teaching_authority_provides_written_statement do
region.teaching_authority_provides_written_statement
end
requires_preliminary_check { region.requires_preliminary_check }

trait :requires_preliminary_check do
requires_preliminary_check { true }
Expand Down
1 change: 0 additions & 1 deletion spec/factories/countries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# eligibility_skip_questions :boolean default(FALSE), not null
# other_information :text default(""), not null
# qualifications_information :text default(""), not null
# requires_preliminary_check :boolean default(FALSE), not null
# sanction_information :string default(""), not null
# status_information :string default(""), not null
# teaching_authority_address :text default(""), not null
Expand Down
1 change: 0 additions & 1 deletion spec/models/country_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# eligibility_skip_questions :boolean default(FALSE), not null
# other_information :text default(""), not null
# qualifications_information :text default(""), not null
# requires_preliminary_check :boolean default(FALSE), not null
# sanction_information :string default(""), not null
# status_information :string default(""), not null
# teaching_authority_address :text default(""), not null
Expand Down
23 changes: 0 additions & 23 deletions spec/models/region_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,6 @@
end
end

describe "scopes" do
describe "#requires_preliminary_check" do
subject(:requires_preliminary_check) do
described_class.requires_preliminary_check
end

let!(:normal_region) { create(:region) }
let!(:preliminary_region) do
create(:region, requires_preliminary_check: true)
end
let!(:preliminary_country_region) do
create(
:region,
country: create(:country, requires_preliminary_check: true),
)
end

it { is_expected.to_not include(normal_region) }
it { is_expected.to include(preliminary_region) }
it { is_expected.to include(preliminary_country_region) }
end
end

describe "#teaching_authority_emails_string" do
subject(:teaching_authority_emails_string) do
region.teaching_authority_emails_string
Expand Down
9 changes: 8 additions & 1 deletion spec/services/backfill_preliminary_checks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@

context "with application forms" do
let!(:submitted_application_form) do
create(:application_form, :submitted, :with_assessment, region:)
create(
:application_form,
:submitted,
:with_assessment,
region:,
requires_preliminary_check: false,
)
end
let!(:waiting_on_application_form) do
create(
Expand All @@ -25,6 +31,7 @@
region:,
waiting_on_professional_standing: true,
teaching_authority_provides_written_statement: true,
requires_preliminary_check: false,
)
end
let!(:preliminary_check_application_form) do
Expand Down
5 changes: 0 additions & 5 deletions spec/system/support_interface/countries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
when_i_fill_teaching_authority_certificate
when_i_fill_teaching_authority_online_checker_url
when_i_fill_qualifications_information
when_i_check_requires_preliminary_check
when_i_fill_regions
and_i_click_preview
then_i_see_country_contact_preview
Expand Down Expand Up @@ -114,7 +113,6 @@ def then_i_see_country_contact_preview
expect(page).to have_content("Certificate")
expect(page).to have_content("Other")
expect(page).to have_content("Qualifications information")
expect(page).to have_content("Preliminary check")
end

def then_i_see_region_changes_confirmation
Expand Down Expand Up @@ -238,9 +236,6 @@ def when_i_check_written_statement_optional

def when_i_check_requires_preliminary_check
choose "region-requires-preliminary-check-true-field", visible: false
rescue Capybara::ElementNotFound
choose "support-interface-country-form-requires-preliminary-check-true-field",
visible: false
end

def and_i_click_save
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@

context "when a preliminary check is required" do
let(:application_form) do
create(:application_form, region:, requires_preliminary_check: true)
create(:application_form, :requires_preliminary_check, region:)
end

let!(:preliminary_assessment_section) do
Expand Down
Loading