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

View File

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