diff options
Diffstat (limited to 'spec/models/abuse_report_spec.rb')
-rw-r--r-- | spec/models/abuse_report_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/models/abuse_report_spec.rb b/spec/models/abuse_report_spec.rb index 7995cc36383..9026a870138 100644 --- a/spec/models/abuse_report_spec.rb +++ b/spec/models/abuse_report_spec.rb @@ -70,6 +70,42 @@ RSpec.describe AbuseReport, feature_category: :insider_threat do } end + describe 'scopes' do + let_it_be(:reporter) { create(:user) } + let_it_be(:report1) { create(:abuse_report, reporter: reporter) } + let_it_be(:report2) { create(:abuse_report, :closed, category: 'phishing') } + + describe '.by_reporter_id' do + subject(:results) { described_class.by_reporter_id(reporter.id) } + + it 'returns reports with reporter_id equal to the given user id' do + expect(subject).to match_array([report1]) + end + end + + describe '.open' do + subject(:results) { described_class.open } + + it 'returns reports without resolved_at value' do + expect(subject).to match_array([report, report1]) + end + end + + describe '.closed' do + subject(:results) { described_class.closed } + + it 'returns reports with resolved_at value' do + expect(subject).to match_array([report2]) + end + end + + describe '.by_category' do + it 'returns abuse reports with the specified category' do + expect(described_class.by_category('phishing')).to match_array([report2]) + end + end + end + describe 'before_validation' do context 'when links to spam contains empty strings' do let(:report) { create(:abuse_report, links_to_spam: ['', 'https://gitlab.com']) } |