FIX: Don't include unlisted topic in groups/posts
This commit is contained in:
parent
6c50ef9b5d
commit
b283bb2ba7
|
@ -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?
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue