diff --git a/app/models/automation/condition.rb b/app/models/automation/condition.rb index 1d3a85ff..a69fe3cf 100644 --- a/app/models/automation/condition.rb +++ b/app/models/automation/condition.rb @@ -120,7 +120,8 @@ def content_match?(object, value) if object.pdf? pdf_match?(object.content, value) elsif object.xml? - object.content.match?(value) + # TODO: fix encoding when saving content to DB + Nokogiri::XML(object.content, nil, 'UTF-8').to_s.match?(value) end end diff --git a/test/fixtures/automation/actions.yml b/test/fixtures/automation/actions.yml index c96ba8e3..19406586 100644 --- a/test/fixtures/automation/actions.yml +++ b/test/fixtures/automation/actions.yml @@ -32,3 +32,8 @@ six: automation_rule: five type: Automation::ChangeMessageThreadTitleAction value: "New title - {{title}}" + +seven: + automation_rule: six + type: Automation::AddMessageThreadTagAction + action_object: ssd_crac_success (Tag) diff --git a/test/fixtures/automation/conditions.yml b/test/fixtures/automation/conditions.yml index 2007db80..f52bf788 100644 --- a/test/fixtures/automation/conditions.yml +++ b/test/fixtures/automation/conditions.yml @@ -31,3 +31,8 @@ six: automation_rule: five type: Automation::AttachmentContentContainsCondition value: "Test\\s*string" + +seven: + automation_rule: six + type: Automation::AttachmentContentContainsCondition + value: "úspešne spracovaná" diff --git a/test/fixtures/automation/rules.yml b/test/fixtures/automation/rules.yml index f3d16276..8817dfb8 100644 --- a/test/fixtures/automation/rules.yml +++ b/test/fixtures/automation/rules.yml @@ -29,3 +29,10 @@ five: tenant: ssd name: AttachmentContentContainsCondition trigger_event: message_created + +six: + user: basic + tenant: ssd + name: AttachmentContentContainsCondition2 + trigger_event: message_created + diff --git a/test/fixtures/govbox/messages.yml b/test/fixtures/govbox/messages.yml index 1ba47166..ba8f3801 100644 --- a/test/fixtures/govbox/messages.yml +++ b/test/fixtures/govbox/messages.yml @@ -274,3 +274,28 @@ ssd_general_agenda_with_lorem_pdf: signed: true class: MyClass content: Dummy + +ssd_crac: + message_id: <%= SecureRandom.uuid %> + correlation_id: <%= SecureRandom.uuid %> + edesk_message_id: 100 + delivered_at: <%= DateTime.current %> + edesk_class: TEST + folder: ssd_one + payload: + message_id: <%= SecureRandom.uuid %> + subject: MySubject + sender_name: MySender + sender_uri: MySenderURI + recipient_name: MyRecipient + delivered_at: <%= DateTime.current.to_s %> + original_html: MyHtml + objects: + - name: form + mime_type: application/x-eform-xml + signed: false + class: FORM + content: + Spracovanie požiadavky v registri autentifikačných certifikátov + Žiadosť o zmenu zápisu autentifikačného certifikátu v registri autentifikačných certifikátov bola úspešne spracovaná 29.11.2024 13:00. + diff --git a/test/fixtures/tags.yml b/test/fixtures/tags.yml index b8c4d477..06947b6b 100644 --- a/test/fixtures/tags.yml +++ b/test/fixtures/tags.yml @@ -74,6 +74,12 @@ ssd_print: visible: true tenant: ssd +ssd_crac_success: + name: CRAC vybavené + type: SimpleTag + visible: true + tenant: ssd + ssd_signature_requested: name: Na podpis type: SignatureRequestedTag diff --git a/test/models/automation/rule_test.rb b/test/models/automation/rule_test.rb index 4f01ce7f..0a5b118a 100644 --- a/test/models/automation/rule_test.rb +++ b/test/models/automation/rule_test.rb @@ -68,4 +68,15 @@ class Automation::RuleTest < ActiveSupport::TestCase assert_includes message.thread.tags, tags(:ssd_print) assert_not_includes message.tags, tags(:ssd_print) end + + test 'should run an automation on message created AttachmentContainsConidition AddMessageThreadTagAction' do + govbox_message = govbox_messages(:ssd_crac) + + Govbox::Message.create_message_with_thread!(govbox_message) + travel_to(15.minutes.from_now) { GoodJob.perform_inline } + message = Message.last + + assert_includes message.thread.tags, tags(:ssd_crac_success) + assert_not_includes message.tags, tags(:ssd_crac_success) + end end