Skip to content

Commit

Permalink
Merge pull request #228 from solver-it-sro/bugfix/fix-delivery-notifi…
Browse files Browse the repository at this point in the history
…cation-tag-creation

Bugfix/fix delivery notification tag creation
  • Loading branch information
jsuchal authored Dec 5, 2023
2 parents 11e0361 + 3c99795 commit 17b6ebe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/models/upvs/delivery_notification_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Upvs::DeliveryNotificationTag < ::Tag
def self.find_or_create_for_tenant!(tenant)
find_or_create_by!(
type: self.to_s,
tenant_id: tenant
tenant: tenant
) do |tag|
tag.name = "Na prevzatie"
tag.visible = true
Expand Down
12 changes: 0 additions & 12 deletions test/fixtures/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ ssd_other:
visible: true
tenant: ssd

ssd_delivery_notification:
name: Na prevzatie
type: Upvs::DeliveryNotificationTag
visible: true
tenant: ssd

ssd_construction:
name: Construction
type: SimpleTag
Expand Down Expand Up @@ -79,9 +73,3 @@ solver_drafts:
type: DraftTag
visible: true
tenant: solver

solver_delivery_notification:
name: Na prevzatie
type: Upvs::DeliveryNotificationTag
visible: true
tenant: solver
9 changes: 9 additions & 0 deletions test/jobs/govbox/process_message_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ class Govbox::ProcessMessageJobTest < ActiveJob::TestCase

assert outbox_message.reload.collapsed?
end

test "successfully processes a delivery notification" do
inbox_govbox_message = govbox_messages(:solver_delivery_notification)
Govbox::ProcessMessageJob.new.perform(inbox_govbox_message)

message = Message.find_by_uuid(inbox_govbox_message.payload["message_id"])

assert message
end
end
15 changes: 10 additions & 5 deletions test/models/message_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ class MessageTest < ActiveSupport::TestCase
end

test "remove_cascade_tag method should delete tag from message and also message thread if no more messages with the tag" do
message = messages(:solver_main_delivery_notification_one)
tag = tags(:solver_delivery_notification)
message = messages(:ssd_main_general_one)
tag = tags(:ssd_finance)

message.add_cascading_tag(tag)

assert message.tags.include?(tag)
assert message.thread.tags.include?(tag)

message.remove_cascading_tag(tag)

assert_equal message.tags.include?(tag), false
assert_equal message.thread.tags.include?(tag), false
assert_not message.tags.include?(tag)
assert_not message.thread.tags.include?(tag)
end

test "remove_cascade_tag method should delete tag from message and keep it on message thread if more messages with the tag" do
Expand All @@ -27,7 +32,7 @@ class MessageTest < ActiveSupport::TestCase

message.remove_cascading_tag(tag)

assert_equal message.tags.include?(tag), false
assert_not message.tags.include?(tag)
assert message.thread.tags.include?(tag)
end
end

0 comments on commit 17b6ebe

Please sign in to comment.