diff --git a/app/forms/assessor_interface/assessment_section_form.rb b/app/forms/assessor_interface/assessment_section_form.rb index 7625c367ac..ea1bc31f48 100644 --- a/app/forms/assessor_interface/assessment_section_form.rb +++ b/app/forms/assessor_interface/assessment_section_form.rb @@ -35,7 +35,7 @@ def selected_failure_reasons .each_with_object({}) do |failure_reason, memo| next unless send("#{failure_reason}_checked") memo[failure_reason] = { notes: send("#{failure_reason}_notes") } - next unless FailureReasons.chooses_work_history?(failure_reason:) + next unless FailureReasons.chooses_work_history?(failure_reason) memo[failure_reason][ :work_histories ] = work_histories.filter do |work_history| @@ -86,7 +86,7 @@ def self.name klass.validates "#{failure_reason}_checked", inclusion: [true, false] end - if FailureReasons.chooses_work_history?(failure_reason:) + if FailureReasons.chooses_work_history?(failure_reason) klass.attribute "#{failure_reason}_work_history_checked" klass.validates "#{failure_reason}_work_history_checked", @@ -97,7 +97,7 @@ def self.name klass.attribute "#{failure_reason}_notes", :string if assessment_section.preliminary? || - FailureReasons.decline?(failure_reason:) + FailureReasons.decline?(failure_reason) next end klass.validates "#{failure_reason}_notes", @@ -124,7 +124,7 @@ def initial_attributes(assessment_section) selected_failure_reasons_hash.each do |key, notes| attributes["#{key}_checked"] = true attributes["#{key}_notes"] = notes[:assessor_feedback] - if FailureReasons.chooses_work_history?(failure_reason: key) + if FailureReasons.chooses_work_history?(key) attributes["#{key}_work_history_checked"] = notes[:work_history_ids] end end diff --git a/app/lib/failure_reasons.rb b/app/lib/failure_reasons.rb index e1cd127ef0..b20a83581c 100644 --- a/app/lib/failure_reasons.rb +++ b/app/lib/failure_reasons.rb @@ -94,15 +94,19 @@ class FailureReasons WRITTEN_STATEMENT_RECENT => :written_statement, }.freeze - def self.decline?(failure_reason:) + def self.decline?(failure_reason) DECLINABLE.include?(failure_reason.to_s) end - def self.further_information_request_document_type(failure_reason:) + def self.further_information?(failure_reason) + FURTHER_INFORMATIONABLE.include?(failure_reason.to_s) + end + + def self.further_information_request_document_type(failure_reason) DOCUMENT_FAILURE_REASONS[failure_reason.to_s] end - def self.chooses_work_history?(failure_reason:) + def self.chooses_work_history?(failure_reason) WORK_HISTORY_FAILURE_REASONS.include?(failure_reason.to_s) end end diff --git a/app/lib/further_information_request_items_factory.rb b/app/lib/further_information_request_items_factory.rb index 9f545a34fc..5deccfcd98 100644 --- a/app/lib/further_information_request_items_factory.rb +++ b/app/lib/further_information_request_items_factory.rb @@ -35,7 +35,7 @@ def build_further_information_request_item( if ( document_type = FailureReasons.further_information_request_document_type( - failure_reason: failure_reason_key, + failure_reason_key, ) ).present? [ diff --git a/app/view_objects/assessor_interface/assessment_section_view_object.rb b/app/view_objects/assessor_interface/assessment_section_view_object.rb index 9ed0c31dc6..14a4716848 100644 --- a/app/view_objects/assessor_interface/assessment_section_view_object.rb +++ b/app/view_objects/assessor_interface/assessment_section_view_object.rb @@ -152,10 +152,10 @@ def highlighted_work_history_contact_emails def build_key(failure_reason, key_section) key = - if FailureReasons.decline?(failure_reason:) + if FailureReasons.decline?(failure_reason) "decline" elsif FailureReasons.further_information_request_document_type( - failure_reason:, + failure_reason, ).present? "document" else diff --git a/app/view_objects/teacher_interface/application_form_view_object.rb b/app/view_objects/teacher_interface/application_form_view_object.rb index 5f187c671c..bb554e4e35 100644 --- a/app/view_objects/teacher_interface/application_form_view_object.rb +++ b/app/view_objects/teacher_interface/application_form_view_object.rb @@ -255,8 +255,7 @@ def assessment_declined_reasons sorted_reasons = section.selected_failure_reasons.sort_by do |failure_reason| - is_decline = - FailureReasons.decline?(failure_reason: failure_reason.key) + is_decline = FailureReasons.decline?(failure_reason.key) [is_decline ? 0 : 1, failure_reason.key] end @@ -277,8 +276,7 @@ def assessment_declined_reasons if ( assessor_feedback = failure_reason.assessor_feedback - ).present? && - FailureReasons.decline?(failure_reason: failure_reason.key) + ).present? && FailureReasons.decline?(failure_reason.key) { name: title, assessor_note: assessor_feedback } else { name: title } diff --git a/app/views/assessor_interface/assessment_recommendation_decline/edit.html.erb b/app/views/assessor_interface/assessment_recommendation_decline/edit.html.erb index 8685b572f0..c42899a1ed 100644 --- a/app/views/assessor_interface/assessment_recommendation_decline/edit.html.erb +++ b/app/views/assessor_interface/assessment_recommendation_decline/edit.html.erb @@ -40,7 +40,7 @@ <% if (assessor_feedback = failure_reason.assessor_feedback).present? %> - <% if FailureReasons.decline?(failure_reason: failure_reason.key) %> + <% if FailureReasons.decline?(failure_reason.key) %>
Your note to the applicant:
<% else %>Your note (the applicant won’t see this):
diff --git a/app/views/assessor_interface/assessment_sections/_form.html.erb b/app/views/assessor_interface/assessment_sections/_form.html.erb index ac7cbeca6f..c9c770e5f0 100644 --- a/app/views/assessor_interface/assessment_sections/_form.html.erb +++ b/app/views/assessor_interface/assessment_sections/_form.html.erb @@ -70,7 +70,7 @@ label: { text: t(view_object.notes_label_key_for(failure_reason:)), size: "s" }, hint: { text: t(view_object.notes_hint_key_for(failure_reason:)) }, placeholder: t(view_object.notes_placeholder_key_for(failure_reason:)) %> - <% if FailureReasons::chooses_work_history?(failure_reason:) %> + <% if FailureReasons::chooses_work_history?(failure_reason) %> <%= f.govuk_collection_check_boxes :"#{failure_reason}_work_history_checked", view_object.work_histories, :id, :school_name, multiple: false, legend: { size: "s" } %> <% end %> <% end %> diff --git a/config/environments/test.rb b/config/environments/test.rb index cd3d4b475e..dcefb2dbf6 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -23,12 +23,12 @@ } # Show full error reports and enable caching. - config.consider_all_requests_local = false + config.consider_all_requests_local = true config.action_controller.perform_caching = false config.cache_store = :memory_store # Render exception templates instead of raising exceptions. - config.action_dispatch.show_exceptions = :all + config.action_dispatch.show_exceptions = :none # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false diff --git a/lib/tasks/example_data.rake b/lib/tasks/example_data.rake index 826a93c38d..f7cccf57dd 100644 --- a/lib/tasks/example_data.rake +++ b/lib/tasks/example_data.rake @@ -15,12 +15,7 @@ namespace :example_data do Faker::UniqueGenerator.clear staff_members.each do |staff| - FactoryBot.create( - :staff, - :confirmed, - :with_change_email_permission, - **staff, - ) + FactoryBot.create(:staff, :with_change_email_permission, **staff) end create_application_forms @@ -208,7 +203,7 @@ def create_application_forms if application_form.declined_at.present? FactoryBot.create( :selected_failure_reason, - :fi_requestable, + :further_informationable, assessment_section: assessment.sections.first, key: assessment.sections.first.failure_reasons.sample, ) diff --git a/spec/components/application_form_search_result_component_spec.rb b/spec/components/application_form_search_result_component_spec.rb index 3f8fbf93a3..55ab8d5601 100644 --- a/spec/components/application_form_search_result_component_spec.rb +++ b/spec/components/application_form_search_result_component_spec.rb @@ -11,9 +11,9 @@ create( :application_form, :submitted, - :with_reviewer, given_names: "Given", family_name: "Family", + reviewer: create(:staff), ) end let(:current_staff) { create(:staff) } @@ -51,7 +51,7 @@ it { is_expected.to include("Reference") } context "where there is no reviewer assigned" do - before { application_form.update(reviewer: nil) } + before { application_form.update!(reviewer: nil) } it { is_expected.not_to include("Reviewer") } end diff --git a/spec/controllers/assessor_interface/uploads_controller_spec.rb b/spec/controllers/assessor_interface/uploads_controller_spec.rb index 862d5df580..8dbec6d18b 100644 --- a/spec/controllers/assessor_interface/uploads_controller_spec.rb +++ b/spec/controllers/assessor_interface/uploads_controller_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" RSpec.describe AssessorInterface::UploadsController, type: :controller do - let(:staff) { create(:staff, :with_assess_permission, :confirmed) } + let(:staff) { create(:staff, :with_assess_permission) } let(:application_form) { create(:application_form) } before { sign_in staff, scope: :staff } diff --git a/spec/factories/application_forms.rb b/spec/factories/application_forms.rb index a605c0c8c4..747f5c4eed 100644 --- a/spec/factories/application_forms.rb +++ b/spec/factories/application_forms.rb @@ -81,8 +81,9 @@ FactoryBot.define do factory :application_form do sequence(:reference) { |n| n.to_s.rjust(7, "0") } - association :teacher - association :region + + teacher + region needs_work_history { !region.application_form_skip_work_history } needs_written_statement do @@ -102,16 +103,8 @@ requires_preliminary_check { true } end - trait :completed do - personal_information_status { "completed" } - identification_document_status { "completed" } - qualifications_status { "completed" } - age_range_status { "completed" } - subjects_status { "completed" } - english_language_status { "completed" } - work_history_status { "completed" } - registration_number_status { "completed" } - written_statement_status { "completed" } + trait :teaching_authority_provides_written_statement do + teaching_authority_provides_written_statement { true } end trait :action_required_by_admin do @@ -152,6 +145,7 @@ trait :verification_stage do stage { "verification" } + action_required_by_admin end trait :review_stage do @@ -185,7 +179,7 @@ trait :preliminary_check do submitted pre_assessment_stage - requires_preliminary_check { true } + requires_preliminary_check statuses { %w[preliminary_check] } end @@ -242,25 +236,6 @@ end end - trait :with_age_range do - age_range_min { Faker::Number.between(from: 5, to: 11) } - age_range_max { Faker::Number.between(from: age_range_min, to: 18) } - end - - trait :with_subjects do - transient { number_of_subjects { Faker::Number.between(from: 1, to: 3) } } - - subjects do - ([-> { Faker::Educator.subject }] * number_of_subjects).map(&:call) - end - end - - trait :with_identification_document do - after(:create) do |application_form, _evaluator| - create(:upload, document: application_form.identification_document) - end - end - trait :with_personal_information do given_names { Faker::Name.name } family_name { Faker::Name.last_name } @@ -268,29 +243,44 @@ Faker::Date.between(from: 65.years.ago, to: 21.years.ago) end has_alternative_name { false } + personal_information_status { "completed" } + end + + trait :with_identification_document do + identification_document_status { "completed" } + after(:create) do |application_form, _evaluator| + create(:upload, document: application_form.identification_document) + end end trait :with_alternative_name do has_alternative_name { true } alternative_given_names { Faker::Name.name } alternative_family_name { Faker::Name.last_name } - end - - trait :with_name_change_document do after(:create) do |application_form, _evaluator| create(:upload, document: application_form.name_change_document) end end - trait :with_registration_number do - needs_registration_number { true } - registration_number do - Faker::Number.unique.leading_zero_number(digits: 8) + trait :with_age_range do + age_range_min { Faker::Number.between(from: 5, to: 11) } + age_range_max { Faker::Number.between(from: age_range_min, to: 18) } + age_range_status { "completed" } + end + + trait :with_subjects do + transient { number_of_subjects { Faker::Number.between(from: 1, to: 3) } } + + subjects do + ([-> { Faker::Educator.subject }] * number_of_subjects).map(&:call) end + + subjects_status { "completed" } end trait :with_teaching_qualification do teaching_qualification_part_of_degree { true } + qualifications_status { "completed" } after(:create) do |application_form, _evaluator| create( @@ -311,6 +301,7 @@ trait :with_english_language_medium_of_instruction do english_language_proof_method { "medium_of_instruction" } + english_language_status { "completed" } after(:create) do |application_form, _evaluator| create( @@ -323,6 +314,7 @@ trait :with_english_language_proficiency_document do with_english_language_provider + english_language_status { "completed" } after(:create) do |application_form, _evaluator| create( @@ -338,11 +330,13 @@ EnglishLanguageProvider.all.sample || create(:english_language_provider) end english_language_provider_reference { "reference" } + english_language_status { "completed" } end trait :with_english_language_other_provider do english_language_proof_method { "provider" } english_language_provider_other { true } + english_language_status { "completed" } after(:create) do |application_form, _evaluator| create( @@ -354,15 +348,18 @@ trait :with_english_language_exemption_by_citizenship do english_language_citizenship_exempt { true } + english_language_status { "completed" } end trait :with_english_language_exemption_by_qualification do english_language_qualification_exempt { true } + english_language_status { "completed" } end trait :with_work_history do needs_work_history { true } has_work_history { true } + work_history_status { "completed" } after(:create) do |application_form, _evaluator| create(:work_history, :completed, :still_employed, application_form:) @@ -375,12 +372,9 @@ end end - trait :teaching_authority_provides_written_statement do - teaching_authority_provides_written_statement { true } - end - trait :with_written_statement do needs_written_statement { true } + written_statement_status { "completed" } after(:create) do |application_form, _evaluator| if application_form.teaching_authority_provides_written_statement @@ -391,8 +385,12 @@ end end - trait :with_reviewer do - association :reviewer, factory: :staff + trait :with_registration_number do + needs_registration_number { true } + registration_number do + Faker::Number.unique.leading_zero_number(digits: 8) + end + registration_number_status { "completed" } end end end diff --git a/spec/factories/assessment_sections.rb b/spec/factories/assessment_sections.rb index 1886e357c7..17a89281a2 100644 --- a/spec/factories/assessment_sections.rb +++ b/spec/factories/assessment_sections.rb @@ -23,7 +23,7 @@ # FactoryBot.define do factory :assessment_section do - association :assessment + assessment key { AssessmentSection.keys.keys.sample } preliminary { false } @@ -39,7 +39,7 @@ trait :failed do passed { false } selected_failure_reasons do - [build(:selected_failure_reason, :fi_requestable)] + [build(:selected_failure_reason, :further_informationable)] end end diff --git a/spec/factories/consent_requests.rb b/spec/factories/consent_requests.rb index 5c4e0e8d5f..8d8c83eb3e 100644 --- a/spec/factories/consent_requests.rb +++ b/spec/factories/consent_requests.rb @@ -32,8 +32,15 @@ # FactoryBot.define do factory :consent_request do - association :assessment - association :qualification, :completed + assessment + + qualification do + create( + :qualification, + :completed, + application_form: assessment.application_form, + ) + end trait :with_unsigned_upload do after(:create) do |consent_request, _evaluator| @@ -47,20 +54,10 @@ end end - trait :requested do - with_unsigned_upload - requested_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - trait :received do requested with_signed_upload received_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } end - - trait :expired do - requested - expired_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end end end diff --git a/spec/factories/documents.rb b/spec/factories/documents.rb index 2a4a1194e5..31a72609da 100644 --- a/spec/factories/documents.rb +++ b/spec/factories/documents.rb @@ -69,13 +69,6 @@ association :documentable, factory: :application_form end - trait :optional_written_statement do - written_statement - after(:create) do |document, _evaluator| - document.application_form.update!(written_statement_optional: true) - end - end - trait :signed_consent do document_type { "signed_consent" } association :documentable, factory: :qualification_request @@ -90,5 +83,12 @@ document_type { "written_statement" } association :documentable, factory: :application_form end + + trait :optional_written_statement do + written_statement + after(:create) do |document, _evaluator| + document.application_form.update!(written_statement_optional: true) + end + end end end diff --git a/spec/factories/eligibility_checks.rb b/spec/factories/eligibility_checks.rb index a1892666a8..08eebb443a 100644 --- a/spec/factories/eligibility_checks.rb +++ b/spec/factories/eligibility_checks.rb @@ -30,7 +30,7 @@ qualified_for_subject { nil } trait :eligible do - association :region + region country_code { region.country.code } degree { true } free_of_sanctions { true } diff --git a/spec/factories/further_information_request_items.rb b/spec/factories/further_information_request_items.rb index 56426e4998..9e0b9e9e54 100644 --- a/spec/factories/further_information_request_items.rb +++ b/spec/factories/further_information_request_items.rb @@ -28,7 +28,7 @@ # FactoryBot.define do factory :further_information_request_item do - association :further_information_request + further_information_request failure_reason_assessor_feedback { Faker::Lorem.paragraph } @@ -49,7 +49,9 @@ trait :with_work_history_contact_response do information_type { "work_history_contact" } failure_reason_key { "school_details_cannot_be_verified" } - association :work_history, :completed + work_history do + further_information_request.application_form.work_histories.first + end end trait :completed do diff --git a/spec/factories/further_information_requests.rb b/spec/factories/further_information_requests.rb index 31c2ee5304..e47092ecd3 100644 --- a/spec/factories/further_information_requests.rb +++ b/spec/factories/further_information_requests.rb @@ -24,37 +24,7 @@ # FactoryBot.define do factory :further_information_request do - association :assessment - - trait :requested do - requested_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - - trait :received do - requested - received_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - - trait :expired do - requested - expired_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - - trait :reviewed do - received - reviewed_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - - trait :passed do - reviewed - review_passed { true } - end - - trait :failed do - reviewed - review_passed { false } - review_note { "Notes." } - end + assessment trait :with_items do after(:create) do |further_information_request, _evaluator| @@ -67,8 +37,6 @@ :further_information_request_item, :with_work_history_contact_response, further_information_request:, - work_history: - further_information_request.application_form.work_histories.first, ) create( :further_information_request_item, diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb index 89b22f7d61..c93c72c1b1 100644 --- a/spec/factories/notes.rb +++ b/spec/factories/notes.rb @@ -21,7 +21,7 @@ # FactoryBot.define do factory :note do - association :application_form + application_form association :author, factory: :staff text { Faker::Lorem.paragraph } end diff --git a/spec/factories/professional_standing_requests.rb b/spec/factories/professional_standing_requests.rb index cbd2893178..c266bac945 100644 --- a/spec/factories/professional_standing_requests.rb +++ b/spec/factories/professional_standing_requests.rb @@ -29,24 +29,9 @@ # FactoryBot.define do factory :professional_standing_request do - association :assessment + assessment - trait :requested do - requested_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - - trait :received do - requested - receivable - received_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - - trait :expired do - requested - expired_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - - trait :receivable do + trait :with_location_note do location_note { Faker::Lorem.sentence } end end diff --git a/spec/factories/qualification_requests.rb b/spec/factories/qualification_requests.rb index 359524c59a..d7cb9c3063 100644 --- a/spec/factories/qualification_requests.rb +++ b/spec/factories/qualification_requests.rb @@ -32,27 +32,18 @@ # FactoryBot.define do factory :qualification_request do - association :assessment - association :qualification, :completed + assessment - trait :with_consent_method do - consent_method { %i[signed_ecctis signed_institution unsigned].sample } - end - - trait :requested do - requested_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - - trait :received do - received_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - receivable - end - - trait :expired do - expired_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } + qualification do + create( + :qualification, + :completed, + application_form: assessment.application_form, + ) end - trait :receivable do + trait :with_consent_method do + consent_method { %i[signed_ecctis signed_institution unsigned].sample } end end end diff --git a/spec/factories/qualifications.rb b/spec/factories/qualifications.rb index 4de5b3db0d..68a2a08acb 100644 --- a/spec/factories/qualifications.rb +++ b/spec/factories/qualifications.rb @@ -23,7 +23,7 @@ # FactoryBot.define do factory :qualification do - association :application_form + application_form trait :completed do title { Faker::Educator.degree } diff --git a/spec/factories/reference_requests.rb b/spec/factories/reference_requests.rb index 4c2de47a36..8b279f6403 100644 --- a/spec/factories/reference_requests.rb +++ b/spec/factories/reference_requests.rb @@ -52,9 +52,10 @@ # FactoryBot.define do factory :reference_request do + assessment + slug { Faker::Internet.unique.slug } - association :assessment work_history do create( :work_history, @@ -63,54 +64,7 @@ ) end - trait :requested do - requested_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - - trait :received do - requested - receivable - received_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - - trait :expired do - requested - expired_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - - trait :reviewed do - received - reviewed_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - - trait :review_passed do - reviewed - review_passed { true } - end - - trait :review_failed do - reviewed - review_passed { false } - review_note { "Notes." } - end - - trait :verified do - received - verified_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } - end - - trait :verify_passed do - verified - verify_passed { true } - end - - trait :verify_failed do - verified - verify_passed { false } - verify_note { "Notes." } - end - - trait :receivable do + trait :with_responses do contact_response { Faker::Boolean.boolean } contact_name { contact_response ? "" : Faker::Name.name } contact_job { contact_response ? "" : Faker::Job.title } @@ -140,27 +94,6 @@ additional_information_response { Faker::Lorem.sentence } end - trait :responses_invalid do - contact_response { false } - contact_name { Faker::Name.name } - contact_job { Faker::Job.title } - contact_comment { Faker::Lorem.sentence } - dates_response { false } - dates_comment { Faker::Lorem.sentence } - hours_response { false } - hours_comment { Faker::Lorem.sentence } - children_response { false } - children_comment { Faker::Lorem.sentence } - lessons_response { false } - lessons_comment { Faker::Lorem.sentence } - reports_response { false } - reports_comment { Faker::Lorem.sentence } - misconduct_response { true } - misconduct_comment { Faker::Lorem.sentence } - satisfied_response { false } - satisfied_comment { Faker::Lorem.sentence } - end - trait :responses_valid do contact_response { true } dates_response { true } @@ -171,5 +104,11 @@ misconduct_response { false } satisfied_response { true } end + + trait :received do + requested + with_responses + received_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } + end end end diff --git a/spec/factories/regions.rb b/spec/factories/regions.rb index 2198c567bf..b4cd423c3b 100644 --- a/spec/factories/regions.rb +++ b/spec/factories/regions.rb @@ -37,7 +37,7 @@ # FactoryBot.define do factory :region do - association :country + country sequence(:name) { |n| "Region #{n}" } diff --git a/spec/factories/requestable.rb b/spec/factories/requestable.rb new file mode 100644 index 0000000000..26cc341582 --- /dev/null +++ b/spec/factories/requestable.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +FactoryBot.define do + trait :requested do + requested_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } + end + + trait :received do + requested + received_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } + end + + trait :expired do + requested + expired_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } + end + + trait :reviewed do + received + reviewed_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } + end + + trait :review_passed do + reviewed + review_passed { true } + end + + trait :review_failed do + reviewed + review_passed { false } + review_note { "Notes." } + end + + trait :verified do + received + verified_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } + end + + trait :verify_passed do + verified + verify_passed { true } + end + + trait :verify_failed do + verified + verify_passed { false } + verify_note { "Notes." } + end +end diff --git a/spec/factories/selected_failure_reasons.rb b/spec/factories/selected_failure_reasons.rb index b67dbca11e..e1358e10fa 100644 --- a/spec/factories/selected_failure_reasons.rb +++ b/spec/factories/selected_failure_reasons.rb @@ -19,12 +19,19 @@ # FactoryBot.define do factory :selected_failure_reason do - association :assessment_section + assessment_section key { FailureReasons::ALL.sample } - trait :fi_requestable do + assessor_feedback do + if FailureReasons.further_information?(key) + "We need more information." + else + "" + end + end + + trait :further_informationable do key { FailureReasons::FURTHER_INFORMATIONABLE.sample } - assessor_feedback { "We need more things please" } end trait :declinable do diff --git a/spec/factories/staff.rb b/spec/factories/staff.rb index 96a915d977..141e09a9d3 100644 --- a/spec/factories/staff.rb +++ b/spec/factories/staff.rb @@ -56,10 +56,7 @@ sequence(:email) { |n| "test#{n}@example.org" } password { "example123" } name { Faker::Name.name } - - trait :confirmed do - confirmed_at { Time.zone.now } - end + confirmed_at { Time.zone.now } trait :with_assess_permission do assess_permission { true } diff --git a/spec/factories/teachers.rb b/spec/factories/teachers.rb index d76882ba19..12d8d41040 100644 --- a/spec/factories/teachers.rb +++ b/spec/factories/teachers.rb @@ -25,8 +25,9 @@ # FactoryBot.define do factory :teacher do - sequence(:email) { |n| "teacher#{n}@example.org" } uuid { SecureRandom.uuid } + + sequence(:email) { |n| "teacher#{n}@example.org" } canonical_email { EmailAddress.canonical(email) } email_domain { EmailAddress.new(email).host_name } diff --git a/spec/factories/timeline_events.rb b/spec/factories/timeline_events.rb index f3394c46db..dc5345fb6c 100644 --- a/spec/factories/timeline_events.rb +++ b/spec/factories/timeline_events.rb @@ -51,7 +51,7 @@ # FactoryBot.define do factory :timeline_event do - association :application_form + application_form association :creator, factory: :staff @@ -89,7 +89,7 @@ trait :information_changed do event_type { "information_changed" } - association :work_history + work_history column_name { "contact_email" } old_value { Faker::Internet.email } new_value { Faker::Internet.email } @@ -97,7 +97,7 @@ trait :note_created do event_type { "note_created" } - association :note + note end trait :requestable_reviewed do diff --git a/spec/factories/uploads.rb b/spec/factories/uploads.rb index 854b954bb5..97c287c8c1 100644 --- a/spec/factories/uploads.rb +++ b/spec/factories/uploads.rb @@ -30,13 +30,13 @@ translation { false } trait :translation do - translation { true } attachment do Rack::Test::UploadedFile.new( "spec/fixtures/files/translation_upload.pdf", "application/pdf", ) end + translation { true } end trait :clean do diff --git a/spec/factories/work_histories.rb b/spec/factories/work_histories.rb index 1153b8cb20..c18e515965 100644 --- a/spec/factories/work_histories.rb +++ b/spec/factories/work_histories.rb @@ -33,7 +33,7 @@ # FactoryBot.define do factory :work_history do - association :application_form + application_form canonical_contact_email { EmailAddress.canonical(contact_email) } contact_email_domain { EmailAddress.new(contact_email).host_name } diff --git a/spec/forms/assessor_interface/assessment_section_form_spec.rb b/spec/forms/assessor_interface/assessment_section_form_spec.rb index d7189ecb10..4f6278af6c 100644 --- a/spec/forms/assessor_interface/assessment_section_form_spec.rb +++ b/spec/forms/assessor_interface/assessment_section_form_spec.rb @@ -24,7 +24,7 @@ FailureReasons::WORK_HISTORY_FAILURE_REASONS.sample.to_sym end let(:decline_failure_reason) { FailureReasons::DECLINABLE.sample.to_sym } - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } let(:attributes) { {} } subject(:form) do diff --git a/spec/forms/assessor_interface/assessor_assignment_form_spec.rb b/spec/forms/assessor_interface/assessor_assignment_form_spec.rb index f5cc841309..0f0c584186 100644 --- a/spec/forms/assessor_interface/assessor_assignment_form_spec.rb +++ b/spec/forms/assessor_interface/assessor_assignment_form_spec.rb @@ -4,8 +4,8 @@ let!(:application_form) do create(:application_form, :with_personal_information, :submitted) end - let(:staff) { create(:staff, :confirmed) } - let(:assessor_id) { create(:staff, :confirmed).id } + let(:staff) { create(:staff) } + let(:assessor_id) { create(:staff).id } subject(:form) do described_class.new(application_form:, staff:, assessor_id:) diff --git a/spec/forms/assessor_interface/check_age_range_subjects_form_spec.rb b/spec/forms/assessor_interface/check_age_range_subjects_form_spec.rb index b84d0033ef..14d6a3bf3c 100644 --- a/spec/forms/assessor_interface/check_age_range_subjects_form_spec.rb +++ b/spec/forms/assessor_interface/check_age_range_subjects_form_spec.rb @@ -4,7 +4,7 @@ RSpec.describe AssessorInterface::CheckAgeRangeSubjectsForm, type: :model do let(:assessment_section) { create(:assessment_section, :age_range_subjects) } - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } let(:attributes) { {} } let(:age_range_subjects_attributes) { {} } diff --git a/spec/forms/assessor_interface/confirm_age_range_subjects_form_spec.rb b/spec/forms/assessor_interface/confirm_age_range_subjects_form_spec.rb index 8344ba9c1e..e256594e05 100644 --- a/spec/forms/assessor_interface/confirm_age_range_subjects_form_spec.rb +++ b/spec/forms/assessor_interface/confirm_age_range_subjects_form_spec.rb @@ -4,7 +4,7 @@ RSpec.describe AssessorInterface::ConfirmAgeRangeSubjectsForm, type: :model do let(:assessment) { create(:assessment) } - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } let(:age_range_subjects_attributes) { {} } subject(:form) do diff --git a/spec/forms/assessor_interface/create_note_form_spec.rb b/spec/forms/assessor_interface/create_note_form_spec.rb index 354c19146b..407fc1ade3 100644 --- a/spec/forms/assessor_interface/create_note_form_spec.rb +++ b/spec/forms/assessor_interface/create_note_form_spec.rb @@ -2,7 +2,7 @@ RSpec.describe AssessorInterface::CreateNoteForm, type: :model do let(:application_form) { create(:application_form) } - let(:author) { create(:staff, :confirmed) } + let(:author) { create(:staff) } let(:text) { "A note." } subject { described_class.new(application_form:, author:, text:) } diff --git a/spec/forms/assessor_interface/induction_required_form_spec.rb b/spec/forms/assessor_interface/induction_required_form_spec.rb index b4cc738b6c..9b556db2c1 100644 --- a/spec/forms/assessor_interface/induction_required_form_spec.rb +++ b/spec/forms/assessor_interface/induction_required_form_spec.rb @@ -6,7 +6,7 @@ let(:assessment_section) do create(:assessment_section, :professional_standing) end - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } let(:attributes) { {} } subject(:form) do diff --git a/spec/forms/assessor_interface/personal_information_form_spec.rb b/spec/forms/assessor_interface/personal_information_form_spec.rb index 6b15dfc5f5..776772f59a 100644 --- a/spec/forms/assessor_interface/personal_information_form_spec.rb +++ b/spec/forms/assessor_interface/personal_information_form_spec.rb @@ -6,7 +6,7 @@ let(:assessment_section) do create(:assessment_section, :personal_information) end - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } let(:attributes) { {} } subject(:form) do diff --git a/spec/forms/assessor_interface/qualification_form_spec.rb b/spec/forms/assessor_interface/qualification_form_spec.rb index 64212c1ff4..a037dabf1c 100644 --- a/spec/forms/assessor_interface/qualification_form_spec.rb +++ b/spec/forms/assessor_interface/qualification_form_spec.rb @@ -4,7 +4,7 @@ RSpec.describe AssessorInterface::QualificationsForm, type: :model do let(:assessment_section) { create(:assessment_section, :qualifications) } - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } let(:attributes) { {} } subject(:form) do diff --git a/spec/forms/assessor_interface/requestable_verify_passed_form_spec.rb b/spec/forms/assessor_interface/requestable_verify_passed_form_spec.rb index 51a0b25765..114d1ecfda 100644 --- a/spec/forms/assessor_interface/requestable_verify_passed_form_spec.rb +++ b/spec/forms/assessor_interface/requestable_verify_passed_form_spec.rb @@ -4,7 +4,12 @@ RSpec.describe AssessorInterface::RequestableVerifyPassedForm, type: :model do let(:requestable) do - create(:reference_request, :requested, :receivable, verify_note: "Old note") + create( + :reference_request, + :requested, + :with_responses, + verify_note: "Old note", + ) end let(:user) { create(:staff) } let(:passed) { nil } diff --git a/spec/forms/assessor_interface/reviewer_assignment_form_spec.rb b/spec/forms/assessor_interface/reviewer_assignment_form_spec.rb index 388a2dbe12..0df6ac389c 100644 --- a/spec/forms/assessor_interface/reviewer_assignment_form_spec.rb +++ b/spec/forms/assessor_interface/reviewer_assignment_form_spec.rb @@ -4,8 +4,8 @@ let!(:application_form) do create(:application_form, :with_personal_information, :submitted) end - let(:staff) { create(:staff, :confirmed) } - let(:reviewer_id) { create(:staff, :confirmed).id } + let(:staff) { create(:staff) } + let(:reviewer_id) { create(:staff).id } subject(:form) do described_class.new(application_form:, staff:, reviewer_id:) diff --git a/spec/forms/assessor_interface/scotland_full_registration_form_spec.rb b/spec/forms/assessor_interface/scotland_full_registration_form_spec.rb index 89a428da20..13afcb313b 100644 --- a/spec/forms/assessor_interface/scotland_full_registration_form_spec.rb +++ b/spec/forms/assessor_interface/scotland_full_registration_form_spec.rb @@ -6,7 +6,7 @@ let(:assessment_section) do create(:assessment_section, :professional_standing) end - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } let(:attributes) { {} } subject(:form) do diff --git a/spec/jobs/expire_requestables_spec.rb b/spec/jobs/expire_requestables_spec.rb index cf7c9e0d1c..e6e4860b56 100644 --- a/spec/jobs/expire_requestables_spec.rb +++ b/spec/jobs/expire_requestables_spec.rb @@ -31,6 +31,12 @@ end end + context "with consent requests" do + it_behaves_like "a job which expires requestables", + "ConsentRequest", + :consent_request + end + context "with further information requests" do it_behaves_like "a job which expires requestables", "FurtherInformationRequest", @@ -43,6 +49,12 @@ :professional_standing_request end + context "with qualification requests" do + it_behaves_like "a job which expires requestables", + "QualificationRequest", + :qualification_request + end + context "with reference requests" do it_behaves_like "a job which expires requestables", "ReferenceRequest", diff --git a/spec/lib/application_form_section_status_updater_spec.rb b/spec/lib/application_form_section_status_updater_spec.rb index c1d6475c1c..d3cdb393a3 100644 --- a/spec/lib/application_form_section_status_updater_spec.rb +++ b/spec/lib/application_form_section_status_updater_spec.rb @@ -36,7 +36,6 @@ :application_form, :with_personal_information, :with_alternative_name, - :with_name_change_document, ) end it { is_expected.to eq("completed") } diff --git a/spec/lib/country_name_spec.rb b/spec/lib/country_name_spec.rb index bc32e971e9..a502b60b86 100644 --- a/spec/lib/country_name_spec.rb +++ b/spec/lib/country_name_spec.rb @@ -1,6 +1,8 @@ require "rails_helper" RSpec.describe CountryName do + let(:country) { create(:country, code: "US") } + describe "#from_code" do subject(:name) { described_class.from_code(code, with_definite_article:) } @@ -21,7 +23,6 @@ described_class.from_country(country, with_definite_article:) end - let(:country) { create(:country, code: "US") } let(:with_definite_article) { false } it { is_expected.to eq("United States") } @@ -38,9 +39,7 @@ described_class.from_region(region, with_definite_article:) end - let(:region) do - create(:region, :national, country: create(:country, code: "US")) - end + let(:region) { create(:region, :national, country:) } let(:with_definite_article) { false } it { is_expected.to eq("United States") } @@ -79,21 +78,14 @@ context "with a national region" do before do - eligibility_check.update!( - region: - create(:region, :national, country: create(:country, code: "US")), - ) + eligibility_check.update!(region: create(:region, :national, country:)) end it { is_expected.to eq("United States") } end context "with a named region" do - before do - eligibility_check.update!( - region: create(:region, country: create(:country, code: "US")), - ) - end + before { eligibility_check.update!(region: create(:region, country:)) } it { is_expected.to eq("United States") } end diff --git a/spec/lib/dqt/trn_request_params_spec.rb b/spec/lib/dqt/trn_request_params_spec.rb index 6fd309c5c8..c219abd363 100644 --- a/spec/lib/dqt/trn_request_params_spec.rb +++ b/spec/lib/dqt/trn_request_params_spec.rb @@ -13,7 +13,7 @@ teacher:, created_at: Date.new(2020, 1, 1), submitted_at: Date.new(2020, 1, 1), - region: create(:region, country: create(:country, code: "AU")), + region: create(:region, :in_country, country_code: "AU"), date_of_birth: Date.new(1960, 1, 1), given_names: "Given", family_name: "Family", diff --git a/spec/lib/filters/country_spec.rb b/spec/lib/filters/country_spec.rb index 4316ed35f8..9af9ea52df 100644 --- a/spec/lib/filters/country_spec.rb +++ b/spec/lib/filters/country_spec.rb @@ -12,13 +12,13 @@ let!(:included) do create( :application_form, - region: create(:region, country: create(:country, code: "US")), + region: create(:region, :in_country, country_code: "US"), ) end let!(:filtered) do create( :application_form, - region: create(:region, country: create(:country, code: "FR")), + region: create(:region, :in_country, country_code: "FR"), ) end diff --git a/spec/models/assessment_section_spec.rb b/spec/models/assessment_section_spec.rb index 84cb346f8a..ec5b14276c 100644 --- a/spec/models/assessment_section_spec.rb +++ b/spec/models/assessment_section_spec.rb @@ -99,7 +99,11 @@ context "with no decline failure reasons" do before do - create(:selected_failure_reason, :fi_requestable, assessment_section:) + create( + :selected_failure_reason, + :further_informationable, + assessment_section:, + ) end it { is_expected.to be false } diff --git a/spec/models/assessment_spec.rb b/spec/models/assessment_spec.rb index 6f3230306c..cceddd6d9f 100644 --- a/spec/models/assessment_spec.rb +++ b/spec/models/assessment_spec.rb @@ -109,14 +109,14 @@ context "with a passed further information request" do before do - create(:further_information_request, :passed, assessment:) + create(:further_information_request, :review_passed, assessment:) end it { is_expected.to be true } end context "with a failed further information request" do before do - create(:further_information_request, :failed, assessment:) + create(:further_information_request, :review_failed, assessment:) end it { is_expected.to be false } end @@ -155,7 +155,13 @@ hours_per_week: 30, ) - create(:reference_request, :verify_passed, assessment:, work_history:) + create( + :reference_request, + :received, + :verify_passed, + assessment:, + work_history:, + ) end it { is_expected.to be true } @@ -176,6 +182,7 @@ create( :reference_request, + :received, :verify_failed, :review_passed, assessment:, @@ -265,7 +272,7 @@ :failed, assessment:, ) - create(:further_information_request, :passed, assessment:) + create(:further_information_request, :review_passed, assessment:) end it { is_expected.to be false } end @@ -278,7 +285,7 @@ :failed, assessment:, ) - create(:further_information_request, :failed, assessment:) + create(:further_information_request, :review_failed, assessment:) end it { is_expected.to be true } end @@ -394,14 +401,14 @@ context "with a passed further information request" do before do - create(:further_information_request, :passed, assessment:) + create(:further_information_request, :review_passed, assessment:) end it { is_expected.to be true } end context "with a failed further information request" do before do - create(:further_information_request, :failed, assessment:) + create(:further_information_request, :review_failed, assessment:) end it { is_expected.to be false } end diff --git a/spec/models/further_information_request_spec.rb b/spec/models/further_information_request_spec.rb index 91bae837e3..7acd0ab86b 100644 --- a/spec/models/further_information_request_spec.rb +++ b/spec/models/further_information_request_spec.rb @@ -27,8 +27,6 @@ RSpec.describe FurtherInformationRequest do subject(:further_information_request) { create(:further_information_request) } - it_behaves_like "an expirable" - it_behaves_like "a remindable" do subject { create(:further_information_request, :requested) } end diff --git a/spec/models/professional_standing_request_spec.rb b/spec/models/professional_standing_request_spec.rb index 10993cc6cf..01dc188de8 100644 --- a/spec/models/professional_standing_request_spec.rb +++ b/spec/models/professional_standing_request_spec.rb @@ -31,7 +31,7 @@ RSpec.describe ProfessionalStandingRequest, type: :model do it_behaves_like "a requestable" do - subject { create(:professional_standing_request, :receivable) } + subject { create(:professional_standing_request, :with_location_note) } end describe "#expires_after" do diff --git a/spec/models/qualification_request_spec.rb b/spec/models/qualification_request_spec.rb index 366cb11e1d..2f1a7f7e7a 100644 --- a/spec/models/qualification_request_spec.rb +++ b/spec/models/qualification_request_spec.rb @@ -35,9 +35,7 @@ RSpec.describe QualificationRequest, type: :model do subject(:qualification_request) { create(:qualification_request) } - it_behaves_like "a requestable" do - subject { create(:qualification_request, :receivable) } - end + it_behaves_like "a requestable" describe "columns" do it do diff --git a/spec/models/reference_request_spec.rb b/spec/models/reference_request_spec.rb index 003eec342a..acd2783c17 100644 --- a/spec/models/reference_request_spec.rb +++ b/spec/models/reference_request_spec.rb @@ -55,14 +55,12 @@ RSpec.describe ReferenceRequest do subject(:reference_request) { create(:reference_request) } - it_behaves_like "an expirable" - it_behaves_like "a remindable" do subject { create(:reference_request, :requested) } end it_behaves_like "a requestable" do - subject { create(:reference_request, :receivable) } + subject { create(:reference_request, :with_responses) } end it { is_expected.to have_secure_token(:slug) } @@ -126,20 +124,13 @@ describe "#responses_given?" do subject(:responses_given?) { reference_request.responses_given? } - context "when requested" do - let(:reference_request) { build(:reference_request, :requested) } + context "when no responses given" do + let(:reference_request) { build(:reference_request) } it { is_expected.to be false } end - context "when requested and all responses given" do - let(:reference_request) do - build(:reference_request, :requested, :receivable) - end - it { is_expected.to be true } - end - - context "when received" do - let(:reference_request) { build(:reference_request, :received) } + context "when all responses given" do + let(:reference_request) { build(:reference_request, :with_responses) } it { is_expected.to be true } end end diff --git a/spec/models/selected_failure_reason_spec.rb b/spec/models/selected_failure_reason_spec.rb index b1dbe22cd8..227bcab64c 100644 --- a/spec/models/selected_failure_reason_spec.rb +++ b/spec/models/selected_failure_reason_spec.rb @@ -44,7 +44,7 @@ context "where a record has a key that isn't declinable" do let(:selected_failure_reason) do - create(:selected_failure_reason, :fi_requestable) + create(:selected_failure_reason, :further_informationable) end it "is not returned" do diff --git a/spec/services/award_qts_spec.rb b/spec/services/award_qts_spec.rb index 96f89bcaea..4458939f6c 100644 --- a/spec/services/award_qts_spec.rb +++ b/spec/services/award_qts_spec.rb @@ -4,7 +4,7 @@ RSpec.describe AwardQTS do let(:teacher) { create(:teacher) } - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } let(:trn) { "abcdef" } let(:access_your_teaching_qualifications_url) { "https://aytq.com" } diff --git a/spec/services/backfill_preliminary_checks_spec.rb b/spec/services/backfill_preliminary_checks_spec.rb index 150af46302..1821e0d9f0 100644 --- a/spec/services/backfill_preliminary_checks_spec.rb +++ b/spec/services/backfill_preliminary_checks_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" RSpec.describe BackfillPreliminaryChecks do - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } subject(:call) { described_class.call(user:) } diff --git a/spec/services/create_further_information_request_spec.rb b/spec/services/create_further_information_request_spec.rb index 3b99c6dbb8..f3a538e455 100644 --- a/spec/services/create_further_information_request_spec.rb +++ b/spec/services/create_further_information_request_spec.rb @@ -5,7 +5,7 @@ RSpec.describe CreateFurtherInformationRequest do let(:application_form) { create(:application_form, :submitted) } let(:assessment) { create(:assessment, application_form:) } - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } subject(:call) { described_class.call(assessment:, user:) } diff --git a/spec/services/create_note_spec.rb b/spec/services/create_note_spec.rb index 2cdd91b4ec..dd7058d735 100644 --- a/spec/services/create_note_spec.rb +++ b/spec/services/create_note_spec.rb @@ -4,7 +4,7 @@ RSpec.describe CreateNote do let(:application_form) { create(:application_form, :submitted) } - let(:author) { create(:staff, :confirmed) } + let(:author) { create(:staff) } let(:text) { "Note text." } subject(:call) { described_class.call(application_form:, author:, text:) } diff --git a/spec/services/decline_qts_spec.rb b/spec/services/decline_qts_spec.rb index d14fc268fe..4a835934b8 100644 --- a/spec/services/decline_qts_spec.rb +++ b/spec/services/decline_qts_spec.rb @@ -4,7 +4,7 @@ RSpec.describe DeclineQTS do let(:teacher) { create(:teacher) } - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } subject(:call) { described_class.call(application_form:, user:) } diff --git a/spec/services/receive_requestable_spec.rb b/spec/services/receive_requestable_spec.rb index 37f419fc98..2f859b8242 100644 --- a/spec/services/receive_requestable_spec.rb +++ b/spec/services/receive_requestable_spec.rb @@ -8,7 +8,6 @@ create( :qualification_request, :requested, - :receivable, assessment: create(:assessment, application_form:), ) end diff --git a/spec/services/unreceive_requestable_spec.rb b/spec/services/unreceive_requestable_spec.rb index 425918a1a4..5764bdbacc 100644 --- a/spec/services/unreceive_requestable_spec.rb +++ b/spec/services/unreceive_requestable_spec.rb @@ -10,7 +10,6 @@ create( :qualification_request, :received, - :receivable, assessment: create(:assessment, application_form:), ) end @@ -40,7 +39,7 @@ it "changes the application form status" do expect { call }.to change { application_form.reload.statuses }.to( - %w[assessment_not_started], + %w[waiting_on_ecctis], ) end diff --git a/spec/services/update_application_form_name_spec.rb b/spec/services/update_application_form_name_spec.rb index 586ad99ada..b36098dca8 100644 --- a/spec/services/update_application_form_name_spec.rb +++ b/spec/services/update_application_form_name_spec.rb @@ -6,7 +6,7 @@ let(:application_form) do create(:application_form, :submitted, :with_personal_information) end - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } let(:new_given_names) { "New given names" } let(:new_family_name) { "New family name" } diff --git a/spec/services/update_assessment_induction_required_spec.rb b/spec/services/update_assessment_induction_required_spec.rb index 4d2e68f0d6..88461a11f2 100644 --- a/spec/services/update_assessment_induction_required_spec.rb +++ b/spec/services/update_assessment_induction_required_spec.rb @@ -56,7 +56,13 @@ end_date: Date.new(2021, 12, 1), hours_per_week: 30, ) - create(:reference_request, :verify_passed, assessment:, work_history:) + create( + :reference_request, + :received, + :verify_passed, + assessment:, + work_history:, + ) end include_examples "induction not required" diff --git a/spec/services/update_work_history_contact_spec.rb b/spec/services/update_work_history_contact_spec.rb index f2aedda4bf..5f3e9758d7 100644 --- a/spec/services/update_work_history_contact_spec.rb +++ b/spec/services/update_work_history_contact_spec.rb @@ -4,7 +4,7 @@ RSpec.describe UpdateWorkHistoryContact do let(:work_history) { create(:work_history, :completed) } - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } let(:new_name) { "New name" } let(:new_job) { "New job" } let(:new_email) { "new@example.com" } diff --git a/spec/services/verify_assessment_spec.rb b/spec/services/verify_assessment_spec.rb index 2e91c87144..f38345f194 100644 --- a/spec/services/verify_assessment_spec.rb +++ b/spec/services/verify_assessment_spec.rb @@ -5,7 +5,7 @@ RSpec.describe VerifyAssessment do let(:application_form) { create(:application_form, :submitted) } let(:assessment) { create(:assessment, application_form:) } - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } let(:professional_standing) { true } let(:qualification) { create(:qualification, :completed, application_form:) } let(:qualifications_assessor_note) { "A note." } diff --git a/spec/services/withdraw_application_form_spec.rb b/spec/services/withdraw_application_form_spec.rb index 29158fa010..906ae7e79a 100644 --- a/spec/services/withdraw_application_form_spec.rb +++ b/spec/services/withdraw_application_form_spec.rb @@ -4,7 +4,7 @@ RSpec.describe WithdrawApplicationForm do let(:application_form) { create(:application_form, :submitted) } - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } subject(:call) { described_class.call(application_form:, user:) } diff --git a/spec/support/shared_examples/policy.rb b/spec/support/shared_examples/policy.rb index b0b25b334d..8bcc1b58d0 100644 --- a/spec/support/shared_examples/policy.rb +++ b/spec/support/shared_examples/policy.rb @@ -10,7 +10,7 @@ end context "with a user" do - let(:user) { create(:staff, :confirmed) } + let(:user) { create(:staff) } it { is_expected.to_not be_nil } end end diff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rb index 5c97780ec0..5760ab7556 100644 --- a/spec/support/system_helpers.rb +++ b/spec/support/system_helpers.rb @@ -56,35 +56,17 @@ def given_i_am_authorized_as_a_user(user) end def given_i_am_authorized_as_a_support_user - user = - create( - :staff, - :confirmed, - :with_support_console_permission, - name: "Admin", - ) + user = create(:staff, :with_support_console_permission, name: "Admin") given_i_am_authorized_as_a_user(user) end def given_i_am_authorized_as_an_assessor_user - user = - create( - :staff, - :confirmed, - :with_assess_permission, - name: "Authorized User", - ) + user = create(:staff, :with_assess_permission, name: "Authorized User") given_i_am_authorized_as_a_user(user) end def given_i_am_authorized_as_an_admin_user - user = - create( - :staff, - :confirmed, - :with_verify_permission, - name: "Authorized User", - ) + user = create(:staff, :with_verify_permission, name: "Authorized User") given_i_am_authorized_as_a_user(user) end diff --git a/spec/system/assessor_interface/authentication_spec.rb b/spec/system/assessor_interface/authentication_spec.rb index 97caf75dfa..386b499223 100644 --- a/spec/system/assessor_interface/authentication_spec.rb +++ b/spec/system/assessor_interface/authentication_spec.rb @@ -19,7 +19,7 @@ private def given_staff_exist - create(:staff, :confirmed, email: "staff@example.com", password: "password") + create(:staff, email: "staff@example.com", password: "password") end def when_i_login diff --git a/spec/system/assessor_interface/change_application_form_email_spec.rb b/spec/system/assessor_interface/change_application_form_email_spec.rb index 0dd04fedb0..5597832fdd 100644 --- a/spec/system/assessor_interface/change_application_form_email_spec.rb +++ b/spec/system/assessor_interface/change_application_form_email_spec.rb @@ -57,10 +57,10 @@ def application_form delegate :reference, to: :application_form def assessor - create(:staff, :confirmed, :with_assess_permission) + create(:staff, :with_assess_permission) end def manager - create(:staff, :confirmed, :with_change_email_permission) + create(:staff, :with_change_email_permission) end end diff --git a/spec/system/assessor_interface/change_application_form_name_spec.rb b/spec/system/assessor_interface/change_application_form_name_spec.rb index 90b7cc08dc..d916d831cb 100644 --- a/spec/system/assessor_interface/change_application_form_name_spec.rb +++ b/spec/system/assessor_interface/change_application_form_name_spec.rb @@ -59,10 +59,10 @@ def application_form delegate :reference, to: :application_form def assessor - create(:staff, :confirmed, :with_assess_permission) + create(:staff, :with_assess_permission) end def manager - create(:staff, :confirmed, :with_change_name_permission) + create(:staff, :with_change_name_permission) end end diff --git a/spec/system/assessor_interface/change_work_history_spec.rb b/spec/system/assessor_interface/change_work_history_spec.rb index 520ff46569..db39847d01 100644 --- a/spec/system/assessor_interface/change_work_history_spec.rb +++ b/spec/system/assessor_interface/change_work_history_spec.rb @@ -124,10 +124,10 @@ def reference_request end def assessor - create(:staff, :confirmed, :with_assess_permission) + create(:staff, :with_assess_permission) end def manager - create(:staff, :confirmed, :with_change_work_history_permission) + create(:staff, :with_change_work_history_permission) end end diff --git a/spec/system/assessor_interface/completing_assessment_spec.rb b/spec/system/assessor_interface/completing_assessment_spec.rb index 863c33e1f4..7b93531361 100644 --- a/spec/system/assessor_interface/completing_assessment_spec.rb +++ b/spec/system/assessor_interface/completing_assessment_spec.rb @@ -9,7 +9,7 @@ end let(:notify_template_preview) { double(html: "I am an email") } let(:assessor_user) do - create(:staff, :with_assess_permission, :confirmed, name: "Authorized User") + create(:staff, :with_assess_permission, name: "Authorized User") end around do |example| diff --git a/spec/system/assessor_interface/filtering_application_forms_spec.rb b/spec/system/assessor_interface/filtering_application_forms_spec.rb index a9e606d5b6..c4caa3e27c 100644 --- a/spec/system/assessor_interface/filtering_application_forms_spec.rb +++ b/spec/system/assessor_interface/filtering_application_forms_spec.rb @@ -207,7 +207,7 @@ def application_forms create( :application_form, :submitted, - region: create(:region, country: create(:country, code: "US")), + region: create(:region, :in_country, country_code: "US"), given_names: "Cher", family_name: "Bert", assessor: assessors.second, @@ -218,7 +218,7 @@ def application_forms :application_form, :submitted, :action_required_by_admin, - region: create(:region, country: create(:country, code: "FR")), + region: create(:region, :in_country, country_code: "FR"), given_names: "Emma", family_name: "Dubois", assessor: assessors.second, @@ -229,7 +229,7 @@ def application_forms :application_form, :submitted, :action_required_by_assessor, - region: create(:region, country: create(:country, code: "ES")), + region: create(:region, :in_country, country_code: "ES"), given_names: "Arnold", family_name: "Drummond", assessor: assessors.first, @@ -239,7 +239,7 @@ def application_forms :application_form, :awarded, awarded_at: 2.days.ago, - region: create(:region, country: create(:country, code: "PT")), + region: create(:region, :in_country, country_code: "PT"), given_names: "John", family_name: "Smith", assessor: assessors.second, @@ -249,7 +249,7 @@ def application_forms :application_form, :awarded, awarded_at: 6.months.ago, - region: create(:region, country: create(:country, code: "DE")), + region: create(:region, :in_country, country_code: "DE"), given_names: "Nick", family_name: "Johnson", assessor: assessors.second, diff --git a/spec/system/assessor_interface/reverse_decision_spec.rb b/spec/system/assessor_interface/reverse_decision_spec.rb index b28f9e9d4a..65d374cd07 100644 --- a/spec/system/assessor_interface/reverse_decision_spec.rb +++ b/spec/system/assessor_interface/reverse_decision_spec.rb @@ -63,10 +63,10 @@ def assessment delegate :id, to: :assessment, prefix: true def assessor - create(:staff, :confirmed, :with_assess_permission) + create(:staff, :with_assess_permission) end def manager - create(:staff, :confirmed, :with_reverse_decision_permission) + create(:staff, :with_reverse_decision_permission) end end diff --git a/spec/system/assessor_interface/view_timeline_events_spec.rb b/spec/system/assessor_interface/view_timeline_events_spec.rb index c06de41c54..b5c7d4e86c 100644 --- a/spec/system/assessor_interface/view_timeline_events_spec.rb +++ b/spec/system/assessor_interface/view_timeline_events_spec.rb @@ -62,6 +62,6 @@ def application_form delegate :reference, to: :application_form def assessor - @assessor ||= create(:staff, :confirmed) + @assessor ||= create(:staff) end end diff --git a/spec/system/assessor_interface/withdraw_application_spec.rb b/spec/system/assessor_interface/withdraw_application_spec.rb index 5206d2fdae..a6a1b1abe0 100644 --- a/spec/system/assessor_interface/withdraw_application_spec.rb +++ b/spec/system/assessor_interface/withdraw_application_spec.rb @@ -61,10 +61,10 @@ def assessment delegate :id, to: :assessment, prefix: true def assessor - create(:staff, :confirmed, :with_assess_permission) + create(:staff, :with_assess_permission) end def manager - create(:staff, :confirmed, :with_withdraw_permission) + create(:staff, :with_withdraw_permission) end end diff --git a/spec/system/personas_spec.rb b/spec/system/personas_spec.rb index 94dbe5ba49..7a52edc5f1 100644 --- a/spec/system/personas_spec.rb +++ b/spec/system/personas_spec.rb @@ -56,7 +56,7 @@ def given_personas_are_deactivated def given_personas_exist create(:region, :online_checks, name: "Example Region") - create(:staff, :confirmed, email: "staff@example.com") + create(:staff, email: "staff@example.com") teacher = create(:teacher, email: "teacher@example.com") create(:application_form, teacher:) diff --git a/spec/system/support_interface/staff_spec.rb b/spec/system/support_interface/staff_spec.rb index 9afbb73198..b791b8c0c4 100644 --- a/spec/system/support_interface/staff_spec.rb +++ b/spec/system/support_interface/staff_spec.rb @@ -72,7 +72,7 @@ private def given_a_helpdesk_user_exists - create(:staff, :confirmed, name: "Helpdesk") + create(:staff, name: "Helpdesk") end def given_sign_in_with_active_directory_is_active diff --git a/spec/system/teacher_interface/submitting_spec.rb b/spec/system/teacher_interface/submitting_spec.rb index d5db5499e4..92b62cc860 100644 --- a/spec/system/teacher_interface/submitting_spec.rb +++ b/spec/system/teacher_interface/submitting_spec.rb @@ -75,15 +75,15 @@ def application_form @application_form ||= create( :application_form, - :completed, :with_personal_information, :with_identification_document, + :with_teaching_qualification, :with_age_range, :with_subjects, - :with_registration_number, + :with_english_language_provider, :with_work_history, :with_written_statement, - :with_teaching_qualification, + :with_registration_number, teacher:, ) end diff --git a/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb b/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb index 37db97537b..f6a35fa3d5 100644 --- a/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb +++ b/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb @@ -11,7 +11,7 @@ end let(:params) { {} } - let(:current_staff) { create(:staff, :confirmed) } + let(:current_staff) { create(:staff) } describe "#application_form" do subject(:application_form) { view_object.application_form } @@ -251,7 +251,11 @@ context "and request further information" do before do assessment.request_further_information! - create(:selected_failure_reason, :fi_requestable, assessment_section:) + create( + :selected_failure_reason, + :further_informationable, + assessment_section:, + ) assessment_section.reload.update!(passed: false) end @@ -303,7 +307,12 @@ context "with a passed further information request" do before do assessment.request_further_information! - create(:further_information_request, :received, :passed, assessment:) + create( + :further_information_request, + :received, + :review_passed, + assessment:, + ) end it do @@ -318,7 +327,12 @@ context "with a failed further information request" do before do assessment.request_further_information! - create(:further_information_request, :received, :failed, assessment:) + create( + :further_information_request, + :received, + :review_failed, + assessment:, + ) end it do @@ -333,7 +347,12 @@ context "with a passed further information request and a finished assessment" do before do assessment.award! - create(:further_information_request, :received, :passed, assessment:) + create( + :further_information_request, + :received, + :review_passed, + assessment:, + ) end it do is_expected.to include_task_list_item( @@ -347,7 +366,12 @@ context "with a failed further information request and a finished assessment" do before do assessment.decline! - create(:further_information_request, :received, :failed, assessment:) + create( + :further_information_request, + :received, + :review_failed, + assessment:, + ) end it do is_expected.to include_task_list_item( diff --git a/spec/view_objects/teacher_interface/application_form_view_object_spec.rb b/spec/view_objects/teacher_interface/application_form_view_object_spec.rb index 0dadc660ab..0c0f9b181f 100644 --- a/spec/view_objects/teacher_interface/application_form_view_object_spec.rb +++ b/spec/view_objects/teacher_interface/application_form_view_object_spec.rb @@ -196,7 +196,19 @@ end context "with a completed application form" do - let(:application_form) { create(:application_form, :completed) } + let(:application_form) do + create( + :application_form, + :with_personal_information, + :with_identification_document, + :with_degree_qualification, + :with_age_range, + :with_subjects, + :with_work_history, + :with_written_statement, + :with_english_language_provider, + ) + end it { is_expected.to be true } end