diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-10 03:08:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-10 03:08:40 +0300 |
commit | 707312855bd32e4504638456c7043be5ca14aacd (patch) | |
tree | b86c1e7260d33d335ab720a7930d34c2ae43c8d6 /spec/finders | |
parent | 413c91fda942270905873684a58041f8c65f878c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/admin/abuse_report_labels_finder_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/finders/admin/abuse_report_labels_finder_spec.rb b/spec/finders/admin/abuse_report_labels_finder_spec.rb new file mode 100644 index 00000000000..01b0e742ed1 --- /dev/null +++ b/spec/finders/admin/abuse_report_labels_finder_spec.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Admin::AbuseReportLabelsFinder, feature_category: :insider_threat do + let_it_be(:current_user) { create(:admin) } + let_it_be(:project_label) { create(:label) } + let_it_be(:label_one) { create(:abuse_report_label, title: 'Uno') } + let_it_be(:label_two) { create(:abuse_report_label, title: 'Dos') } + + let(:params) { {} } + + subject(:finder) { described_class.new(current_user, params) } + + describe '#execute', :enable_admin_mode do + context 'when current user is admin' do + context 'when params is empty' do + it 'returns all abuse report labels sorted by title in ascending order' do + expect(finder.execute).to eq([label_two, label_one]) + end + end + + context 'when search_term param is present' do + let(:params) { { search_term: 'un' } } + + it 'returns matching abuse report labels' do + expect(finder.execute).to match_array([label_one]) + end + end + end + + context 'when current user is not an admin' do + let_it_be(:current_user) { create(:user) } + + it 'returns nothing' do + expect(finder.execute).to be_empty + end + end + end +end |