Skip to content

Commit

Permalink
Merge pull request #547 from slovensko-digital/GO-181/add_inbox_tag_t…
Browse files Browse the repository at this point in the history
…o_new_fs_messages_too

GO-181 Add Inbox Tag to thread when new FS inbox message is processed
  • Loading branch information
luciajanikova authored Feb 6, 2025
2 parents 1d9fd22 + 7de9c57 commit dedaf1b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/fs/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def self.create_inbox_message_with_thread!(raw_message, box:)
message = create_inbox_message(raw_message)

message.thread = associated_outbox_message.thread
message.thread.assign_tag(message.thread.tenant.inbox_tag)

message.save!

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ fs_accountants_outbox:
replyable: false
metadata:
fs_message_id: 1234/2024
correlation_id: 4bc972bb-9364-47de-bb40-23720f24a4ab
author: accountants_basic

solver_main_delivery_notification_one:
Expand Down
49 changes: 48 additions & 1 deletion test/models/fs/message_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require "active_support/all"

class Fs::MessageTest < ActiveSupport::TestCase
test "#create_inbox_messages creates new message with delivered_at and fs_submission_created_at values in same format" do
test "#create_inbox_message creates new message with delivered_at and fs_submission_created_at values in same format" do
raw_message = {
"created_at" => "2024-06-05T10:27:03.105Z",
"message_id" => "12345689/2024",
Expand Down Expand Up @@ -51,4 +51,51 @@ class Fs::MessageTest < ActiveSupport::TestCase
assert_equal '2024-06-05 12:27:03 +0200', message.delivered_at.to_s
assert_equal '2024-06-05T12:27:01.433+02:00', message.metadata['fs_submission_created_at']
end

test "#create_inbox_message_with_thread handles adding inbox tag to thread" do
raw_message = {
"created_at" => "2024-06-05T10:27:03.105Z",
"message_id" => "12345689/2024",
"submission_type_id" => "3079",
"submission_type_name" => "Podanie pre FS (Správa daní) – späťvzatie žiadosti",
"message_type_id" => "DRSR_POPP_v02",
"message_type_name" => "Informácia o podaní",
"sent_message_id" => "1234/2024",
"seen" => true,
"is_ekr2" => true,
"status" => "Vybavená",
"submission_status" => "Prijaté a potvrdené",
"dic" => "1122222333",
"subject" => "xy",
"submitting_subject" => "xy",
"submission_created_at" => "2024-06-05T10:27:01.433Z",
"period" => nil,
"dismissal_reason" => nil,
"message_container" =>
{
"message_id" => SecureRandom.uuid,
"sender_id" => "FSSR",
"recipient_id" => "1122222333",
"message_type" => "ED.DeliveryReport",
"subject" => "x",
"objects" => [
{
"class" => "FORM",
"description" => "DeliveryReport",
"encoding" => "XML",
"id" => SecureRandom.uuid,
"signed" => true,
"mime_type" => "application/xml",
"name" => "DeliveryReport",
"content" =>
"<content>xy</content>"
}
]
}
}

Fs::Message.create_inbox_message_with_thread!(raw_message, box: boxes(:fs_accountants))

assert Message.last.thread.tags.include?(tags(:accountants_inbox))
end
end

0 comments on commit dedaf1b

Please sign in to comment.