diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /spec/services/issues | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'spec/services/issues')
-rw-r--r-- | spec/services/issues/import_csv_service_spec.rb | 10 | ||||
-rw-r--r-- | spec/services/issues/update_service_spec.rb | 91 |
2 files changed, 21 insertions, 80 deletions
diff --git a/spec/services/issues/import_csv_service_spec.rb b/spec/services/issues/import_csv_service_spec.rb index 6a147782209..660686cf805 100644 --- a/spec/services/issues/import_csv_service_spec.rb +++ b/spec/services/issues/import_csv_service_spec.rb @@ -22,6 +22,8 @@ RSpec.describe Issues::ImportCsvService, feature_category: :team_planning do describe '#execute' do subject { service.execute } + it_behaves_like 'performs a spam check', true + it 'sets all issueable attributes and executes quick actions' do project.add_developer(user) project.add_developer(assignee) @@ -38,5 +40,13 @@ RSpec.describe Issues::ImportCsvService, feature_category: :team_planning do ) ) end + + context 'when user is an admin' do + before do + allow(user).to receive(:can_admin_all_resources?).and_return(true) + end + + it_behaves_like 'performs a spam check', false + end end end diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index a5151925c52..c677dc0315c 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -11,6 +11,7 @@ RSpec.describe Issues::UpdateService, :mailer, feature_category: :team_planning let_it_be(:project, reload: true) { create(:project, :repository, group: group) } let_it_be(:label) { create(:label, title: 'a', project: project) } let_it_be(:label2) { create(:label, title: 'b', project: project) } + let_it_be(:label3) { create(:label, title: 'c', project: project) } let_it_be(:milestone) { create(:milestone, project: project) } let(:issue) do @@ -992,75 +993,18 @@ RSpec.describe Issues::UpdateService, :mailer, feature_category: :team_planning end context 'updating labels' do - let(:label3) { create(:label, project: project) } - let(:result) { described_class.new(container: project, current_user: user, params: params).execute(issue).reload } - - context 'when add_label_ids and label_ids are passed' do - let(:params) { { label_ids: [label.id], add_label_ids: [label3.id] } } - - before do - issue.update!(labels: [label2]) - end - - it 'replaces the labels with the ones in label_ids and adds those in add_label_ids' do - expect(result.label_ids).to contain_exactly(label.id, label3.id) - end - end - - context 'when remove_label_ids and label_ids are passed' do - let(:params) { { label_ids: [label.id, label2.id, label3.id], remove_label_ids: [label.id] } } - - before do - issue.update!(labels: [label, label3]) - end - - it 'replaces the labels with the ones in label_ids and removes those in remove_label_ids' do - expect(result.label_ids).to contain_exactly(label2.id, label3.id) - end - end - - context 'when add_label_ids and remove_label_ids are passed' do - let(:params) { { add_label_ids: [label3.id], remove_label_ids: [label.id] } } - - before do - issue.update!(labels: [label]) - end - - it 'adds the passed labels' do - expect(result.label_ids).to include(label3.id) - end - - it 'removes the passed labels' do - expect(result.label_ids).not_to include(label.id) - end - end - - context 'when same id is passed as add_label_ids and remove_label_ids' do - let(:params) { { add_label_ids: [label.id], remove_label_ids: [label.id] } } - - context 'for a label assigned to an issue' do - it 'removes the label' do - issue.update!(labels: [label]) - - expect(result.label_ids).to be_empty - end - end - - context 'for a label not assigned to an issue' do - it 'does not add the label' do - expect(result.label_ids).to be_empty - end - end - end + let(:label_a) { label } + let(:label_b) { label2 } + let(:label_c) { label3 } + let(:label_locked) { create(:label, title: 'locked', project: project, lock_on_merge: true) } + let(:issuable) { issue } - context 'when duplicate label titles are given' do - let(:params) do - { labels: [label3.title, label3.title] } - end + it_behaves_like 'updating issuable labels' + it_behaves_like 'keeps issuable labels sorted after update' + it_behaves_like 'broadcasting issuable labels updates' - it 'assigns the label once' do - expect(result.labels).to contain_exactly(label3) - end + def update_issuable(update_params) + update_issue(update_params) end end @@ -1513,19 +1457,6 @@ RSpec.describe Issues::UpdateService, :mailer, feature_category: :team_planning end end - context 'labels are updated' do - let(:label_a) { label } - let(:label_b) { label2 } - let(:issuable) { issue } - - it_behaves_like 'keeps issuable labels sorted after update' - it_behaves_like 'broadcasting issuable labels updates' - - def update_issuable(update_params) - update_issue(update_params) - end - end - it_behaves_like 'issuable record that supports quick actions' do let(:existing_issue) { create(:issue, project: project) } let(:issuable) { described_class.new(container: project, current_user: user, params: params).execute(existing_issue) } |