From 41cf0a8c36401b186699cb444ed40989a8638c84 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Sun, 24 Sep 2023 16:13:52 +0100 Subject: [PATCH] Rename state_changed event_type We're going to rename this to `status_changed` to better represent how we show it to users. --- app/components/timeline_entry/component.rb | 6 +++--- app/models/timeline_event.rb | 13 ++++++++++--- config/locales/components.en.yml | 2 ++ spec/components/timeline_entry_spec.rb | 9 +++++++-- spec/factories/application_forms.rb | 2 +- spec/factories/timeline_events.rb | 2 +- spec/lib/application_form_status_updater_spec.rb | 4 ++-- spec/models/timeline_event_spec.rb | 6 +++--- spec/services/rollback_assessment_spec.rb | 14 +++++++------- spec/services/submit_application_form_spec.rb | 2 +- .../view_timeline_events_spec.rb | 2 +- 11 files changed, 38 insertions(+), 24 deletions(-) diff --git a/app/components/timeline_entry/component.rb b/app/components/timeline_entry/component.rb index d1870d1cd1..e78e4ee1ce 100644 --- a/app/components/timeline_entry/component.rb +++ b/app/components/timeline_entry/component.rb @@ -41,16 +41,16 @@ def description_vars private - def state_changed_vars + def status_changed_vars { - old_state: + old_status: render( StatusTag::Component.new( status: timeline_event.old_state, class_context: "timeline-event", ), ).strip, - new_state: + new_status: render( StatusTag::Component.new( status: timeline_event.new_state, diff --git a/app/models/timeline_event.rb b/app/models/timeline_event.rb index c41481fde2..b3d3940f73 100644 --- a/app/models/timeline_event.rb +++ b/app/models/timeline_event.rb @@ -75,7 +75,7 @@ class TimelineEvent < ApplicationRecord requestable_received: "requestable_received", requestable_requested: "requestable_requested", reviewer_assigned: "reviewer_assigned", - state_changed: "state_changed", + status_changed: "status_changed", } validates :creator, presence: true, unless: -> { creator_name.present? } @@ -152,11 +152,18 @@ class TimelineEvent < ApplicationRecord validates :old_value, :new_value, presence: true, - if: -> { action_required_by_changed? || information_changed? } + if: -> do + action_required_by_changed? || assessment_section_recorded? || + information_changed? || status_changed? + end validates :old_value, :new_value, absence: true, - unless: -> { action_required_by_changed? || information_changed? } + unless: -> do + action_required_by_changed? || assessment_section_recorded? || + information_changed? || status_changed? + end + validates :column_name, presence: true, if: :information_changed? validates :work_history_id, :column_name, diff --git a/config/locales/components.en.yml b/config/locales/components.en.yml index 399f9249f9..b3b190bd28 100644 --- a/config/locales/components.en.yml +++ b/config/locales/components.en.yml @@ -68,6 +68,7 @@ en: QualificationRequest: Qualification assessed ReferenceRequest: Reference assessed information_changed: Information changed after submission + status_changed: Status changed description: action_required_by_changed: Application requires %{action} action. assessor_assigned: "%{assignee_name} is assigned as the assessor." @@ -95,6 +96,7 @@ en: ProfessionalStandingRequest: The professional standing request has been assessed. QualificationRequest: A qualification has been assessed. ReferenceRequest: A reference has been assessed. + status_changed: Status changed from %{old_status} to %{new_status}. columns: contact_email: Reference email address contact_job: Reference job diff --git a/spec/components/timeline_entry_spec.rb b/spec/components/timeline_entry_spec.rb index 5b8d9692da..3ef3c9f903 100644 --- a/spec/components/timeline_entry_spec.rb +++ b/spec/components/timeline_entry_spec.rb @@ -8,7 +8,12 @@ context "with a creator name" do let(:timeline_event) do - create(:timeline_event, :state_changed, creator_name: "DQT", creator: nil) + create( + :timeline_event, + :status_changed, + creator_name: "DQT", + creator: nil, + ) end it "describes the event" do @@ -50,7 +55,7 @@ let(:timeline_event) do create( :timeline_event, - :state_changed, + :status_changed, old_state: "submitted", new_state: "awarded", ) diff --git a/spec/factories/application_forms.rb b/spec/factories/application_forms.rb index 31f30f0b19..0ce06cad22 100644 --- a/spec/factories/application_forms.rb +++ b/spec/factories/application_forms.rb @@ -149,7 +149,7 @@ after(:create) do |application_form, _evaluator| create( :timeline_event, - :state_changed, + :status_changed, application_form:, creator: application_form.teacher, old_state: "draft", diff --git a/spec/factories/timeline_events.rb b/spec/factories/timeline_events.rb index d9a2af715f..38a894c20a 100644 --- a/spec/factories/timeline_events.rb +++ b/spec/factories/timeline_events.rb @@ -66,7 +66,7 @@ association :assignee, factory: :staff end - trait :state_changed do + trait :status_changed do event_type { "state_changed" } old_state { ApplicationForm.statuses.keys.sample } new_state { ApplicationForm.statuses.keys.sample } diff --git a/spec/lib/application_form_status_updater_spec.rb b/spec/lib/application_form_status_updater_spec.rb index 45e05b8a41..b8c192a7c7 100644 --- a/spec/lib/application_form_status_updater_spec.rb +++ b/spec/lib/application_form_status_updater_spec.rb @@ -47,7 +47,7 @@ it "records a timeline event" do expect { call }.to have_recorded_timeline_event( - :state_changed, + :status_changed, creator: user, application_form:, old_state: "draft", @@ -398,7 +398,7 @@ end it "doesn't record a timeline event" do - expect { call }.to_not have_recorded_timeline_event(:state_changed) + expect { call }.to_not have_recorded_timeline_event(:status_changed) end include_examples "doesn't change action required by" diff --git a/spec/models/timeline_event_spec.rb b/spec/models/timeline_event_spec.rb index 2f4bea97c9..52e8de282a 100644 --- a/spec/models/timeline_event_spec.rb +++ b/spec/models/timeline_event_spec.rb @@ -91,7 +91,7 @@ requestable_received: "requestable_received", requestable_requested: "requestable_requested", reviewer_assigned: "reviewer_assigned", - state_changed: "state_changed", + status_changed: "status_changed", ).backed_by_column_of_type(:string) end @@ -141,8 +141,8 @@ it { is_expected.to validate_absence_of(:new_value) } end - context "with a state changed event type" do - before { timeline_event.event_type = :state_changed } + context "with a status changed event type" do + before { timeline_event.event_type = :status_changed } it { is_expected.to validate_absence_of(:assignee) } it { is_expected.to validate_presence_of(:old_state) } diff --git a/spec/services/rollback_assessment_spec.rb b/spec/services/rollback_assessment_spec.rb index b27d974be0..406958ee3f 100644 --- a/spec/services/rollback_assessment_spec.rb +++ b/spec/services/rollback_assessment_spec.rb @@ -24,7 +24,7 @@ it "records a timeline event" do expect { call }.to have_recorded_timeline_event( - :state_changed, + :status_changed, creator: user, ) end @@ -45,7 +45,7 @@ it "records a timeline event" do expect { call }.to have_recorded_timeline_event( - :state_changed, + :status_changed, creator: user, ) end @@ -62,7 +62,7 @@ it "records a timeline event" do expect { call }.to have_recorded_timeline_event( - :state_changed, + :status_changed, creator: user, ) end @@ -86,7 +86,7 @@ it "records a timeline event" do expect { call }.to have_recorded_timeline_event( - :state_changed, + :status_changed, creator: user, ) end @@ -107,7 +107,7 @@ it "records a timeline event" do expect { call }.to have_recorded_timeline_event( - :state_changed, + :status_changed, creator: user, ) end @@ -124,7 +124,7 @@ it "records a timeline event" do expect { call }.to have_recorded_timeline_event( - :state_changed, + :status_changed, creator: user, ) end @@ -169,7 +169,7 @@ it "records a timeline event" do expect { call }.to have_recorded_timeline_event( - :state_changed, + :status_changed, creator: user, ) end diff --git a/spec/services/submit_application_form_spec.rb b/spec/services/submit_application_form_spec.rb index 8b92c5e395..1e609aa1e0 100644 --- a/spec/services/submit_application_form_spec.rb +++ b/spec/services/submit_application_form_spec.rb @@ -61,7 +61,7 @@ it "records a timeline event" do expect { call }.to have_recorded_timeline_event( - :state_changed, + :status_changed, creator: user, application_form:, old_state: "draft", diff --git a/spec/system/assessor_interface/view_timeline_events_spec.rb b/spec/system/assessor_interface/view_timeline_events_spec.rb index a14eee26aa..f741945d02 100644 --- a/spec/system/assessor_interface/view_timeline_events_spec.rb +++ b/spec/system/assessor_interface/view_timeline_events_spec.rb @@ -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, :state_changed, application_form:) + create(:timeline_event, :status_changed, application_form:) create(:timeline_event, :note_created, application_form:) application_form end