mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
refactor validators
add a new setting for min pm body length use that setting for flags scale entropy check down for pms
This commit is contained in:
34
spec/components/validators/post_validator_spec.rb
Normal file
34
spec/components/validators/post_validator_spec.rb
Normal file
@ -0,0 +1,34 @@
|
||||
require 'spec_helper'
|
||||
require_dependency 'validators/post_validator'
|
||||
|
||||
describe Validators::PostValidator do
|
||||
let :post do
|
||||
build(:post)
|
||||
end
|
||||
|
||||
let :validator do
|
||||
Validators::PostValidator.new({})
|
||||
end
|
||||
|
||||
context "stripped_length" do
|
||||
it "adds an error for short raw" do
|
||||
post.raw = "abc"
|
||||
validator.stripped_length(post)
|
||||
expect(post.errors.count).to eq(1)
|
||||
end
|
||||
|
||||
it "adds no error for long raw" do
|
||||
post.raw = "this is a long topic body testing 123"
|
||||
validator.stripped_length(post)
|
||||
expect(post.errors.count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context "invalid post" do
|
||||
it "should be invalid" do
|
||||
validator.validate(post)
|
||||
expect(post.errors.count).to be > 0
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -53,7 +53,7 @@ describe TopicTitleLengthValidator do
|
||||
validate
|
||||
expect(record.errors[:title]).to_not be_present
|
||||
end
|
||||
|
||||
|
||||
include_examples "validating any topic title"
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user