Prevent recursion when invoking AI

This can result in stack overflow errors for missing commands.

https://fizzy.37signals.com/5986089/collections/7/cards/1135

Follow up to https://github.com/basecamp/fizzy/pull/766
This commit is contained in:
Jorge Manrubia
2025-07-21 10:23:16 +02:00
parent 7a1b90c0d7
commit 2cd4dd8709
3 changed files with 29 additions and 3 deletions
+11
View File
@@ -25,4 +25,15 @@ class Command::Ai::ParserTest < ActionDispatch::IntegrationTest
assert_equal [ collections(:writebook).id.to_s ], params[:collection_ids]
assert_equal [ tags(:web).id.to_s ], params[:tag_ids]
end
test "if the AI translator emitted an unknown command, this will result in a regular search (not on AI recursion)" do
Command::Ai::Translator.any_instance.stubs(:translate).returns(commands: [ "/missing" ])
command = parse_command "assign @kevin and close"
assert command.commands.one?
search_command = command.commands.first
assert search_command.is_a?(Command::Search)
assert_equal "/missing", search_command.terms
end
end