FIX: Fixed tests. (#6716)

This commit is contained in:
Bianca Nenciu 2018-12-03 18:03:11 +02:00 committed by Régis Hanol
parent f8e6a37858
commit 1a4676c6e0
1 changed files with 9 additions and 11 deletions

View File

@ -229,25 +229,23 @@ describe Validators::PostValidator do
SiteSetting.max_consecutive_replies = 2
end
it "should always allow posting" do
it "should always allow original poster to post" do
[user, user, user, other_user, user, user, user].each_with_index do |u, i|
post = Post.new(user: user, topic: topic, raw: "post number #{i}")
post = Post.new(user: u, topic: topic, raw: "post number #{i}")
validator.force_edit_last_validator(post)
expect(post.errors.count).to eq(0)
post.save
post.save!
end
end
it "should not allow posting more than 2 consecutive replies" do
post = Post.new(user: other_user, topic: topic, raw: "post number 0")
post.save
Post.create(user: other_user, topic: topic, raw: "post number 0")
Post.create(user: user, topic: topic, raw: "post number 1")
Post.create(user: user, topic: topic, raw: "post number 2")
1.upto(3).each do |i|
post = Post.new(user: user, topic: topic, raw: "post number #{i}")
validator.force_edit_last_validator(post)
expect(post.errors.count).to eq(i > SiteSetting.max_consecutive_replies ? 1 : 0)
post.save
end
post = Post.new(user: user, topic: topic, raw: "post number 3")
validator.force_edit_last_validator(post)
expect(post.errors.count).to eq(1)
end
it "should always allow editing" do