DEV: Add test when user is suspended (#219)
This commit is contained in:
parent
58315230f0
commit
247c74ecfd
|
@ -64,12 +64,14 @@ RSpec.describe Jobs::AssignNotification do
|
|||
|
||||
context 'Group' do
|
||||
fab!(:user3) { Fabricate(:user) }
|
||||
fab!(:user4) { Fabricate(:user, suspended_till: 1.year.from_now) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
let(:assignment) { Assignment.create!(topic: topic, assigned_by_user: user1, assigned_to: group) }
|
||||
|
||||
before do
|
||||
group.add(user2)
|
||||
group.add(user3)
|
||||
group.add(user4)
|
||||
end
|
||||
|
||||
it 'sends notification alert to all group members' do
|
||||
|
@ -84,24 +86,18 @@ RSpec.describe Jobs::AssignNotification do
|
|||
end
|
||||
expect(messages.length).to eq(1)
|
||||
expect(messages.first.data[:excerpt]).to eq("assigned you the topic '#{topic.title}'")
|
||||
|
||||
messages = MessageBus.track_publish("/notification-alert/#{user4.id}") do
|
||||
described_class.new.execute({ topic_id: topic.id, assigned_to_id: group.id, assigned_to_type: 'Group', assigned_by_id: user1.id, silent: false })
|
||||
end
|
||||
expect(messages.length).to eq(0)
|
||||
end
|
||||
|
||||
it 'sends a high priority notification to all group members' do
|
||||
[user2, user3, user4].each do |user|
|
||||
Notification.expects(:create!).with(
|
||||
notification_type: Notification.types[:custom],
|
||||
user_id: user2.id,
|
||||
topic_id: topic.id,
|
||||
post_number: 1,
|
||||
high_priority: true,
|
||||
data: {
|
||||
message: 'discourse_assign.assign_group_notification',
|
||||
display_username: group.name,
|
||||
topic_title: topic.title
|
||||
}.to_json
|
||||
)
|
||||
Notification.expects(:create!).with(
|
||||
notification_type: Notification.types[:custom],
|
||||
user_id: user3.id,
|
||||
user_id: user.id,
|
||||
topic_id: topic.id,
|
||||
post_number: 1,
|
||||
high_priority: true,
|
||||
|
@ -111,6 +107,8 @@ RSpec.describe Jobs::AssignNotification do
|
|||
topic_title: topic.title
|
||||
}.to_json
|
||||
)
|
||||
end
|
||||
|
||||
described_class.new.execute({ topic_id: topic.id, assigned_to_id: group.id, assigned_to_type: 'Group', assigned_by_id: user1.id, silent: false })
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue