Add /reopen command

This commit is contained in:
Jorge Manrubia
2025-07-03 13:47:10 +02:00
parent a2ca8b1dc0
commit ac2400a657
30 changed files with 245525 additions and 14 deletions
+10 -2
View File
@@ -48,8 +48,6 @@ class Command::Ai::TranslatorTest < ActionDispatch::IntegrationTest
assert_command({ context: { terms: [ "123" ] } }, "123") # Notice existing cards will be intercepted earlier
end
vcr_record!
test "acts on cards passing their ids" do
assert_command({ context: { card_ids: [ 123, 456 ] }, commands: [ "/close" ] }, "close 123 and 456")
assert_command({ context: { card_ids: [ 123 ] }, commands: [ "/close" ] }, "close 123")
@@ -70,6 +68,16 @@ class Command::Ai::TranslatorTest < ActionDispatch::IntegrationTest
assert_command({ commands: [ "/close" ] }, "close", context: :card)
end
test "reopen cards" do
# List context
assert_command({ commands: [ "/reopen" ] }, "reopen")
assert_command({ context: { assignee_ids: [ "jz" ] }, commands: [ "/reopen" ] }, "reopen cards assigned to jz")
assert_command({ context: { closure: "thisweek", indexed_by: "closed" }, commands: [ "/reopen" ] }, "reopen cards closed this week")
# Card context
assert_command({ commands: [ "/reopen" ] }, "reopen", context: :card)
end
test "assign cards" do
# List context
assert_command({ commands: [ "/assign jz" ] }, "assign to jz")
+42
View File
@@ -0,0 +1,42 @@
require "test_helper"
class Command::ReopenTest < ActionDispatch::IntegrationTest
include CommandTestHelper
setup do
Current.session = sessions(:david)
@card = cards(:text)
@card.close(user: users(:david))
end
test "reopen card on perma" do
assert_changes -> { @card.reload.open? }, from: false, to: true do
execute_command "/reopen", context_url: collection_card_url(@card.collection, @card)
end
assert_nil @card.closed_by
end
test "reopen cards on cards' index page" do
cards = cards(:logo, :text, :layout)
cards.each { |card| card.close }
execute_command "/reopen", context_url: collection_cards_url(@card.collection, indexed_by: "closed")
assert cards.map(&:reload).all?(&:open?)
end
test "undo reopen" do
cards = cards(:logo, :text, :layout)
cards.each { |card| card.close(user: users(:david)) }
command = parse_command "/reopen", context_url: collection_cards_url(@card.collection, indexed_by: "closed")
command.execute
assert cards.map(&:reload).all?(&:open?)
command.undo
assert cards.map(&:reload).all?(&:closed?)
end
end