Skip to content

Commit

Permalink
Stop updating statuses
Browse files Browse the repository at this point in the history
This updates the ApplicationFormStatusUpdater service to stop updating
the status (and related fields) as we're going to stop using them and
instead rely on the replacements.
  • Loading branch information
thomasleese committed Nov 16, 2023
1 parent e8c98a6 commit 0d6dca0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 160 deletions.
49 changes: 0 additions & 49 deletions app/lib/application_form_status_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,6 @@ def initialize(application_form:, user:)

def call
ActiveRecord::Base.transaction do
application_form.update!(
overdue_further_information:,
overdue_professional_standing: overdue_lops,
overdue_qualification:,
overdue_reference:,
received_further_information:,
received_professional_standing: received_lops,
received_qualification:,
received_reference:,
waiting_on_further_information:,
waiting_on_professional_standing: waiting_on_lops,
waiting_on_qualification:,
waiting_on_reference:,
)

application_form.status = status if application_form.status != status

if (old_action_required_by = application_form.action_required_by) !=
action_required_by
application_form.action_required_by = action_required_by
Expand Down Expand Up @@ -58,38 +41,6 @@ def call

attr_reader :application_form, :user

def status
@status ||=
if dqt_trn_request&.potential_duplicate?
"potential_duplicate_in_dqt"
elsif application_form.withdrawn_at.present?
"withdrawn"
elsif application_form.declined_at.present?
"declined"
elsif application_form.awarded_at.present?
"awarded"
elsif dqt_trn_request.present?
"awarded_pending_checks"
elsif preliminary_check?
"preliminary_check"
elsif overdue_further_information || overdue_lops ||
overdue_qualification || overdue_reference
"overdue"
elsif received_further_information || received_lops ||
received_qualification || received_reference
"received"
elsif waiting_on_further_information || waiting_on_lops ||
waiting_on_qualification || waiting_on_reference
"waiting_on"
elsif assessment&.any_not_preliminary_section_finished?
"assessment_in_progress"
elsif application_form.submitted_at.present?
"submitted"
else
"draft"
end
end

def action_required_by
@action_required_by ||=
if application_form.withdrawn_at.present? ||
Expand Down
111 changes: 0 additions & 111 deletions spec/lib/application_form_status_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@
end
end

shared_examples "changes status" do |new_status|
it "changes status to #{new_status}" do
expect { call }.to change(application_form, :status).to(new_status)
end
end

describe "#call" do
subject(:call) { described_class.call(application_form:, user:) }

Expand All @@ -80,7 +74,6 @@
include_examples "changes action required by", "assessor"
include_examples "changes stage", "review"
include_examples "changes statuses", %w[potential_duplicate_in_dqt]
include_examples "changes status", "potential_duplicate_in_dqt"
end

context "with a withdrawn_at date" do
Expand All @@ -94,7 +87,6 @@
include_examples "doesn't change action required by"
include_examples "changes stage", "completed"
include_examples "changes statuses", %w[withdrawn]
include_examples "changes status", "withdrawn"
end

context "with a declined_at date" do
Expand All @@ -108,7 +100,6 @@
include_examples "doesn't change action required by"
include_examples "changes stage", "completed"
include_examples "changes statuses", %w[declined]
include_examples "changes status", "declined"
end

context "with an awarded_at date" do
Expand All @@ -122,7 +113,6 @@
include_examples "doesn't change action required by"
include_examples "changes stage", "completed"
include_examples "changes statuses", %w[awarded]
include_examples "changes status", "awarded"
end

context "with a DQT TRN request" do
Expand All @@ -134,7 +124,6 @@
include_examples "changes action required by", "assessor"
include_examples "changes stage", "review"
include_examples "changes statuses", %w[awarded_pending_checks]
include_examples "changes status", "awarded_pending_checks"
end

context "with a received further information request" do
Expand All @@ -148,14 +137,6 @@
include_examples "changes action required by", "assessor"
include_examples "changes stage", "assessment"
include_examples "changes statuses", %w[received_further_information]
include_examples "changes status", "received"

it "changes received_further_information" do
expect { call }.to change(
application_form,
:received_further_information,
).from(false).to(true)
end
end

context "with a requested further information request" do
Expand All @@ -169,14 +150,6 @@
include_examples "changes action required by", "external"
include_examples "changes stage", "assessment"
include_examples "changes statuses", %w[waiting_on_further_information]
include_examples "changes status", "waiting_on"

it "changes waiting_on_further_information" do
expect { call }.to change(
application_form,
:waiting_on_further_information,
).from(false).to(true)
end
end

context "with a requested profession standing request" do
Expand All @@ -190,14 +163,6 @@
include_examples "changes action required by", "external"
include_examples "changes stage", "verification"
include_examples "changes statuses", %w[waiting_on_lops]
include_examples "changes status", "waiting_on"

it "changes waiting_on_professional_standing" do
expect { call }.to change(
application_form,
:waiting_on_professional_standing,
).from(false).to(true)
end
end

context "with a received profession standing request" do
Expand All @@ -215,13 +180,6 @@
include_examples "changes action required by", "assessor"
include_examples "changes stage", "not_started"
include_examples "changes statuses", %w[assessment_not_started]

