diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/services/issues/build_service_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/services/issues/build_service_spec.rb')
-rw-r--r-- | spec/services/issues/build_service_spec.rb | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/spec/services/issues/build_service_spec.rb b/spec/services/issues/build_service_spec.rb index 3f506ec58b0..b96dd981e0f 100644 --- a/spec/services/issues/build_service_spec.rb +++ b/spec/services/issues/build_service_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe Issues::BuildService do + using RSpec::Parameterized::TableSyntax + let_it_be(:project) { create(:project, :repository) } let_it_be(:developer) { create(:user) } let_it_be(:guest) { create(:user) } @@ -144,6 +146,8 @@ RSpec.describe Issues::BuildService do issue = build_issue(milestone_id: milestone.id) expect(issue.milestone).to eq(milestone) + expect(issue.issue_type).to eq('issue') + expect(issue.work_item_type.base_type).to eq('issue') end it 'sets milestone to nil if it is not available for the project' do @@ -152,6 +156,15 @@ RSpec.describe Issues::BuildService do expect(issue.milestone).to be_nil end + + context 'when issue_type is incident' do + it 'sets the correct issue type' do + issue = build_issue(issue_type: 'incident') + + expect(issue.issue_type).to eq('incident') + expect(issue.work_item_type.base_type).to eq('incident') + end + end end context 'as guest' do @@ -165,28 +178,37 @@ RSpec.describe Issues::BuildService do end context 'setting issue type' do - it 'defaults to issue if issue_type not given' do - issue = build_issue + shared_examples 'builds an issue' do + specify do + issue = build_issue(issue_type: issue_type) - expect(issue).to be_issue + expect(issue.issue_type).to eq(resulting_issue_type) + expect(issue.work_item_type_id).to eq(work_item_type_id) + end end - it 'sets issue' do - issue = build_issue(issue_type: 'issue') + it 'cannot set invalid issue type' do + issue = build_issue(issue_type: 'project') expect(issue).to be_issue end - it 'sets incident' do - issue = build_issue(issue_type: 'incident') - - expect(issue).to be_incident - end - - it 'cannot set invalid type' do - issue = build_issue(issue_type: 'invalid type') - - expect(issue).to be_issue + context 'with a corresponding WorkItem::Type' do + let_it_be(:type_issue_id) { WorkItem::Type.default_issue_type.id } + let_it_be(:type_incident_id) { WorkItem::Type.default_by_type(:incident).id } + + where(:issue_type, :work_item_type_id, :resulting_issue_type) do + nil | ref(:type_issue_id) | 'issue' + 'issue' | ref(:type_issue_id) | 'issue' + 'incident' | ref(:type_incident_id) | 'incident' + 'test_case' | ref(:type_issue_id) | 'issue' # update once support for test_case is enabled + 'requirement' | ref(:type_issue_id) | 'issue' # update once support for requirement is enabled + 'invalid' | ref(:type_issue_id) | 'issue' + end + + with_them do + it_behaves_like 'builds an issue' + end end end end |