Skip to content

Commit

Permalink
WIP: fix unassign notification job specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Flink committed Oct 18, 2023
1 parent 08ac787 commit 840f278
Showing 1 changed file with 10 additions and 26 deletions.
36 changes: 10 additions & 26 deletions spec/jobs/regular/unassign_notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,19 @@ def assert_publish_topic_state(topic, user)
end

describe "User" do
it "deletes notifications" do
Jobs::AssignNotification.new.execute(
{
topic_id: topic.id,
post_id: post.id,
assigned_to_id: user2.id,
assigned_to_type: "User",
assigned_by_id: user1.id,
skip_small_action_post: false,
assignment_id: 4519,
},
)
fab!(:assignment) { Fabricate(:topic_assignment, topic: topic, assigned_to: user2) }

before { assignment.create_missing_notifications! }

it "deletes notifications" do
expect {
described_class.new.execute(
{
topic_id: topic.id,
post_id: post.id,
assigned_to_id: user2.id,
assigned_to_type: "User",
assignment_id: 4519,
assignment_id: assignment.id,
},
)
}.to change { user2.notifications.count }.by(-1)
Expand Down Expand Up @@ -70,33 +62,25 @@ def assert_publish_topic_state(topic, user)
fab!(:assign_allowed_group) { Group.find_by(name: "staff") }
fab!(:user3) { Fabricate(:user) }
fab!(:group) { Fabricate(:group) }
fab!(:assignment) do
Fabricate(:topic_assignment, topic: topic, assigned_to: group, assigned_by_user: user1)
end

before do
group.add(user2)
group.add(user3)
assignment.create_missing_notifications!
end

it "deletes notifications" do
Jobs::AssignNotification.new.execute(
{
topic_id: topic.id,
post_id: post.id,
assigned_to_id: group.id,
assigned_to_type: "Group",
assigned_by_id: user1.id,
skip_small_action_post: false,
assignment_id: 9281,
},
)

expect {
described_class.new.execute(
{
topic_id: topic.id,
post_id: post.id,
assigned_to_id: group.id,
assigned_to_type: "Group",
assignment_id: 9281,
assignment_id: assignment.id,
},
)
}.to change { Notification.count }.by(-2)
Expand Down

0 comments on commit 840f278

Please sign in to comment.