it "doesn't change received_professional_standing" do
expect { call }.to_not change(
application_form,
:received_professional_standing,
).from(false)
end
end

context "when the teaching authority doesn't provide the written statement" do
Expand All @@ -233,14 +191,6 @@
include_examples "changes action required by", "admin"
include_examples "changes stage", "verification"
include_examples "changes statuses", %w[received_lops]
include_examples "changes status", "received"

it "changes received_professional_standing" do
expect { call }.to change(
application_form,
:received_professional_standing,
).from(false).to(true)
end
end
end

Expand All @@ -255,14 +205,6 @@
include_examples "changes action required by", "assessor"
include_examples "changes stage", "verification"
include_examples "changes statuses", %w[received_qualification]
include_examples "changes status", "received"

it "changes received_further_information" do
expect { call }.to change(
application_form,
:received_qualification,
).from(false).to(true)
end
end

context "with a requested qualification request" do
Expand All @@ -276,14 +218,6 @@
include_examples "changes action required by", "external"
include_examples "changes stage", "verification"
include_examples "changes statuses", %w[waiting_on_qualification]
include_examples "changes status", "waiting_on"

it "changes waiting_on_qualification" do
expect { call }.to change(
application_form,
:waiting_on_qualification,
).from(false).to(true)
end
end

context "with a received reference request" do
Expand Down Expand Up @@ -312,14 +246,6 @@
include_examples "changes action required by", "external"
include_examples "changes stage", "verification"
include_examples "changes statuses", %w[waiting_on_reference]
include_examples "changes status", "waiting_on"

it "doesn't change received_reference" do
expect { call }.to_not change(
application_form,
:received_reference,
).from(false)
end
end

context "with less than 20 months" do
Expand All @@ -343,14 +269,6 @@
include_examples "changes action required by", "assessor"
include_examples "changes stage", "verification"
include_examples "changes statuses", %w[received_reference]
include_examples "changes status", "received"

it "changes received_reference" do
expect { call }.to change(
application_form,
:received_reference,
).from(false).to(true)
end
end

context "and there are other reference requests" do
Expand All @@ -359,14 +277,6 @@
include_examples "changes action required by", "external"
include_examples "changes stage", "verification"
include_examples "changes statuses", %w[waiting_on_reference]
include_examples "changes status", "waiting_on"

it "doesn't change received_reference" do
expect { call }.to_not change(
application_form,
:received_reference,
).from(false)
end
end
end

Expand All @@ -390,13 +300,6 @@
include_examples "changes action required by", "assessor"
include_examples "changes stage", "verification"
include_examples "changes statuses", %w[received_reference]
include_examples "changes status", "received"

it "changes received_reference" do
expect { call }.to change(application_form, :received_reference).from(
false,
).to(true)
end
end
end

Expand All @@ -411,13 +314,6 @@
include_examples "changes action required by", "external"
include_examples "changes stage", "verification"
include_examples "changes statuses", %w[waiting_on_reference]
include_examples "changes status", "waiting_on"

it "changes waiting_on_reference" do
expect { call }.to change(application_form, :waiting_on_reference).from(
false,
).to(true)
end
end

context "when a reviewed assessment" do
Expand Down Expand Up @@ -451,7 +347,6 @@
include_examples "changes action required by", "assessor"
include_examples "changes stage", "assessment"
include_examples "changes statuses", %w[assessment_in_progress]
include_examples "changes status", "assessment_in_progress"
end

context "with an unstarted assessment" do
Expand All @@ -463,7 +358,6 @@
include_examples "changes action required by", "assessor"
include_examples "changes stage", "not_started"
include_examples "changes statuses", %w[assessment_not_started]
include_examples "changes status", "submitted"
end

context "when status is unchanged" do
Expand Down Expand Up @@ -505,7 +399,6 @@
include_examples "changes action required by", "admin"
include_examples "changes stage", "pre_assessment"
include_examples "changes statuses", %w[preliminary_check]
include_examples "changes status", "preliminary_check"

context "when teaching authority provides written statement" do
before do
Expand All @@ -519,15 +412,13 @@
include_examples "changes stage", "pre_assessment"
include_examples "changes statuses",
%w[preliminary_check waiting_on_lops]
include_examples "changes status", "preliminary_check"

context "when the preliminary check has passed" do
before { preliminary_assessment_section.update!(passed: true) }

include_examples "changes action required by", "external"
include_examples "changes stage", "pre_assessment"
include_examples "changes statuses", %w[waiting_on_lops]
include_examples "changes status", "waiting_on"
end

context "when the preliminary check has failed" do
Expand All @@ -543,15 +434,13 @@
include_examples "changes stage", "pre_assessment"
include_examples "changes statuses",
%w[preliminary_check waiting_on_lops]
include_examples "changes status", "preliminary_check"

context "and the application form is declined" do
before { application_form.update!(declined_at: Time.zone.now) }

include_examples "doesn't change action required by"
include_examples "changes stage", "completed"
include_examples "changes statuses", %w[declined]
include_examples "changes status", "declined"
end
end
end
Expand Down

0 comments on commit 0d6dca0

Please sign in to comment.