FIX: Don't include unlisted topic in groups/posts

This commit is contained in:
Robin Ward 2018-02-28 14:39:11 -05:00
parent 6c50ef9b5d
commit b283bb2ba7
2 changed files with 20 additions and 0 deletions

View File

@ -192,6 +192,7 @@ class Group < ActiveRecord::Base
.references(:posts, :topics, :category)
.where(user_id: user_ids)
.where('topics.archetype <> ?', Archetype.private_message)
.where('topics.visible')
.where(post_type: Post.types[:regular])
if opts[:category_id].present?

View File

@ -5,6 +5,25 @@ describe Group do
let(:user) { Fabricate(:user) }
let(:group) { Fabricate(:group) }
describe "#posts_for" do
it "returns the post in the group" do
p = Fabricate(:post)
group.add(p.user)
posts = group.posts_for(Guardian.new)
expect(posts).to include(p)
end
it "doesn't include unlisted posts" do
p = Fabricate(:post)
p.topic.update_column(:visible, false)
group.add(p.user)
posts = group.posts_for(Guardian.new)
expect(posts).not_to include(p)
end
end
describe '#builtin' do
context "verify enum sequence" do
before do