mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
FIX: recover post by a non-staff user fails because the post is not unique. Uniqueness check shouldn't happen when recovering a deleted post.
This commit is contained in:
@ -31,4 +31,38 @@ describe Validators::PostValidator do
|
||||
end
|
||||
end
|
||||
|
||||
describe "unique_post_validator" do
|
||||
before do
|
||||
SiteSetting.stubs(:unique_posts_mins).returns(5)
|
||||
end
|
||||
|
||||
context "post is unique" do
|
||||
before do
|
||||
$redis.stubs(:exists).with(post.unique_post_key).returns(nil)
|
||||
end
|
||||
|
||||
it "should not add an error" do
|
||||
validator.unique_post_validator(post)
|
||||
post.errors.count.should == 0
|
||||
end
|
||||
end
|
||||
|
||||
context "post is not unique" do
|
||||
before do
|
||||
$redis.stubs(:exists).with(post.unique_post_key).returns('1')
|
||||
end
|
||||
|
||||
it "should add an error" do
|
||||
validator.unique_post_validator(post)
|
||||
expect(post.errors.count).to be > 0
|
||||
end
|
||||
|
||||
it "should not add an error if post.skip_unique_check is true" do
|
||||
post.skip_unique_check = true
|
||||
validator.unique_post_validator(post)
|
||||
post.errors.count.should == 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user