the private message stream is different to normal streams, improving the ui a bit and collapsing conversations

This commit is contained in:
Sam
2013-05-20 16:44:06 +10:00
parent b9c4bf9870
commit e91ed83586
5 changed files with 118 additions and 4 deletions

View File

@@ -206,4 +206,55 @@ describe UserAction do
@user.user_actions.where(action_type: UserAction::BOOKMARK).first.should be_nil
end
end
describe 'private messages' do
let(:user) do
Fabricate(:user)
end
let(:target_user) do
Fabricate(:user)
end
let(:private_message) do
PostCreator.create( user,
raw: 'this is a private message',
title: 'this is the pm title',
target_usernames: target_user.username,
archetype: Archetype::private_message
)
end
let!(:response) do
PostCreator.create(user, raw: 'oops I forgot to mention this', topic_id: private_message.topic_id)
end
let!(:private_message2) do
PostCreator.create( target_user,
raw: 'this is a private message',
title: 'this is the pm title',
target_usernames: user.username,
archetype: Archetype::private_message
)
end
it 'should collapse the inbox correctly' do
stream = UserAction.private_message_stream(UserAction::GOT_PRIVATE_MESSAGE, user_id: target_user.id, guardian: Guardian.new(target_user))
# inbox should collapse this initial and reply message into one item
stream.count.should == 1
# outbox should also collapse
stream = UserAction.private_message_stream(UserAction::NEW_PRIVATE_MESSAGE, user_id: user.id, guardian: Guardian.new(user))
stream.count.should == 1
# anon should see nothing
stream = UserAction.private_message_stream(UserAction::NEW_PRIVATE_MESSAGE, user_id: user.id, guardian: Guardian.new(nil))
stream.count.should == 0
end
end
end