mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-29 14:35:06 +01:00
Simplify model validation specs for Report
(#33267)
This commit is contained in:
parent
d56aa9031a
commit
b51e0bc3c7
@ -156,13 +156,13 @@ RSpec.describe Report do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'validations' do
|
describe 'Validations' do
|
||||||
let(:remote_account) { Fabricate(:account, domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') }
|
let(:remote_account) { Fabricate(:account, domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') }
|
||||||
|
|
||||||
it 'is invalid if comment is longer than character limit and reporter is local' do
|
it 'is invalid if comment is longer than character limit and reporter is local' do
|
||||||
report = Fabricate.build(:report, comment: comment_over_limit)
|
report = Fabricate.build(:report)
|
||||||
expect(report.valid?).to be false
|
|
||||||
expect(report).to model_have_error_on_field(:comment)
|
expect(report).to_not allow_value(comment_over_limit).for(:comment)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is valid if comment is longer than character limit and reporter is not local' do
|
it 'is valid if comment is longer than character limit and reporter is not local' do
|
||||||
@ -171,16 +171,16 @@ RSpec.describe Report do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'is invalid if it references invalid rules' do
|
it 'is invalid if it references invalid rules' do
|
||||||
report = Fabricate.build(:report, category: :violation, rule_ids: [-1])
|
report = Fabricate.build(:report, category: :violation)
|
||||||
expect(report.valid?).to be false
|
|
||||||
expect(report).to model_have_error_on_field(:rule_ids)
|
expect(report).to_not allow_value([-1]).for(:rule_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is invalid if it references rules but category is not "violation"' do
|
it 'is invalid if it references rules but category is not "violation"' do
|
||||||
rule = Fabricate(:rule)
|
rule = Fabricate(:rule)
|
||||||
report = Fabricate.build(:report, category: :spam, rule_ids: rule.id)
|
report = Fabricate.build(:report, category: :spam)
|
||||||
expect(report.valid?).to be false
|
|
||||||
expect(report).to model_have_error_on_field(:rule_ids)
|
expect(report).to_not allow_value(rule.id).for(:rule_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
def comment_over_limit
|
def comment_over_limit
|
||||||
|
Loading…
Reference in New Issue
Block a user