Do not allow TL0 users topics in email digest
This commit is contained in:
parent
4fd0200df8
commit
21e94859a9
|
@ -124,7 +124,7 @@ class Topic < ActiveRecord::Base
|
|||
|
||||
scope :visible, -> { where(visible: true) }
|
||||
|
||||
scope :created_since, lambda { |time_ago| where('created_at > ?', time_ago) }
|
||||
scope :created_since, lambda { |time_ago| where('topics.created_at > ?', time_ago) }
|
||||
|
||||
scope :secured, lambda { |guardian=nil|
|
||||
ids = guardian.secure_category_ids if guardian
|
||||
|
@ -276,8 +276,10 @@ class Topic < ActiveRecord::Base
|
|||
.visible
|
||||
.secured(Guardian.new(user))
|
||||
.joins("LEFT OUTER JOIN topic_users ON topic_users.topic_id = topics.id AND topic_users.user_id = #{user.id.to_i}")
|
||||
.joins("LEFT OUTER JOIN users ON users.id = topics.user_id")
|
||||
.where(closed: false, archived: false)
|
||||
.where("COALESCE(topic_users.notification_level, 1) <> ?", TopicUser.notification_levels[:muted])
|
||||
.where("COALESCE(users.trust_level, 0) > 0")
|
||||
.created_since(since)
|
||||
.listable_topics
|
||||
.includes(:category)
|
||||
|
|
|
@ -1151,6 +1151,13 @@ describe Topic do
|
|||
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to be_blank
|
||||
end
|
||||
|
||||
it "doesn't return topics from TL0 users" do
|
||||
new_user = Fabricate(:user, trust_level: 0)
|
||||
topic = Fabricate(:topic, user_id: new_user.id)
|
||||
|
||||
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to be_blank
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'secured' do
|
||||
|
|
Loading…
Reference in New Issue