Test and fix setting workflow to nothing

This commit is contained in:
David Heinemeier Hansson
2025-04-22 13:05:39 +02:00
parent 8e35a3de9c
commit 5ea0ec8cb4
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -13,6 +13,6 @@ module Collection::Workflowing
private
def set_all_cards_to_initial_workflow_stage
cards.update_all(stage_id: initial_workflow_stage.id)
cards.update_all(stage_id: initial_workflow_stage&.id)
end
end
@@ -5,4 +5,9 @@ class Collection::WorkflowingTest < ActiveSupport::TestCase
collections(:writebook).update! workflow: workflows(:on_call)
assert_equal [ collections(:writebook).initial_workflow_stage ], collections(:writebook).cards.reload.collect(&:stage).uniq
end
test "remove stage from cards if workflow is removed" do
collections(:writebook).update! workflow: nil
assert_equal [], collections(:writebook).cards.reload.collect(&:stage).compact
end
end