mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-26 07:21:51 +00:00
Merge 6266dc1bc6
into 6d62581da1
This commit is contained in:
commit
77dd2efc1b
|
@ -127,31 +127,60 @@ RSpec.describe Report do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#unresolved_siblings?' do
|
||||
subject { Fabricate :report }
|
||||
|
||||
context 'when the target account has other unresolved reports' do
|
||||
before { Fabricate :report, action_taken_at: nil, target_account: subject.target_account }
|
||||
|
||||
it { is_expected.to be_unresolved_siblings }
|
||||
end
|
||||
|
||||
context 'when the target account has a resolved report' do
|
||||
before { Fabricate :report, action_taken_at: 3.days.ago, target_account: subject.target_account }
|
||||
|
||||
it { is_expected.to_not be_unresolved_siblings }
|
||||
end
|
||||
|
||||
context 'when the target account has no other reports' do
|
||||
before { described_class.where(target_account: subject.target_account).destroy_all }
|
||||
|
||||
it { is_expected.to_not be_unresolved_siblings }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
subject { Fabricate.build :report }
|
||||
|
||||
let(:remote_account) { Fabricate(:account, domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') }
|
||||
let(:local_account) { Fabricate(:account, domain: nil) }
|
||||
|
||||
it 'is invalid if comment is longer than character limit and reporter is local' do
|
||||
report = Fabricate.build(:report, comment: comment_over_limit)
|
||||
expect(report.valid?).to be false
|
||||
expect(report).to model_have_error_on_field(:comment)
|
||||
context 'with a local reporter' do
|
||||
subject { Fabricate.build :report, account: local_account }
|
||||
|
||||
it { is_expected.to_not allow_value(comment_over_limit).for(:comment) }
|
||||
end
|
||||
|
||||
it 'is valid if comment is longer than character limit and reporter is not local' do
|
||||
report = Fabricate.build(:report, account: remote_account, comment: comment_over_limit)
|
||||
expect(report.valid?).to be true
|
||||
context 'with a remote reporter' do
|
||||
subject { Fabricate.build :report, account: remote_account }
|
||||
|
||||
it { is_expected.to allow_value(comment_over_limit).for(:comment) }
|
||||
end
|
||||
|
||||
it 'is invalid if it references invalid rules' do
|
||||
report = Fabricate.build(:report, category: :violation, rule_ids: [-1])
|
||||
expect(report.valid?).to be false
|
||||
expect(report).to model_have_error_on_field(:rule_ids)
|
||||
it { is_expected.to_not allow_value([-1]).for(:rule_ids) }
|
||||
|
||||
context 'with a category that is not "violation"' do
|
||||
subject { Fabricate.build :report, category: :spam }
|
||||
|
||||
let(:rule) { Fabricate :rule }
|
||||
|
||||
it { is_expected.to_not allow_value(rule.id).for(:rule_ids) }
|
||||
end
|
||||
|
||||
it 'is invalid if it references rules but category is not "violation"' do
|
||||
rule = Fabricate(:rule)
|
||||
report = Fabricate.build(:report, category: :spam, rule_ids: rule.id)
|
||||
expect(report.valid?).to be false
|
||||
expect(report).to model_have_error_on_field(:rule_ids)
|
||||
context 'with extra rule ids on a violation' do
|
||||
subject { Fabricate.build :report, category: :violation }
|
||||
|
||||
it { is_expected.to_not allow_value([nil, Fabricate(:rule).id]).for(:rule_ids) }
|
||||
end
|
||||
|
||||
def comment_over_limit
|
||||
|
|
Loading…
Reference in New Issue
Block a user