Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove status transition of paused => cancelling #434

Merged
merged 1 commit into from Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/validators/maintenance_tasks/run_status_validator.rb
Expand Up @@ -48,9 +48,8 @@ class RunStatusValidator < ActiveModel::Validator
"errored",
],
# paused -> enqueued occurs when the task is resumed after being paused.
# paused -> cancelling when the user cancels the task after it is paused.
# paused -> cancelled when the user cancels the task after it is paused.
"paused" => ["enqueued", "cancelling", "cancelled"],
"paused" => ["enqueued", "cancelled"],
# interrupted -> running occurs when the task is resumed after being
# interrupted by the job infrastructure.
# interrupted -> pausing occurs when the task is paused by the user while
Expand Down
12 changes: 2 additions & 10 deletions test/validators/maintenance_tasks/run_status_validator_test.rb
Expand Up @@ -63,7 +63,7 @@ class RunStatusValidatorTest < ActiveSupport::TestCase
)
end

test "run can go from enqueued, running, interrupted, pausing, or paused to cancelling" do
test "run can go from enqueued, running, interrupted, or pausing to cancelling" do
enqueued_run = Run.create!(task_name: "Maintenance::UpdatePostsTask")
enqueued_run.status = :cancelling

Expand Down Expand Up @@ -93,16 +93,8 @@ class RunStatusValidatorTest < ActiveSupport::TestCase

assert pausing_run.valid?

paused_run = Run.create!(
task_name: "Maintenance::UpdatePostsTask",
status: :paused
)
paused_run.status = :cancelling

assert paused_run.valid?

assert_no_invalid_transitions(
[:enqueued, :running, :interrupted, :pausing, :paused],
[:enqueued, :running, :interrupted, :pausing],
:cancelling
)
end
Expand Down