Add test to ensure creation of like notification in a PM.

This commit is contained in:
Vikhyat Korrapati 2014-03-06 19:04:14 +05:30
parent 9f2b48014c
commit 944246f4af
2 changed files with 13 additions and 2 deletions

View File

@ -37,7 +37,6 @@ class PostAlertObserver < ActiveRecord::Observer
post = post_action.post
return if post_action.user.blank?
return if post.topic.private_message?
create_notification(post.user,
Notification.types[:liked],

View File

@ -96,7 +96,11 @@ describe PostAlertObserver do
context 'private message' do
let(:user) { Fabricate(:user) }
let(:mention_post) { Fabricate(:post, user: user, raw: 'Hello @eviltrout')}
let(:topic) { mention_post.topic }
let(:topic) do
topic = mention_post.topic
topic.update_column :archetype, Archetype.private_message
topic
end
it "won't notify someone who can't see the post" do
lambda {
@ -104,6 +108,14 @@ describe PostAlertObserver do
mention_post
}.should_not change(evil_trout.notifications, :count)
end
it 'creates like notifications' do
other_user = Fabricate(:user)
topic.allowed_users << user << other_user
lambda {
PostAction.act(other_user, mention_post, PostActionType.types[:like])
}.should change(user.notifications, :count)
end
end
context 'moderator action post' do