From 2dc34b61d22ac7e7a15ec2c656e84ecc66d78cca 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/lib/application_form_status_updater.rb | 2 +- app/models/timeline_event.rb | 7 ++++--- config/locales/components.en.yml | 4 ++-- spec/components/timeline_entry_spec.rb | 9 +++++++-- spec/factories/application_forms.rb | 2 +- spec/factories/timeline_events.rb | 4 ++-- 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 +- 12 files changed, 34 insertions(+), 28 deletions(-) diff --git a/app/components/timeline_entry/component.rb b/app/components/timeline_entry/component.rb index 58121b0198..f4677f26d8 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/lib/application_form_status_updater.rb b/app/lib/application_form_status_updater.rb index 34466c9921..ea1773f595 100644 --- a/app/lib/application_form_status_updater.rb +++ b/app/lib/application_form_status_updater.rb @@ -28,7 +28,7 @@ def call if (old_status = application_form.status) != status application_form.update!(status:) create_timeline_event( - event_type: "state_changed", + event_type: "status_changed", old_state: old_status, new_state: status, ) diff --git a/app/models/timeline_event.rb b/app/models/timeline_event.rb index 8ffb896733..7543a0654b 100644 --- a/app/models/timeline_event.rb +++ b/app/models/timeline_event.rb @@ -76,7 +76,7 @@ class TimelineEvent < ApplicationRecord requestable_requested: "requestable_requested", reviewer_assigned: "reviewer_assigned", stage_changed: "stage_changed", - state_changed: "state_changed", + status_changed: "status_changed", } validates :creator, presence: true, unless: -> { creator_name.present? } @@ -93,11 +93,11 @@ class TimelineEvent < ApplicationRecord validates :old_state, :new_state, presence: true, - if: -> { state_changed? || assessment_section_recorded? } + if: -> { status_changed? || assessment_section_recorded? } validates :old_state, :new_state, absence: true, - unless: -> { state_changed? || assessment_section_recorded? } + unless: -> { status_changed? || assessment_section_recorded? } validates :assessment_section, presence: true, @@ -164,6 +164,7 @@ class TimelineEvent < ApplicationRecord action_required_by_changed? || information_changed? || stage_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 adafbdb5e5..ed4146c428 100644 --- a/config/locales/components.en.yml +++ b/config/locales/components.en.yml @@ -72,7 +72,7 @@ en: QualificationRequest: Qualification assessed ReferenceRequest: Reference assessed stage_changed: Stage changed - state_changed: Status changed + status_changed: Status changed description: action_required_by_changed: Application requires %{action} action. assessor_assigned: "%{assignee_name} is assigned as the assessor." @@ -100,7 +100,7 @@ en: QualificationRequest: A qualification has been assessed. ReferenceRequest: A reference has been assessed. stage_changed: Stage changed from %{old_stage} to %{new_stage}. - state_changed: Status changed from %{old_state} to %{new_state}. + 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 051a83ef7d..2ff368c7bb 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 b2023353ec..43a10b5370 100644 --- a/spec/factories/application_forms.rb +++ b/spec/factories/application_forms.rb @@ -185,7 +185,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 89c356e78e..1dccde3e2e 100644 --- a/spec/factories/timeline_events.rb +++ b/spec/factories/timeline_events.rb @@ -66,8 +66,8 @@ association :assignee, factory: :staff end - trait :state_changed do - event_type { "state_changed" } + trait :status_changed do + event_type { "status_changed" } old_state { ApplicationForm.statuses.keys.sample } new_state { ApplicationForm.statuses.keys.sample } end diff --git a/spec/lib/application_form_status_updater_spec.rb b/spec/lib/application_form_status_updater_spec.rb index 2d785a1a9b..67c62d4d46 100644 --- a/spec/lib/application_form_status_updater_spec.rb +++ b/spec/lib/application_form_status_updater_spec.rb @@ -63,7 +63,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", @@ -433,7 +433,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 it "doesn't change the stage from draft" do expect { call }.to_not change(application_form, :stage).from("draft") diff --git a/spec/models/timeline_event_spec.rb b/spec/models/timeline_event_spec.rb index 7325614cb2..8b978dec4e 100644 --- a/spec/models/timeline_event_spec.rb +++ b/spec/models/timeline_event_spec.rb @@ -92,7 +92,7 @@ requestable_requested: "requestable_requested", reviewer_assigned: "reviewer_assigned", stage_changed: "stage_changed", - state_changed: "state_changed", + status_changed: "status_changed", ).backed_by_column_of_type(:string) end @@ -142,8 +142,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