mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Don't employ the "too many replies" if the user is staff, or if they created the topic.
See: http://meta.discourse.org/t/what-is-the-point-of-limiting-new-users-to-three-replies-per-topic/11696
This commit is contained in:
parent
aefad6ae85
commit
f145060315
2 changed files with 34 additions and 0 deletions
|
@ -354,6 +354,10 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def posted_too_much_in_topic?(topic_id)
|
||||
|
||||
# Does not apply to staff or your own topics
|
||||
return false if staff? || Topic.where(id: topic_id, user_id: id).exists?
|
||||
|
||||
trust_level == TrustLevel.levels[:newuser] && (Post.where(topic_id: topic_id, user_id: id).count >= SiteSetting.newuser_max_replies_per_topic)
|
||||
end
|
||||
|
||||
|
|
|
@ -903,6 +903,36 @@ describe User do
|
|||
|
||||
end
|
||||
|
||||
describe "posted too much in topic" do
|
||||
let!(:user) { Fabricate(:user, trust_level: TrustLevel.levels[:newuser]) }
|
||||
let!(:topic) { Fabricate(:post).topic }
|
||||
|
||||
before do
|
||||
# To make testing easier, say 1 reply is too much
|
||||
SiteSetting.stubs(:newuser_max_replies_per_topic).returns(1)
|
||||
end
|
||||
|
||||
context "for a user who didn't create the topic" do
|
||||
let!(:post) { Fabricate(:post, topic: topic, user: user) }
|
||||
|
||||
it "does not return true for staff" do
|
||||
user.stubs(:staff?).returns(true)
|
||||
user.posted_too_much_in_topic?(topic.id).should be_false
|
||||
end
|
||||
|
||||
it "returns true when the user has posted too much" do
|
||||
user.posted_too_much_in_topic?(topic.id).should be_true
|
||||
end
|
||||
end
|
||||
|
||||
it "returns false for a user who created the topic" do
|
||||
topic_user = topic.user
|
||||
topic_user.trust_level = TrustLevel.levels[:newuser]
|
||||
topic.user.posted_too_much_in_topic?(topic.id).should be_false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#find_email" do
|
||||
|
||||
let(:user) { Fabricate(:user, email: "bob@example.com") }
|
||||
|
|
Loading…
Reference in a new issue