diff --git a/app/controllers/personas_controller.rb b/app/controllers/personas_controller.rb
index edb76b81ae..2764926cb2 100644
--- a/app/controllers/personas_controller.rb
+++ b/app/controllers/personas_controller.rb
@@ -103,10 +103,10 @@ def load_eligible_personas
%w[online written none]
.product(
%w[online written none],
- %w[draft submitted waiting_on awarded declined],
+ %w[draft not_started verification completed],
)
- .map do |status_check, sanction_check, status|
- { status_check:, sanction_check:, status: }
+ .map do |status_check, sanction_check, stage|
+ { status_check:, sanction_check:, stage: }
end
def load_teacher_personas
@@ -129,7 +129,7 @@ def load_teacher_personas
region.status_check == persona[:status_check] &&
region.sanction_check == persona[:sanction_check] &&
- application_form.status == persona[:status]
+ application_form.stage == persona[:stage]
end
if (application_form = found_application_form)
diff --git a/app/controllers/teacher_interface/base_controller.rb b/app/controllers/teacher_interface/base_controller.rb
index 06892b8536..7410b3c5e6 100644
--- a/app/controllers/teacher_interface/base_controller.rb
+++ b/app/controllers/teacher_interface/base_controller.rb
@@ -34,7 +34,7 @@ def document
end
def redirect_unless_application_form_is_draft
- if application_form.nil? || !application_form.draft?
+ if application_form.nil? || application_form.submitted?
redirect_to %i[teacher_interface application_form]
end
end
diff --git a/app/lib/filters/status.rb b/app/lib/filters/status.rb
deleted file mode 100644
index 6300bc79b4..0000000000
--- a/app/lib/filters/status.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen_string_literal: true
-
-class Filters::Status < Filters::Base
- def apply
- return scope if statuses.empty?
-
- exact_statuses = statuses - BOOLEAN_TO_EXACT_STATUSES.keys
- boolean_statuses = statuses - exact_statuses
-
- scope.merge(
- boolean_statuses.reduce(
- ApplicationForm.where(status: exact_statuses),
- ) do |accumulator, boolean_status|
- accumulator.or(
- ApplicationForm.where(
- {
- boolean_status => true,
- :status => BOOLEAN_TO_EXACT_STATUSES.fetch(boolean_status),
- },
- ),
- )
- end,
- )
- end
-
- private
-
- BOOLEAN_TO_EXACT_STATUSES = {
- "overdue_further_information" => "overdue",
- "overdue_professional_standing" => "overdue",
- "overdue_qualification" => "overdue",
- "overdue_reference" => "overdue",
- "received_further_information" => "received",
- "received_professional_standing" => "received",
- "received_qualification" => "received",
- "received_reference" => "received",
- "waiting_on_further_information" => "waiting_on",
- "waiting_on_professional_standing" => "waiting_on",
- "waiting_on_qualification" => "waiting_on",
- "waiting_on_reference" => "waiting_on",
- }.freeze
-
- def statuses
- Array(params[:statuses]).reject(&:blank?)
- end
-end
diff --git a/app/models/application_form.rb b/app/models/application_form.rb
index 2871703c51..6d2e7c2aef 100644
--- a/app/models/application_form.rb
+++ b/app/models/application_form.rb
@@ -111,7 +111,6 @@ class ApplicationForm < ApplicationRecord
belongs_to :assessor, class_name: "Staff", optional: true
belongs_to :reviewer, class_name: "Staff", optional: true
- validates :submitted_at, presence: true, unless: :draft?
validates :awarded_at, absence: true, if: :declined_at?
validates :awarded_at, absence: true, if: :withdrawn_at?
validates :declined_at, absence: true, if: :awarded_at?
@@ -146,21 +145,6 @@ class ApplicationForm < ApplicationRecord
},
_suffix: true
- enum status: {
- draft: "draft",
- submitted: "submitted",
- preliminary_check: "preliminary_check",
- assessment_in_progress: "assessment_in_progress",
- waiting_on: "waiting_on",
- received: "received",
- overdue: "overdue",
- awarded_pending_checks: "awarded_pending_checks",
- awarded: "awarded",
- declined: "declined",
- potential_duplicate_in_dqt: "potential_duplicate_in_dqt",
- withdrawn: "withdrawn",
- }
-
delegate :country, to: :region, allow_nil: true
STATUS_COLUMNS = %i[
@@ -183,40 +167,31 @@ class ApplicationForm < ApplicationRecord
STATUS_COLUMNS.each { |column| enum column, STATUS_VALUES, prefix: column }
- scope :assessable,
- -> do
- where(
- status: %i[
- preliminary_check
- submitted
- assessment_in_progress
- waiting_on
- received
- overdue
- ],
- )
- end
+ scope :assessable, -> { where.not(stage: %i[draft completed]) }
scope :active,
-> do
assessable
- .or(awarded_pending_checks)
- .or(potential_duplicate_in_dqt)
- .or(awarded.where("awarded_at >= ?", 90.days.ago))
- .or(declined.where("declined_at >= ?", 90.days.ago))
- .or(withdrawn.where("withdrawn_at >= ?", 90.days.ago))
+ .or(where("awarded_at >= ?", 90.days.ago))
+ .or(where("declined_at >= ?", 90.days.ago))
+ .or(where("withdrawn_at >= ?", 90.days.ago))
end
scope :destroyable,
-> do
- draft
+ where(submitted_at: nil)
.where("created_at < ?", 6.months.ago)
- .or(awarded.where("awarded_at < ?", 5.years.ago))
- .or(declined.where("declined_at < ?", 5.years.ago))
- .or(withdrawn.where("withdrawn_at < ?", 5.years.ago))
+ .or(where("awarded_at < ?", 5.years.ago))
+ .or(where("declined_at < ?", 5.years.ago))
+ .or(where("withdrawn_at < ?", 5.years.ago))
end
- scope :remindable, -> { draft.where("created_at < ?", 5.months.ago) }
+ scope :remindable,
+ -> { where(submitted_at: nil).where("created_at < ?", 5.months.ago) }
+
+ def submitted?
+ submitted_at.present?
+ end
def teaching_qualification
qualifications.find(&:is_teaching_qualification?)
@@ -269,7 +244,7 @@ def send_reminder_email(number_of_reminders_sent)
end
def expires_after
- draft? ? 6.months : nil
+ submitted? ? nil : 6.months
end
def requested_at
diff --git a/app/models/further_information_request.rb b/app/models/further_information_request.rb
index 542bbc9e5a..956faddc68 100644
--- a/app/models/further_information_request.rb
+++ b/app/models/further_information_request.rb
@@ -68,7 +68,9 @@ def after_received(*)
end
def after_expired(user:)
- DeclineQTS.call(application_form:, user:) unless application_form.withdrawn?
+ if application_form.withdrawn_at.nil?
+ DeclineQTS.call(application_form:, user:)
+ end
end
def after_reviewed(user:)
diff --git a/app/models/professional_standing_request.rb b/app/models/professional_standing_request.rb
index 459d64b5ca..3a6587b6fa 100644
--- a/app/models/professional_standing_request.rb
+++ b/app/models/professional_standing_request.rb
@@ -45,7 +45,7 @@ def after_received(*)
def after_expired(user:)
if application_form.teaching_authority_provides_written_statement &&
- !application_form.withdrawn?
+ application_form.withdrawn_at.nil?
DeclineQTS.call(application_form:, user:)
end
end
@@ -55,7 +55,7 @@ def after_expired(user:)
private
def should_send_received_email?
- !application_form.declined? &&
+ application_form.declined_at.nil? &&
application_form.teaching_authority_provides_written_statement
end
end
diff --git a/app/models/teacher.rb b/app/models/teacher.rb
index b996aaf68a..b8a0162dde 100644
--- a/app/models/teacher.rb
+++ b/app/models/teacher.rb
@@ -35,7 +35,7 @@ class Teacher < ApplicationRecord
def application_form
@application_form ||=
- application_forms.not_withdrawn.order(created_at: :desc).first
+ application_forms.where(withdrawn_at: nil).order(created_at: :desc).first
end
def send_magic_link(*)
diff --git a/app/services/award_qts.rb b/app/services/award_qts.rb
index 57cb59b18e..95d784a765 100644
--- a/app/services/award_qts.rb
+++ b/app/services/award_qts.rb
@@ -17,12 +17,9 @@ def initialize(
end
def call
- return if application_form.awarded?
+ return if application_form.awarded_at.present?
- unless application_form.awarded_pending_checks? ||
- application_form.potential_duplicate_in_dqt?
- raise InvalidState
- end
+ raise InvalidState if application_form.dqt_trn_request.nil?
raise MissingTRN if trn.blank?
diff --git a/app/services/backfill_preliminary_checks.rb b/app/services/backfill_preliminary_checks.rb
index ed10eae848..bd12c1315c 100644
--- a/app/services/backfill_preliminary_checks.rb
+++ b/app/services/backfill_preliminary_checks.rb
@@ -43,12 +43,14 @@ def applications_forms
requires_preliminary_check: false,
)
.merge(
- ApplicationForm.submitted.or(
- ApplicationForm.waiting_on.where(
- teaching_authority_provides_written_statement: true,
- waiting_on_professional_standing: true,
+ ApplicationForm
+ .where.not(submitted_at: nil)
+ .or(
+ ApplicationForm.pre_assessment_stage.where(
+ "'waiting_on_lops' = ANY (statuses)",
+ teaching_authority_provides_written_statement: true,
+ ),
),
- ),
)
end
end
diff --git a/app/services/decline_qts.rb b/app/services/decline_qts.rb
index c12a406a63..c204029427 100644
--- a/app/services/decline_qts.rb
+++ b/app/services/decline_qts.rb
@@ -9,7 +9,7 @@ def initialize(application_form:, user:)
end
def call
- return if application_form.declined?
+ return if application_form.declined_at.present?
ActiveRecord::Base.transaction do
application_form.update!(declined_at: Time.zone.now)
diff --git a/app/services/rollback_assessment.rb b/app/services/rollback_assessment.rb
index d04549e02c..e6092eb764 100644
--- a/app/services/rollback_assessment.rb
+++ b/app/services/rollback_assessment.rb
@@ -33,12 +33,12 @@ def validate_state
def has_submitted_another_application_form?
teacher.application_form != application_form &&
- !teacher.application_form.draft?
+ teacher.application_form.submitted?
end
def valid_assessment_state?
assessment.award? || assessment.decline? ||
- (assessment.unknown? && application_form.declined?)
+ (assessment.unknown? && application_form.declined_at.present?)
end
def update_assessment
@@ -63,9 +63,11 @@ def previously_further_information_requested?
delegate :teacher, to: :application_form
def update_application_form
- if application_form.awarded?
+ if application_form.awarded_at.present?
application_form.update!(awarded_at: nil)
- elsif application_form.declined?
+ end
+
+ if application_form.declined_at.present?
application_form.update!(declined_at: nil)
end
@@ -74,8 +76,7 @@ def update_application_form
def delete_draft_application_forms
ApplicationForm
- .draft
- .where(teacher:)
+ .where(submitted_at: nil, teacher:)
.find_each do |application_form|
DestroyApplicationForm.call(application_form:)
end
diff --git a/app/services/withdraw_application_form.rb b/app/services/withdraw_application_form.rb
index dbe6c26589..6202a74002 100644
--- a/app/services/withdraw_application_form.rb
+++ b/app/services/withdraw_application_form.rb
@@ -9,7 +9,7 @@ def initialize(application_form:, user:)
end
def call
- return if application_form.withdrawn?
+ return if application_form.withdrawn_at.present?
ActiveRecord::Base.transaction do
application_form.update!(withdrawn_at: Time.zone.now)
diff --git a/app/view_objects/assessor_interface/application_forms_show_view_object.rb b/app/view_objects/assessor_interface/application_forms_show_view_object.rb
index ad06e78ff5..2364864421 100644
--- a/app/view_objects/assessor_interface/application_forms_show_view_object.rb
+++ b/app/view_objects/assessor_interface/application_forms_show_view_object.rb
@@ -10,7 +10,7 @@ def application_form
@application_form ||=
ApplicationForm
.includes(assessment: :sections)
- .not_draft
+ .where.not(submitted_at: nil)
.find(params[:id])
end
@@ -27,7 +27,7 @@ def task_list_sections
end
def status
- application_form.status.humanize
+ application_form.statuses.map(&:humanize).to_sentence
end
def email_used_as_reference_in_this_application_form?
@@ -41,7 +41,7 @@ def other_application_forms_where_email_used_as_reference
.includes(:application_form)
.where(canonical_contact_email: canonical_email)
.where.not(application_form:)
- .where.not(application_form: { status: "draft" })
+ .where.not(application_form: { submitted_at: nil })
.map(&:application_form)
end
@@ -73,6 +73,10 @@ def management_tasks
].compact
end
+ def waiting_on_references?
+ assessment.reference_requests.reject(&:reviewed?).any?(&:requested?)
+ end
+
private
attr_reader :params, :current_staff
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 ae5e8a9f00..2387e633e5 100644
--- a/app/view_objects/assessor_interface/assessment_section_view_object.rb
+++ b/app/view_objects/assessor_interface/assessment_section_view_object.rb
@@ -99,7 +99,7 @@ def work_history_application_forms_contact_email_used_as_teacher
ApplicationForm
.includes(:teacher)
- .not_draft
+ .where.not(submitted_at: nil)
.where(
teacher: {
canonical_email: work_history_canonical_contact_emails,
@@ -123,7 +123,7 @@ def work_history_application_forms_contact_email_used_as_reference
canonical_contact_email: work_history_canonical_contact_emails,
)
.where.not(application_form:)
- .where.not(application_form: { status: "draft" })
+ .where.not(application_form: { submitted_at: nil })
.group_by(&:canonical_contact_email)
.transform_values do |work_histories|
work_histories.map(&:application_form)
diff --git a/app/views/assessor_interface/application_forms/status.html.erb b/app/views/assessor_interface/application_forms/status.html.erb
index ccb57b3839..e8530be93f 100644
--- a/app/views/assessor_interface/application_forms/status.html.erb
+++ b/app/views/assessor_interface/application_forms/status.html.erb
@@ -1,22 +1,22 @@
<% content_for :page_title, "Application" %>
-<% content_for :back_link_url, assessor_interface_application_form_path(@view_object.application_form) %>
+<% content_for :back_link_url, [:assessor_interface, @view_object.application_form] %>
-<% if @view_object.application_form.waiting_on? %>
+<% if @view_object.waiting_on_references? %>
<%= govuk_panel(title_text: "Reference requests sent successfully") %>
<% else %>
<%= govuk_panel(title_text: "QTS application #{@view_object.application_form.reference} has been #{@view_object.status.downcase}") %>
<% end %>
-<% unless @view_object.application_form.waiting_on? %>
-
The status of this application has been changed to ’<%= @view_object.status %>‘.
+<% unless @view_object.waiting_on_references? %>
+ The status of this application has been changed to ‘<%= @view_object.status %>’.
<% end %>
-<% if @view_object.application_form.declined? %>
+<% if @view_object.application_form.declined_at.present? %>
The application will be deleted after 90 days unless the applicant chooses to appeal.
-<% elsif @view_object.application_form.awarded_pending_checks? %>
+<% elsif @view_object.application_form.dqt_trn_request.present? %>
This status will appear while the award is reconciled with the information in the Database of Qualified Teachers (DQT).
Once these checks are complete, the status will change to ‘Awarded’ and the applicant will receive the email telling them they’ve been awarded QTS.
-<% elsif @view_object.application_form.waiting_on? %>
+<% elsif @view_object.waiting_on_references? %>
You’ve successfully sent requests to each of the references that the applicant provided.
The applicant will also receive an email to tell them you’ve contacted their references.
When the references respond, you’ll see the status of the application change to ‘Received’.
@@ -25,6 +25,6 @@
You can now return to the application itself, or go back to your list of applications.
- <%= govuk_button_link_to "Back to application list", assessor_interface_application_forms_path %>
- <%= govuk_button_link_to "See application overview", assessor_interface_application_form_path(@view_object.application_form), secondary: true %>
+ <%= govuk_button_link_to "Back to application list", %i[assessor_interface application_forms] %>
+ <%= govuk_button_link_to "See application overview", [:assessor_interface, @view_object.application_form], secondary: true %>
diff --git a/app/views/teacher_interface/application_forms/show.html.erb b/app/views/teacher_interface/application_forms/show.html.erb
index 94898777ee..27502a7d25 100644
--- a/app/views/teacher_interface/application_forms/show.html.erb
+++ b/app/views/teacher_interface/application_forms/show.html.erb
@@ -2,16 +2,16 @@
Apply for qualified teacher status (QTS)
-<% if @view_object.application_form.draft? %>
- <%= render "teacher_interface/application_forms/show/draft", view_object: @view_object %>
-<% elsif @view_object.application_form.declined? %>
+<% if @view_object.application_form.declined_at.present? %>
<%= render "teacher_interface/application_forms/show/declined", view_object: @view_object %>
-<% elsif @view_object.application_form.awarded? %>
+<% elsif @view_object.application_form.awarded_at.present? %>
<%= render "teacher_interface/application_forms/show/awarded", view_object: @view_object %>
<% elsif @view_object.request_further_information? %>
<%= render "teacher_interface/application_forms/show/further_information_requested", view_object: @view_object %>
<% elsif @view_object.request_professional_standing_certificate? %>
<%= render "teacher_interface/application_forms/show/request_professional_standing_certificate", view_object: @view_object %>
-<% else %>
+<% elsif @view_object.application_form.submitted? %>
<%= render "teacher_interface/application_forms/show/complete", view_object: @view_object %>
+<% else %>
+ <%= render "teacher_interface/application_forms/show/draft", view_object: @view_object %>
<% end %>
diff --git a/lib/tasks/example_data.rake b/lib/tasks/example_data.rake
index ea565c92c0..3941eb04e3 100644
--- a/lib/tasks/example_data.rake
+++ b/lib/tasks/example_data.rake
@@ -159,11 +159,11 @@ def create_application_forms
application_form_traits_for(region).each do |traits|
application_form = FactoryBot.create(:application_form, *traits, region:)
- next if application_form.draft?
+ next unless application_form.submitted?
assessment = AssessmentFactory.call(application_form:)
- if application_form.waiting_on?
+ if application_form.action_required_by_external?
if application_form.teaching_authority_provides_written_statement
FactoryBot.create(
:professional_standing_request,
@@ -173,7 +173,6 @@ def create_application_forms
application_form.update!(
statuses: %w[waiting_on_lops],
stage: "pre_assessment",
- waiting_on_professional_standing: true,
)
elsif application_form.needs_written_statement && rand(4).zero?
FactoryBot.create(
@@ -184,7 +183,6 @@ def create_application_forms
application_form.update!(
statuses: %w[waiting_on_lops],
stage: "verification",
- waiting_on_professional_standing: true,
)
elsif (work_history = application_form.work_histories.first) &&
rand(3).zero?
@@ -198,7 +196,6 @@ def create_application_forms
application_form.update!(
statuses: %w[waiting_on_reference],
stage: "verification",
- waiting_on_reference: true,
)
elsif (qualification = application_form.qualifications.first) &&
rand(2).zero?
@@ -212,7 +209,6 @@ def create_application_forms
application_form.update!(
statuses: %w[waiting_on_qualification],
stage: "verification",
- waiting_on_qualification: true,
)
else
FactoryBot.create(
@@ -224,7 +220,6 @@ def create_application_forms
application_form.update!(
statuses: %w[waiting_on_further_information],
stage: "assessment",
- waiting_on_further_information: true,
)
end
elsif (work_history = application_form.work_histories.first) &&
diff --git a/spec/components/timeline_entry_spec.rb b/spec/components/timeline_entry_spec.rb
index 71d421deb0..b8660e6227 100644
--- a/spec/components/timeline_entry_spec.rb
+++ b/spec/components/timeline_entry_spec.rb
@@ -8,12 +8,7 @@
context "with a creator name" do
let(:timeline_event) do
- create(
- :timeline_event,
- :status_changed,
- creator_name: "DQT",
- creator: nil,
- )
+ create(:timeline_event, :stage_changed, creator_name: "DQT", creator: nil)
end
it "describes the event" do
@@ -51,7 +46,7 @@
end
end
- context "state changed" do
+ context "status changed" do
let(:timeline_event) do
create(
:timeline_event,
diff --git a/spec/factories/application_forms.rb b/spec/factories/application_forms.rb
index e75ce35027..952e851dc5 100644
--- a/spec/factories/application_forms.rb
+++ b/spec/factories/application_forms.rb
@@ -93,7 +93,6 @@
FactoryBot.define do
factory :application_form do
sequence(:reference) { |n| n.to_s.rjust(7, "0") }
- status { "draft" }
association :teacher
association :region
@@ -179,7 +178,6 @@
trait :submitted do
not_started_stage
- status { "submitted" }
statuses { %w[assessment_not_started] }
submitted_at { Time.zone.now }
working_days_since_submission { 0 }
@@ -187,11 +185,11 @@
after(:create) do |application_form, _evaluator|
create(
:timeline_event,
- :status_changed,
+ :stage_changed,
application_form:,
creator: application_form.teacher,
old_value: "draft",
- new_value: "submitted",
+ new_value: "not_started",
)
end
end
@@ -200,14 +198,12 @@
submitted
pre_assessment_stage
requires_preliminary_check { true }
- status { "preliminary_check" }
statuses { %w[preliminary_check] }
end
trait :assessment_in_progress do
submitted
assessment_stage
- status { "assessment_in_progress" }
statuses { %w[assessment_in_progress] }
end
@@ -215,7 +211,6 @@
submitted
action_required_by_external
verification_stage
- status { "waiting_on" }
statuses do
%w[
waiting_on_further_information
@@ -229,7 +224,6 @@
trait :received do
submitted
verification_stage
- status { "received" }
statuses do
%w[
received_further_information
@@ -243,7 +237,6 @@
trait :overdue do
submitted
verification_stage
- status { "overdue" }
statuses do
%w[
overdue_further_information
@@ -257,21 +250,18 @@
trait :awarded_pending_checks do
submitted
review_stage
- status { "awarded_pending_checks" }
statuses { %w[awarded_pending_checks] }
end
trait :potential_duplicate_in_dqt do
submitted
review_stage
- status { "potential_duplicate_in_dqt" }
statuses { %w[potential_duplicate_in_dqt] }
end
trait :awarded do
submitted
completed_stage
- status { "awarded" }
statuses { %w[awarded] }
awarded_at { Time.zone.now }
end
@@ -279,7 +269,6 @@
trait :declined do
submitted
completed_stage
- status { "declined" }
statuses { %w[declined] }
declined_at { Time.zone.now }
end
@@ -287,7 +276,6 @@
trait :withdrawn do
submitted
completed_stage
- status { "withdrawn" }
statuses { %w[withdrawn] }
withdrawn_at { Time.zone.now }
end
diff --git a/spec/jobs/update_dqt_trn_request_job_spec.rb b/spec/jobs/update_dqt_trn_request_job_spec.rb
index 9041c7be05..88fc5022d8 100644
--- a/spec/jobs/update_dqt_trn_request_job_spec.rb
+++ b/spec/jobs/update_dqt_trn_request_job_spec.rb
@@ -80,10 +80,10 @@
perform_rescue_exception
end
- it "doesn't change the state" do
+ it "doesn't change the stage" do
expect { perform_rescue_exception }.to_not change(
application_form,
- :status,
+ :stage,
)
end
@@ -116,8 +116,8 @@
end
it "changes the state" do
- expect { perform }.to change(application_form, :status).to(
- "potential_duplicate_in_dqt",
+ expect { perform }.to change(application_form, :statuses).to(
+ %w[potential_duplicate_in_dqt],
)
end
@@ -193,10 +193,10 @@
perform_rescue_exception
end
- it "doesn't change the state" do
+ it "doesn't change the stage" do
expect { perform_rescue_exception }.to_not change(
application_form,
- :status,
+ :stage,
)
end
@@ -232,8 +232,8 @@
end
it "changes the state" do
- expect { perform }.to change(application_form, :status).to(
- "potential_duplicate_in_dqt",
+ expect { perform }.to change(application_form, :statuses).to(
+ %w[potential_duplicate_in_dqt],
)
end
@@ -265,8 +265,8 @@
perform
end
- it "doesn't change the state" do
- expect { perform }.to_not change(application_form, :status)
+ it "doesn't change the stage" do
+ expect { perform }.to_not change(application_form, :stage)
end
it "doesn't queue another job" do
diff --git a/spec/lib/application_form_status_updater_spec.rb b/spec/lib/application_form_status_updater_spec.rb
index 0e37713741..758bd3f364 100644
--- a/spec/lib/application_form_status_updater_spec.rb
+++ b/spec/lib/application_form_status_updater_spec.rb
@@ -339,14 +339,6 @@
end
context "when status is unchanged" do
- it "doesn't change the status from draft" do
- expect { call }.to_not change(application_form, :status).from("draft")
- end
-
- it "doesn't record a timeline event" do
- expect { call }.to_not have_recorded_timeline_event(:status_changed)
- end
-
include_examples "doesn't change action required by"
it "doesn't change the stage from draft" do
diff --git a/spec/lib/filters/status_spec.rb b/spec/lib/filters/status_spec.rb
deleted file mode 100644
index ef4fd80820..0000000000
--- a/spec/lib/filters/status_spec.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-# frozen_string_literal: true
-
-require "rails_helper"
-
-RSpec.describe Filters::Status do
- subject { described_class.apply(scope:, params:) }
-
- context "with states param and a single state" do
- let(:params) { { statuses: :draft } }
- let(:scope) { ApplicationForm.all }
-
- let!(:included) { create(:application_form, :draft) }
-
- let!(:filtered) { create(:application_form, :submitted) }
-
- it "returns a filtered scope" do
- expect(subject).to contain_exactly(included)
- end
- end
-
- context "wth states param and multiple states" do
- let(:params) do
- { statuses: %w[draft submitted waiting_on_further_information] }
- end
- let(:scope) { ApplicationForm.all }
-
- before do
- create(:application_form, :awarded)
- create(:application_form, :declined)
- create(:application_form, :declined, waiting_on_further_information: true)
- end
-
- let!(:included) do
- [
- create(:application_form, :draft),
- create(:application_form, :submitted),
- create(:application_form, waiting_on_further_information: true),
- ]
- end
-
- it "returns a filtered scope" do
- expect(subject).to match_array(included)
- end
- end
-
- context "with states param and a blank string" do
- let(:params) { { statuses: [""] } }
- let(:scope) { double }
-
- it "returns the original scope" do
- expect(subject).to eq(scope)
- end
- end
-
- context "without states param" do
- let(:params) { {} }
- let(:scope) { double }
-
- it "returns the original scope" do
- expect(subject).to eq(scope)
- end
- end
-end
diff --git a/spec/models/application_form_spec.rb b/spec/models/application_form_spec.rb
index 5336ce22d6..8fd6e06bed 100644
--- a/spec/models/application_form_spec.rb
+++ b/spec/models/application_form_spec.rb
@@ -128,21 +128,6 @@
)
.with_suffix
.backed_by_column_of_type(:string)
-
- is_expected.to define_enum_for(:status).with_values(
- draft: "draft",
- submitted: "submitted",
- preliminary_check: "preliminary_check",
- assessment_in_progress: "assessment_in_progress",
- waiting_on: "waiting_on",
- received: "received",
- overdue: "overdue",
- awarded: "awarded",
- awarded_pending_checks: "awarded_pending_checks",
- declined: "declined",
- potential_duplicate_in_dqt: "potential_duplicate_in_dqt",
- withdrawn: "withdrawn",
- ).backed_by_column_of_type(:string)
end
it do
@@ -287,18 +272,6 @@
it { is_expected.to validate_absence_of(:english_language_provider) }
end
- context "when submitted" do
- before { application_form.status = "submitted" }
-
- it { is_expected.to_not be_valid }
-
- context "with submitted_at" do
- before { application_form.submitted_at = Time.zone.now }
-
- it { is_expected.to be_valid }
- end
- end
-
context "when awarded and declined" do
before do
application_form.assign_attributes(
diff --git a/spec/services/award_qts_spec.rb b/spec/services/award_qts_spec.rb
index d57a685c0d..ccbdebddb1 100644
--- a/spec/services/award_qts_spec.rb
+++ b/spec/services/award_qts_spec.rb
@@ -30,6 +30,8 @@
create(:application_form, :awarded_pending_checks, teacher:)
end
+ before { create(:dqt_trn_request, application_form:) }
+
it "sets the TRN" do
expect { call }.to change(teacher, :trn).to("abcdef")
end
@@ -49,7 +51,7 @@
end
it "changes the status" do
- expect { call }.to change(application_form, :status).to("awarded")
+ expect { call }.to change(application_form, :stage).to("completed")
end
it "sets the awarded at date" do
@@ -74,6 +76,8 @@
create(:application_form, :potential_duplicate_in_dqt, teacher:)
end
+ before { create(:dqt_trn_request, application_form:) }
+
it "sets the TRN" do
expect { call }.to change(teacher, :trn).to("abcdef")
end
@@ -93,7 +97,7 @@
end
it "changes the status" do
- expect { call }.to change(application_form, :status).to("awarded")
+ expect { call }.to change(application_form, :stage).to("completed")
end
it "sets the awarded at date" do
@@ -116,6 +120,8 @@
context "with an awarded application form" do
let(:application_form) { create(:application_form, :awarded, teacher:) }
+ before { create(:dqt_trn_request, application_form:) }
+
it "doesn't change the TRN" do
expect { call }.to_not change(teacher, :trn)
end
@@ -134,8 +140,8 @@
)
end
- it "doesn't change the status" do
- expect { call }.to_not change(application_form, :status)
+ it "doesn't change the stage" do
+ expect { call }.to_not change(application_form, :stage)
end
it "doesn't change the awarded at date" do
diff --git a/spec/services/backfill_preliminary_checks_spec.rb b/spec/services/backfill_preliminary_checks_spec.rb
index 61fd22478e..4c32083abc 100644
--- a/spec/services/backfill_preliminary_checks_spec.rb
+++ b/spec/services/backfill_preliminary_checks_spec.rb
@@ -29,7 +29,7 @@
:waiting_on,
:with_assessment,
region:,
- waiting_on_professional_standing: true,
+ statuses: %w[waiting_on_lops],
teaching_authority_provides_written_statement: true,
requires_preliminary_check: false,
)
@@ -46,25 +46,25 @@
it "doesn't backfill the submitted application form" do
expect { call }.to_not(
- change { submitted_application_form.reload.status },
+ change { submitted_application_form.reload.stage },
)
end
it "doesn't backfill the waiting on application form" do
expect { call }.to_not(
- change { waiting_on_application_form.reload.status },
+ change { waiting_on_application_form.reload.stage },
)
end
it "doesn't backfill the preliminary checked application form" do
expect { call }.to_not(
- change { preliminary_check_application_form.reload.status },
+ change { preliminary_check_application_form.reload.stage },
)
end
it "doesn't backfill the awarded application form" do
expect { call }.to_not(
- change { awarded_check_application_form.reload.status },
+ change { awarded_check_application_form.reload.stage },
)
end
end
@@ -77,7 +77,8 @@
submitted_application_form.reload
- expect(submitted_application_form.status).to eq("preliminary_check")
+ expect(submitted_application_form.stage).to eq("pre_assessment")
+ expect(submitted_application_form.statuses).to eq(%w[preliminary_check])
expect(submitted_application_form.requires_preliminary_check).to be true
expect(
submitted_application_form.assessment.sections.preliminary,
@@ -89,7 +90,10 @@
waiting_on_application_form.reload
- expect(waiting_on_application_form.status).to eq("preliminary_check")
+ expect(waiting_on_application_form.stage).to eq("pre_assessment")
+ expect(waiting_on_application_form.statuses).to eq(
+ %w[preliminary_check],
+ )
expect(
waiting_on_application_form.requires_preliminary_check,
).to be true
@@ -100,13 +104,13 @@
it "doesn't backfill the preliminary checked application form" do
expect { call }.to_not(
- change { preliminary_check_application_form.reload.status },
+ change { preliminary_check_application_form.reload.stage },
)
end
it "doesn't backfill the awarded application form" do
expect { call }.to_not(
- change { awarded_check_application_form.reload.status },
+ change { awarded_check_application_form.reload.stage },
)
end
end
diff --git a/spec/services/create_dqt_trn_request_spec.rb b/spec/services/create_dqt_trn_request_spec.rb
index 956074614f..616525eb9b 100644
--- a/spec/services/create_dqt_trn_request_spec.rb
+++ b/spec/services/create_dqt_trn_request_spec.rb
@@ -13,8 +13,8 @@
end
it "changes the status" do
- expect { call }.to change(application_form, :status).to(
- "awarded_pending_checks",
+ expect { call }.to change(application_form, :statuses).to(
+ %w[awarded_pending_checks],
)
end
diff --git a/spec/services/create_further_information_request_spec.rb b/spec/services/create_further_information_request_spec.rb
index 3a15e97ec4..9aed43e1e7 100644
--- a/spec/services/create_further_information_request_spec.rb
+++ b/spec/services/create_further_information_request_spec.rb
@@ -27,16 +27,10 @@
end
end
- describe "updating application form state" do
- subject(:status) { application_form.status }
-
- it { is_expected.to eq("submitted") }
-
- context "after calling the service" do
- before { call }
-
- it { is_expected.to eq("waiting_on") }
- end
+ it "changes the application form statuses" do
+ expect { call }.to change(application_form, :statuses).to(
+ %w[waiting_on_further_information],
+ )
end
describe "sending application received email" do
diff --git a/spec/services/decline_qts_spec.rb b/spec/services/decline_qts_spec.rb
index 2bc3d07cf8..dc9efae5e5 100644
--- a/spec/services/decline_qts_spec.rb
+++ b/spec/services/decline_qts_spec.rb
@@ -18,8 +18,12 @@
).with(params: { teacher: }, args: [])
end
- it "changes the status" do
- expect { call }.to change(application_form, :status).to("declined")
+ it "changes the stage" do
+ expect { call }.to change(application_form, :stage).to("completed")
+ end
+
+ it "changes the statuses" do
+ expect { call }.to change(application_form, :statuses).to(%w[declined])
end
it "sets the declined at date" do
@@ -41,8 +45,8 @@
)
end
- it "doesn't change the status" do
- expect { call }.to_not change(application_form, :status)
+ it "doesn't change the stage" do
+ expect { call }.to_not change(application_form, :stage)
end
it "doesn't change the declined at date" do
diff --git a/spec/services/expire_requestable_spec.rb b/spec/services/expire_requestable_spec.rb
index 1ccb78b8f7..b1259497a2 100644
--- a/spec/services/expire_requestable_spec.rb
+++ b/spec/services/expire_requestable_spec.rb
@@ -36,7 +36,7 @@
shared_examples_for "declining the application" do
it "declines the application" do
- expect(subject.application_form).to be_declined
+ expect(subject.application_form.declined_at).to_not be_nil
end
end
diff --git a/spec/services/receive_requestable_spec.rb b/spec/services/receive_requestable_spec.rb
index 72f41a760b..5f473292df 100644
--- a/spec/services/receive_requestable_spec.rb
+++ b/spec/services/receive_requestable_spec.rb
@@ -29,15 +29,9 @@
end
it "changes the application form status" do
- expect { call }.to change { application_form.reload.received? }.from(
- false,
- ).to(true)
- end
-
- it "changes the application form qualification received" do
- expect { call }.to change {
- application_form.reload.received_qualification
- }.from(false).to(true)
+ expect { call }.to change { application_form.reload.statuses }.to(
+ %w[received_qualification],
+ )
end
it "changes the requestable received at" do
diff --git a/spec/services/rollback_assessment_spec.rb b/spec/services/rollback_assessment_spec.rb
index 3816132598..a417ced448 100644
--- a/spec/services/rollback_assessment_spec.rb
+++ b/spec/services/rollback_assessment_spec.rb
@@ -19,12 +19,12 @@
end
it "reverts application form status" do
- expect { call }.to change(application_form, :status).to("waiting_on")
+ expect { call }.to change(application_form, :stage).to("verification")
end
it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
- :status_changed,
+ :stage_changed,
creator: user,
)
end
@@ -40,12 +40,12 @@
end
it "reverts application form status" do
- expect { call }.to change(application_form, :status).to("waiting_on")
+ expect { call }.to change(application_form, :stage).to("assessment")
end
it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
- :status_changed,
+ :stage_changed,
creator: user,
)
end
@@ -57,12 +57,12 @@
end
it "reverts application form status" do
- expect { call }.to change(application_form, :status).to("submitted")
+ expect { call }.to change(application_form, :stage).to("not_started")
end
it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
- :status_changed,
+ :stage_changed,
creator: user,
)
end
@@ -81,12 +81,12 @@
end
it "reverts application form status" do
- expect { call }.to change(application_form, :status).to("waiting_on")
+ expect { call }.to change(application_form, :stage).to("verification")
end
it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
- :status_changed,
+ :stage_changed,
creator: user,
)
end
@@ -102,12 +102,12 @@
end
it "reverts application form status" do
- expect { call }.to change(application_form, :status).to("waiting_on")
+ expect { call }.to change(application_form, :stage).to("assessment")
end
it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
- :status_changed,
+ :stage_changed,
creator: user,
)
end
@@ -119,12 +119,12 @@
end
it "reverts application form status" do
- expect { call }.to change(application_form, :status).to("submitted")
+ expect { call }.to change(application_form, :stage).to("not_started")
end
it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
- :status_changed,
+ :stage_changed,
creator: user,
)
end
@@ -164,12 +164,12 @@
end
it "reverts application form status" do
- expect { call }.to change(application_form, :status).to("submitted")
+ expect { call }.to change(application_form, :stage).to("not_started")
end
it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
- :status_changed,
+ :stage_changed,
creator: user,
)
end
diff --git a/spec/services/submit_application_form_spec.rb b/spec/services/submit_application_form_spec.rb
index c075181e9b..bad0cf44ce 100644
--- a/spec/services/submit_application_form_spec.rb
+++ b/spec/services/submit_application_form_spec.rb
@@ -61,11 +61,11 @@
it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
- :status_changed,
+ :stage_changed,
creator: user,
application_form:,
old_value: "draft",
- new_value: "submitted",
+ new_value: "not_started",
)
end
diff --git a/spec/services/update_assessment_section_spec.rb b/spec/services/update_assessment_section_spec.rb
index 63c890bd1e..7cbc323415 100644
--- a/spec/services/update_assessment_section_spec.rb
+++ b/spec/services/update_assessment_section_spec.rb
@@ -109,9 +109,9 @@
end
it "changes the application form state" do
- expect { subject }.to change { application_form.status }.from(
- "submitted",
- ).to("assessment_in_progress")
+ expect { subject }.to change { application_form.statuses }.from(
+ %w[assessment_not_started],
+ ).to(%w[assessment_in_progress])
end
it "changes the assessment started at" do
@@ -142,8 +142,12 @@
expect { subject }.to_not change(application_form, :assessor)
end
- it "doesn't change the application form state" do
- expect { subject }.to_not change(application_form, :status)
+ it "doesn't change the application form stage" do
+ expect { subject }.to_not change(application_form, :stage)
+ end
+
+ it "doesn't change the application form statuses" do
+ expect { subject }.to_not change(application_form, :statuses)
end
it "doesn't change the assessment started at" do
diff --git a/spec/services/verify_assessment_spec.rb b/spec/services/verify_assessment_spec.rb
index ffed134355..b7181cecd7 100644
--- a/spec/services/verify_assessment_spec.rb
+++ b/spec/services/verify_assessment_spec.rb
@@ -82,16 +82,8 @@
end
end
- describe "updating application form state" do
- subject(:status) { application_form.status }
-
- it { is_expected.to eq("submitted") }
-
- context "after calling the service" do
- before { call }
-
- it { is_expected.to eq("waiting_on") }
- end
+ it "changes the application form stage" do
+ expect { call }.to change(application_form, :stage).to("verification")
end
describe "sending referee email" do
diff --git a/spec/services/withdraw_application_form_spec.rb b/spec/services/withdraw_application_form_spec.rb
index 32ead4a527..29158fa010 100644
--- a/spec/services/withdraw_application_form_spec.rb
+++ b/spec/services/withdraw_application_form_spec.rb
@@ -8,18 +8,6 @@
subject(:call) { described_class.call(application_form:, user:) }
- describe "application form status" do
- subject(:withdrawn?) { application_form.withdrawn? }
-
- it { is_expected.to be false }
-
- context "when calling the service" do
- before { call }
-
- it { is_expected.to be true }
- end
- end
-
describe "application form withdrawn_at" do
subject(:withdrawn_at) { application_form.withdrawn_at }
diff --git a/spec/support/shared_examples.rb b/spec/support/shared_examples.rb
index ce9a97c9cc..107656de4d 100644
--- a/spec/support/shared_examples.rb
+++ b/spec/support/shared_examples.rb
@@ -2,9 +2,7 @@
RSpec.shared_examples "redirect unless application form is draft" do
context "with a submitted application form" do
- before do
- application_form.update!(status: "submitted", submitted_at: Time.zone.now)
- end
+ before { application_form.update!(submitted_at: Time.zone.now) }
it "redirects to the application form" do
perform
diff --git a/spec/system/assessor_interface/awaiting_professional_standing_spec.rb b/spec/system/assessor_interface/awaiting_professional_standing_spec.rb
index 58f5d3b38f..2ebb630a6a 100644
--- a/spec/system/assessor_interface/awaiting_professional_standing_spec.rb
+++ b/spec/system/assessor_interface/awaiting_professional_standing_spec.rb
@@ -70,7 +70,6 @@ def application_form
create(
:application_form,
:waiting_on,
- waiting_on_professional_standing: true,
statuses: %w[waiting_on_lops],
assessment: create(:assessment, :with_professional_standing_request),
teaching_authority_provides_written_statement: true,
diff --git a/spec/system/assessor_interface/verifying_professional_standing_spec.rb b/spec/system/assessor_interface/verifying_professional_standing_spec.rb
index f281aa0cf4..ba1002acac 100644
--- a/spec/system/assessor_interface/verifying_professional_standing_spec.rb
+++ b/spec/system/assessor_interface/verifying_professional_standing_spec.rb
@@ -83,12 +83,7 @@ def application_form
@application_form ||=
begin
application_form =
- create(
- :application_form,
- :waiting_on,
- waiting_on_professional_standing: true,
- statuses: %w[waiting_on_lops],
- )
+ create(:application_form, :waiting_on, statuses: %w[waiting_on_lops])
create(
:assessment,
:with_professional_standing_request,
diff --git a/spec/system/assessor_interface/verifying_qualifications_spec.rb b/spec/system/assessor_interface/verifying_qualifications_spec.rb
index 08c41983c0..8c229e7210 100644
--- a/spec/system/assessor_interface/verifying_qualifications_spec.rb
+++ b/spec/system/assessor_interface/verifying_qualifications_spec.rb
@@ -154,7 +154,11 @@ def application_form
@application_form ||=
begin
application_form =
- create(:application_form, :waiting_on, waiting_on_qualification: true)
+ create(
+ :application_form,
+ :waiting_on,
+ statuses: %w[waiting_on_qualification],
+ )
qualification = create(:qualification, :completed, application_form:)
assessment = create(:assessment, :started, application_form:)
create(:qualification_request, :requested, assessment:, qualification:)
diff --git a/spec/system/assessor_interface/verifying_references_spec.rb b/spec/system/assessor_interface/verifying_references_spec.rb
index 94ddbabbd4..2259d3b675 100644
--- a/spec/system/assessor_interface/verifying_references_spec.rb
+++ b/spec/system/assessor_interface/verifying_references_spec.rb
@@ -138,8 +138,7 @@ def application_form
create(
:application_form,
:waiting_on,
- waiting_on_reference: true,
- received_reference: true,
+ statuses: %w[waiting_on_reference received_reference],
)
work_history =
create(
diff --git a/spec/system/assessor_interface/view_timeline_events_spec.rb b/spec/system/assessor_interface/view_timeline_events_spec.rb
index f741945d02..8785e15721 100644
--- a/spec/system/assessor_interface/view_timeline_events_spec.rb
+++ b/spec/system/assessor_interface/view_timeline_events_spec.rb
@@ -39,7 +39,7 @@ def then_i_see_the_timeline
"Note created",
)
expect(timeline_page.timeline_items.second.title).to have_content(
- "Status changed",
+ "Stage changed",
)
expect(timeline_page.timeline_items.third.title).to have_content(
"Assessor assigned",
@@ -52,7 +52,7 @@ def application_form
application_form =
create(:application_form, :submitted, :with_assessment)
create(:timeline_event, :assessor_assigned, application_form:)
- create(:timeline_event, :status_changed, application_form:)
+ create(:timeline_event, :stage_changed, application_form:)
create(:timeline_event, :note_created, application_form:)
application_form
end
diff --git a/spec/view_objects/assessor_interface/application_forms_index_view_object_spec.rb b/spec/view_objects/assessor_interface/application_forms_index_view_object_spec.rb
index c1c8846646..b6bbbb4227 100644
--- a/spec/view_objects/assessor_interface/application_forms_index_view_object_spec.rb
+++ b/spec/view_objects/assessor_interface/application_forms_index_view_object_spec.rb
@@ -183,7 +183,7 @@
create_list(:application_form, 3, :submitted, :assessment_stage)
create_list(:application_form, 4, :submitted, :verification_stage)
create_list(:application_form, 5, :submitted, :review_stage)
- create_list(:application_form, 6, :submitted, :completed_stage)
+ create_list(:application_form, 6, :awarded, :completed_stage)
end
it do