mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:12:45 +08:00
FIX: approve post count
did not take new topics into account
This means if a user created a new topic, and it was approved, it would not count towards their approval count. Replies worked correctly.
This commit is contained in:
parent
b409954398
commit
add3d46bc0
|
@ -88,7 +88,7 @@ class NewPostManager
|
|||
|
||||
return :post_count if (
|
||||
user.trust_level <= TrustLevel.levels[:basic] &&
|
||||
user.post_count < SiteSetting.approve_post_count
|
||||
(user.post_count + user.topic_count) < SiteSetting.approve_post_count
|
||||
)
|
||||
|
||||
return :trust_level if user.trust_level < SiteSetting.approve_unless_trust_level.to_i
|
||||
|
|
|
@ -71,6 +71,32 @@ describe NewPostManager do
|
|||
end
|
||||
end
|
||||
|
||||
context 'basic post/topic count restrictions' do
|
||||
before do
|
||||
SiteSetting.approve_post_count = 1
|
||||
end
|
||||
|
||||
it "works with a correct `user_stat.post_count`" do
|
||||
result = NewPostManager.default_handler(manager)
|
||||
expect(result.action).to eq(:enqueued)
|
||||
expect(result.reason).to eq(:post_count)
|
||||
|
||||
manager.user.user_stat.update(post_count: 1)
|
||||
result = NewPostManager.default_handler(manager)
|
||||
expect(result).to eq(nil)
|
||||
end
|
||||
|
||||
it "works with a correct `user_stat.topic_count`" do
|
||||
result = NewPostManager.default_handler(manager)
|
||||
expect(result.action).to eq(:enqueued)
|
||||
expect(result.reason).to eq(:post_count)
|
||||
|
||||
manager.user.user_stat.update(topic_count: 1)
|
||||
result = NewPostManager.default_handler(manager)
|
||||
expect(result).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a high approval post count and TL0' do
|
||||
before do
|
||||
SiteSetting.approve_post_count = 100
|
||||
|
|
Loading…
Reference in New Issue
Block a user