diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-14 21:13:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-14 21:13:24 +0000 |
commit | 6df3cf6b4acbfe83f7a19e40bbd1471af5d6ce95 (patch) | |
tree | ad732f3108fb02f1e8f95f13cc87edaedbb728b1 /spec/services/issues | |
parent | 5b62f8e3ee531f63ce3c49cae03e2a618ba51615 (diff) | |
download | gitlab-ce-6df3cf6b4acbfe83f7a19e40bbd1471af5d6ce95.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/issues')
-rw-r--r-- | spec/services/issues/build_service_spec.rb | 32 | ||||
-rw-r--r-- | spec/services/issues/create_service_spec.rb | 91 | ||||
-rw-r--r-- | spec/services/issues/update_service_spec.rb | 26 |
3 files changed, 61 insertions, 88 deletions
diff --git a/spec/services/issues/build_service_spec.rb b/spec/services/issues/build_service_spec.rb index fecfc3f3d64..bca6a3cd4f9 100644 --- a/spec/services/issues/build_service_spec.rb +++ b/spec/services/issues/build_service_spec.rb @@ -172,37 +172,5 @@ RSpec.describe Issues::BuildService, feature_category: :team_planning do end end end - - describe 'setting issue type' do - context 'with a corresponding WorkItems::Type' do - let_it_be(:type_issue_id) { WorkItems::Type.default_issue_type.id } - let_it_be(:type_incident_id) { WorkItems::Type.default_by_type(:incident).id } - - where(:issue_type, :current_user, :work_item_type_id, :resulting_issue_type) do - nil | ref(:guest) | ref(:type_issue_id) | 'issue' - 'issue' | ref(:guest) | ref(:type_issue_id) | 'issue' - 'incident' | ref(:guest) | ref(:type_issue_id) | 'issue' - 'incident' | ref(:reporter) | ref(:type_incident_id) | 'incident' - # update once support for test_case is enabled - 'test_case' | ref(:guest) | ref(:type_issue_id) | 'issue' - # update once support for requirement is enabled - 'requirement' | ref(:guest) | ref(:type_issue_id) | 'issue' - 'invalid' | ref(:guest) | ref(:type_issue_id) | 'issue' - # ensure that we don't set a value which has a permission check but is an invalid issue type - 'project' | ref(:guest) | ref(:type_issue_id) | 'issue' - end - - with_them do - let(:user) { current_user } - - it 'builds an issue' do - issue = build_issue(issue_type: issue_type) - - expect(issue.issue_type).to eq(resulting_issue_type) - expect(issue.work_item_type_id).to eq(work_item_type_id) - end - end - end - end end end diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb index df47780bc89..88dcc870ee7 100644 --- a/spec/services/issues/create_service_spec.rb +++ b/spec/services/issues/create_service_spec.rb @@ -574,36 +574,6 @@ RSpec.describe Issues::CreateService, feature_category: :team_planning do end context 'Quick actions' do - context 'as work item' do - let(:opts) do - { - title: "My work item", - work_item_type: work_item_type, - description: "/shrug" - } - end - - context 'when work item type is not the default Issue' do - let(:work_item_type) { create(:work_item_type, namespace: project.namespace) } - - it 'saves the work item without applying the quick action' do - expect(result).to be_success - expect(issue).to be_persisted - expect(issue.description).to eq("/shrug") - end - end - - context 'when work item type is the default Issue' do - let(:work_item_type) { WorkItems::Type.default_by_type(:issue) } - - it 'saves the work item and applies the quick action' do - expect(result).to be_success - expect(issue).to be_persisted - expect(issue.description).to eq(" ¯\\_(ツ)_/¯") - end - end - end - context 'with assignee, milestone, and contact in params and command' do let_it_be(:contact) { create(:contact, group: group) } @@ -696,6 +666,23 @@ RSpec.describe Issues::CreateService, feature_category: :team_planning do expect(issue.labels).to eq([label]) end end + + context 'when using promote_to_incident' do + let(:opts) { { title: 'Title', description: '/promote_to_incident' } } + + before do + project.add_developer(user) + end + + it 'creates an issue with the correct issue type' do + expect { result }.to change(Issue, :count).by(1) + + created_issue = Issue.last + + expect(created_issue.issue_type).to eq('incident') + expect(created_issue.work_item_type).to eq(WorkItems::Type.default_by_type('incident')) + end + end end context 'resolving discussions' do @@ -864,5 +851,49 @@ RSpec.describe Issues::CreateService, feature_category: :team_planning do subject.execute end end + + describe 'setting issue type' do + using RSpec::Parameterized::TableSyntax + + let_it_be(:guest) { user.tap { |u| project.add_guest(u) } } + let_it_be(:reporter) { assignee.tap { |u| project.add_reporter(u) } } + + context 'with a corresponding WorkItems::Type' do + let_it_be(:type_issue_id) { WorkItems::Type.default_issue_type.id } + let_it_be(:type_incident_id) { WorkItems::Type.default_by_type(:incident).id } + + where(:issue_type, :current_user, :work_item_type_id, :resulting_issue_type) do + nil | ref(:guest) | ref(:type_issue_id) | 'issue' + 'issue' | ref(:guest) | ref(:type_issue_id) | 'issue' + 'incident' | ref(:guest) | ref(:type_issue_id) | 'issue' + 'incident' | ref(:reporter) | ref(:type_incident_id) | 'incident' + # update once support for test_case is enabled + 'test_case' | ref(:guest) | ref(:type_issue_id) | 'issue' + # update once support for requirement is enabled + 'requirement' | ref(:guest) | ref(:type_issue_id) | 'issue' + 'invalid' | ref(:guest) | ref(:type_issue_id) | 'issue' + # ensure that we don't set a value which has a permission check but is an invalid issue type + 'project' | ref(:guest) | ref(:type_issue_id) | 'issue' + end + + with_them do + let(:user) { current_user } + let(:params) { { title: 'title', issue_type: issue_type } } + let(:issue) do + described_class.new( + container: project, + current_user: user, + params: params, + spam_params: spam_params + ).execute[:issue] + end + + it 'creates an issue' do + expect(issue.issue_type).to eq(resulting_issue_type) + expect(issue.work_item_type_id).to eq(work_item_type_id) + end + end + end + end end end diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index a5a18562ca5..167bff2a492 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -1493,31 +1493,5 @@ RSpec.describe Issues::UpdateService, :mailer, feature_category: :team_planning let(:existing_issue) { create(:issue, project: project) } let(:issuable) { described_class.new(container: project, current_user: user, params: params).execute(existing_issue) } end - - context 'with quick actions' do - context 'as work item' do - let(:opts) { { description: "/shrug" } } - - context 'when work item type is not the default Issue' do - let(:issue) { create(:work_item, :task, description: "") } - - it 'does not apply the quick action' do - expect do - update_issue(opts) - end.to change(issue, :description).to("/shrug") - end - end - - context 'when work item type is the default Issue' do - let(:issue) { create(:work_item, :issue, description: "") } - - it 'does not apply the quick action' do - expect do - update_issue(opts) - end.to change(issue, :description).to(" ¯\\_(ツ)_/¯") - end - end - end - end end end |