Test workflowing updates card stages on change

This commit is contained in:
David Heinemeier Hansson
2025-04-22 13:03:31 +02:00
parent a7d17b38aa
commit 8e35a3de9c
3 changed files with 15 additions and 3 deletions
+4
View File
@@ -1,6 +1,7 @@
logo:
collection: writebook
creator: david
stage: qa_triage
title: The logo isn't big enough
due_on: <%= 3.days.from_now %>
created_at: <%= 1.week.ago %>
@@ -10,6 +11,7 @@ logo:
layout:
collection: writebook
creator: david
stage: qa_triage
title: Layout is broken
created_at: <%= 1.week.ago %>
status: published
@@ -18,6 +20,7 @@ layout:
text:
collection: writebook
creator: kevin
stage: qa_triage
title: The text is too small
created_at: <%= 1.week.ago %>
status: published
@@ -27,6 +30,7 @@ text:
shipping:
collection: writebook
creator: kevin
stage: qa_triage
title: We need to ship the app
created_at: <%= 1.week.ago %>
status: published
@@ -0,0 +1,8 @@
require "test_helper"
class Collection::WorkflowingTest < ActiveSupport::TestCase
test "change all card stages when changing workflow" do
collections(:writebook).update! workflow: workflows(:on_call)
assert_equal [ collections(:writebook).initial_workflow_stage ], collections(:writebook).cards.reload.collect(&:stage).uniq
end
end
+3 -3
View File
@@ -5,11 +5,11 @@ class FilterTest < ActiveSupport::TestCase
Current.set session: sessions(:david) do
@new_collection = Collection.create! name: "Inaccessible Collection"
@new_card = @new_collection.cards.create!
@new_card.update!(stage: workflow_stages(:qa_triage))
@new_card.update!(stage: workflow_stages(:qa_on_hold))
cards(:layout).capture Comment.new(body: "I hate haggis")
cards(:logo).capture Comment.new(body: "I love haggis")
cards(:logo).update(stage: workflow_stages(:qa_triage))
cards(:logo).update(stage: workflow_stages(:qa_on_hold))
end
assert_not_includes users(:kevin).filters.new.cards, @new_card
@@ -17,7 +17,7 @@ class FilterTest < ActiveSupport::TestCase
filter = users(:david).filters.new creator_ids: [ users(:david).id ], tag_ids: [ tags(:mobile).id ]
assert_equal [ cards(:layout) ], filter.cards
filter = users(:david).filters.new stage_ids: [ workflow_stages(:qa_triage).id ]
filter = users(:david).filters.new stage_ids: [ workflow_stages(:qa_on_hold).id ]
assert_equal [ cards(:logo), @new_card ], filter.cards
filter = users(:david).filters.new assignment_status: "unassigned", collection_ids: [ @new_collection.id ]