FIX: only show participants the user can see

This commit is contained in:
Régis Hanol
2017-09-13 17:14:03 +02:00
parent e5db126a8e
commit 0096ee40da
3 changed files with 30 additions and 34 deletions

View File

@ -160,13 +160,18 @@ describe TopicView do
end
context '.post_counts_by_user' do
it 'returns the two posters with their counts' do
expect(topic_view.post_counts_by_user.to_a).to match_array([[first_poster.id, 2], [coding_horror.id, 1]])
it 'returns the two posters with their appropriate counts' do
Fabricate(:post, topic: topic, user: coding_horror, post_type: Post.types[:whisper])
expect(topic_view.post_counts_by_user.to_a).to match_array([[first_poster.id, 2], [coding_horror.id, 2]])
expect(TopicView.new(topic.id, first_poster).post_counts_by_user.to_a).to match_array([[first_poster.id, 2], [coding_horror.id, 1]])
end
it "doesn't return counts for posts with authors who have been deleted" do
p2.user_id = nil
p2.save!
expect(topic_view.post_counts_by_user.to_a).to match_array([[first_poster.id, 2]])
end
end