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:
Neil Lalonde
2013-09-06 11:50:05 -04:00
parent b0573c5f8f
commit eae7e75611
5 changed files with 57 additions and 21 deletions

View File

@ -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