mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
New users can only post newuser_max_replies_per_topic times per topic.
This commit is contained in:
@@ -10,6 +10,7 @@ describe ComposerMessagesFinder do
|
||||
|
||||
it "calls all the message finders" do
|
||||
finder.expects(:check_education_message).once
|
||||
finder.expects(:check_new_user_many_replies).once
|
||||
finder.expects(:check_avatar_notification).once
|
||||
finder.expects(:check_sequential_replies).once
|
||||
finder.expects(:check_dominating_topic).once
|
||||
@@ -56,6 +57,24 @@ describe ComposerMessagesFinder do
|
||||
finder.check_education_message.should be_blank
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context '.check_new_user_many_replies' do
|
||||
let(:user) { Fabricate.build(:user) }
|
||||
|
||||
context 'replying' do
|
||||
let(:finder) { ComposerMessagesFinder.new(user, composerAction: 'reply') }
|
||||
|
||||
it "has no message when `posted_too_much_in_topic?` is false" do
|
||||
user.expects(:posted_too_much_in_topic?).returns(false)
|
||||
finder.check_new_user_many_replies.should be_blank
|
||||
end
|
||||
|
||||
it "has a message when a user has posted too much" do
|
||||
user.expects(:posted_too_much_in_topic?).returns(true)
|
||||
finder.check_new_user_many_replies.should be_present
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -24,6 +24,20 @@ describe Validators::PostValidator do
|
||||
end
|
||||
end
|
||||
|
||||
context "too_many_posts" do
|
||||
it "should be invalid when the user has posted too much" do
|
||||
post.user.expects(:posted_too_much_in_topic?).returns(true)
|
||||
validator.max_posts_validator(post)
|
||||
expect(post.errors.count).to be > 0
|
||||
end
|
||||
|
||||
it "should be valid when the user hasn't posted too much" do
|
||||
post.user.expects(:posted_too_much_in_topic?).returns(false)
|
||||
validator.max_posts_validator(post)
|
||||
expect(post.errors.count).to be(0)
|
||||
end
|
||||
end
|
||||
|
||||
context "invalid post" do
|
||||
it "should be invalid" do
|
||||
validator.validate(post)
|
||||
|
||||
Reference in New Issue
Block a user