Add stage command to assign workflows to cards

This commit is contained in:
Jorge Manrubia
2025-06-26 00:42:17 +02:00
parent 6f015feee6
commit 0765116779
20 changed files with 8888 additions and 1 deletions
@@ -82,6 +82,11 @@ class Command::Ai::TranslatorTest < ActionDispatch::IntegrationTest
assert_command({ commands: [ "/do" ] }, "move to doing")
end
test "assign stages to card" do
assert_command({ commands: [ "/stage in progress" ] }, "move to stage in progress")
assert_command({ commands: [ "/stage in progress" ] }, "move to in progress")
end
test "combine commands and filters" do
assert_command({ context: { assignee_ids: [ "jz" ], tag_ids: [ "design" ] }, commands: [ "/assign andy", "/tag #v2" ] }, "assign andy to the current #design cards assigned to jz and tag them with #v2")
assert_command({ context: { assignee_ids: [ "andy" ] }, commands: [ "/close", "/assign kevin" ] }, "close cards assigned to andy and assign them to kevin")
+47
View File
@@ -0,0 +1,47 @@
require "test_helper"
class Command::StageTest < ActionDispatch::IntegrationTest
include CommandTestHelper
setup do
Current.session = sessions(:david)
@card = cards(:text)
@new_stage = workflow_stages(:qa_review)
@original_stage = @card.stage
end
test "move card to a new stage on perma" do
assert_changes -> { @card.reload.stage }, from: @original_stage, to: @new_stage do
execute_command "/stage #{@new_stage.name}", context_url: collection_card_url(@card.collection, @card)
end
end
test "move cards on cards' index page" do
cards = [cards(:logo), cards(:layout), cards(:text)]
execute_command "/stage #{@new_stage.name}", context_url: collection_cards_url(@card.collection)
cards.each do |card|
assert_equal @new_stage, card.reload.stage
end
end
test "undo stage change" do
cards = [cards(:logo), cards(:layout), cards(:text)]
cards.each { it.change_stage_to @original_stage }
command = parse_command "/stage #{@new_stage.name}", context_url: collection_cards_url(@card.collection)
command.execute
cards.each do |card|
assert_equal @new_stage, card.reload.stage
end
command.undo
# Verify cards moved back to original stages
cards.each do |card|
assert_equal @original_stage, card.reload.stage
end
end
end