mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Improve assertions for spec.
This was showing up as a flaky spec.
This commit is contained in:
parent
73c750a1db
commit
31652c1ad3
@ -108,30 +108,44 @@ describe PostAlerter do
|
|||||||
post = Fabricate(:post, raw: 'I love waffles')
|
post = Fabricate(:post, raw: 'I love waffles')
|
||||||
|
|
||||||
admin = Fabricate(:admin)
|
admin = Fabricate(:admin)
|
||||||
post.revise(admin, raw: 'I made a revision')
|
|
||||||
|
expect do
|
||||||
|
post.revise(admin, raw: 'I made a revision')
|
||||||
|
end.to add_notification(post.user, :edited)
|
||||||
|
|
||||||
# lets also like this post which should trigger a notification
|
# lets also like this post which should trigger a notification
|
||||||
PostActionCreator.new(
|
expect do
|
||||||
admin,
|
PostActionCreator.new(
|
||||||
post,
|
admin,
|
||||||
PostActionType.types[:like]
|
post,
|
||||||
).perform
|
PostActionType.types[:like]
|
||||||
|
).perform
|
||||||
|
end.to add_notification(post.user, :liked)
|
||||||
|
|
||||||
# skip this notification cause we already notified on an edit by the same user
|
# skip this notification cause we already notified on an edit by the same user
|
||||||
# in the previous edit
|
# in the previous edit
|
||||||
freeze_time 2.hours.from_now
|
freeze_time 2.hours.from_now
|
||||||
post.revise(admin, raw: 'I made another revision')
|
|
||||||
|
expect do
|
||||||
|
post.revise(admin, raw: 'I made another revision')
|
||||||
|
end.to_not change { Notification.count }
|
||||||
|
|
||||||
# this we do not skip cause 1 day has passed
|
# this we do not skip cause 1 day has passed
|
||||||
freeze_time 23.hours.from_now
|
freeze_time 23.hours.from_now
|
||||||
post.revise(admin, raw: 'I made another revision xyz')
|
|
||||||
|
|
||||||
post.revise(Fabricate(:admin), raw: 'I made a revision')
|
expect do
|
||||||
|
post.revise(admin, raw: 'I made another revision xyz')
|
||||||
|
end.to add_notification(post.user, :edited)
|
||||||
|
|
||||||
|
expect do
|
||||||
|
post.revise(Fabricate(:admin), raw: 'I made a revision')
|
||||||
|
end.to add_notification(post.user, :edited)
|
||||||
|
|
||||||
freeze_time 2.hours.from_now
|
freeze_time 2.hours.from_now
|
||||||
post.revise(admin, raw: 'I made another revision')
|
|
||||||
|
|
||||||
expect(Notification.where(post_number: 1, topic_id: post.topic_id).count).to eq(5)
|
expect do
|
||||||
|
post.revise(admin, raw: 'I made another revision')
|
||||||
|
end.to add_notification(post.user, :edited)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'notifies flaggers when flagged post gets unhidden by edit' do
|
it 'notifies flaggers when flagged post gets unhidden by edit' do
|
||||||
|
Loading…
Reference in New Issue
Block a user