Add test for mention notifications
This commit is contained in:
parent
48a3909fe0
commit
126252d47a
2 changed files with 12 additions and 1 deletions
|
|
@ -91,7 +91,7 @@ class PostsController < ApplicationController
|
|||
end
|
||||
|
||||
# For mentions
|
||||
mention = @post.mentions.where(person_id: current_user.id).first
|
||||
mention = @post.mentions.where(person_id: current_user.person_id).first
|
||||
Notification.where(recipient_id: current_user.id, target_type: "Mention", target_id: mention.id, unread: true).first.try(:set_read_state, true) if mention
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -50,6 +50,17 @@ describe PostsController do
|
|||
}.to change(Notification.where(:unread => true), :count).by(-2)
|
||||
end
|
||||
|
||||
it 'marks a corresponding mention notification as read' do
|
||||
status_msg = bob.post(:status_message, {text: "this is a text mentioning @{Mention User ; #{alice.diaspora_handle}} ... have fun testing!", :public => true, :to => 'all'})
|
||||
mention = status_msg.mentions.where(person_id: alice.person.id).first
|
||||
note = FactoryGirl.create(:notification, :recipient => alice, :target_type => "Mention", :target_id => mention.id, :unread => true)
|
||||
|
||||
expect {
|
||||
get :show, :id => status_msg.id
|
||||
note.reload
|
||||
}.to change(Notification.where(:unread => true), :count).by(-1)
|
||||
end
|
||||
|
||||
it '404 if the post is missing' do
|
||||
expect {
|
||||
get :show, :id => 1234567
|
||||
|
|
|
|||
Loading…
Reference in a new issue