Skip to content

Commit

Permalink
Rename state_changed event_type
Browse files Browse the repository at this point in the history
We're going to rename this to `status_changed` to better represent how
we show it to users.
  • Loading branch information
thomasleese committed Sep 27, 2023
1 parent 5af0a28 commit 41cf0a8
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 24 deletions.
6 changes: 3 additions & 3 deletions app/components/timeline_entry/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 10 additions & 3 deletions app/models/timeline_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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? }
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions config/locales/components.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions spec/components/timeline_entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,7 +55,7 @@
let(:timeline_event) do
create(
:timeline_event,
:state_changed,
:status_changed,
old_state: "submitted",
new_state: "awarded",
)
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/application_forms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/timeline_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/application_form_status_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions spec/models/timeline_event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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) }
Expand Down
14 changes: 7 additions & 7 deletions spec/services/rollback_assessment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
:state_changed,
:status_changed,
creator: user,
)
end
Expand All @@ -45,7 +45,7 @@

it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
:state_changed,
:status_changed,
creator: user,
)
end
Expand All @@ -62,7 +62,7 @@

it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
:state_changed,
:status_changed,
creator: user,
)
end
Expand All @@ -86,7 +86,7 @@

it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
:state_changed,
:status_changed,
creator: user,
)
end
Expand All @@ -107,7 +107,7 @@

it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
:state_changed,
:status_changed,
creator: user,
)
end
Expand All @@ -124,7 +124,7 @@

it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
:state_changed,
:status_changed,
creator: user,
)
end
Expand Down Expand Up @@ -169,7 +169,7 @@

it "records a timeline event" do
expect { call }.to have_recorded_timeline_event(
:state_changed,
:status_changed,
creator: user,
)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/services/submit_application_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41cf0a8

Please sign in to comment.