mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 04:29:29 +08:00
FIX: Fixed tests. (#6716)
This commit is contained in:
parent
f8e6a37858
commit
1a4676c6e0
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user