Commit 48cfe985 authored by Sean Arnold's avatar Sean Arnold

Use nested params for issue_type

- Update specs
- Add js spec
parent 9c44696e
......@@ -183,7 +183,7 @@ export default {
return mergeUrlParams(
{
issuable_template: this.incidentTemplateName,
issue_type: this.incidentType,
'issue[issue_type]': this.incidentType,
},
this.newIssuePath,
);
......
......@@ -93,8 +93,7 @@ class Projects::IssuesController < Projects::ApplicationController
build_params = issue_params.merge(
merge_request_to_resolve_discussions_of: params[:merge_request_to_resolve_discussions_of],
discussion_to_resolve: params[:discussion_to_resolve],
confidential: !!Gitlab::Utils.to_boolean(params[:issue][:confidential]),
issue_type: params[:issue_type]
confidential: !!Gitlab::Utils.to_boolean(params[:issue][:confidential])
)
service = Issues::BuildService.new(project, current_user, build_params)
......
......@@ -181,10 +181,11 @@ RSpec.describe Projects::IssuesController do
project.add_developer(user)
end
it 'builds a new issue' do
it 'builds a new issue', :aggregate_failures do
get :new, params: { namespace_id: project.namespace, project_id: project }
expect(assigns(:issue)).to be_a_new(Issue)
expect(assigns(:issue).issue_type).to eq('issue')
end
where(:conf_value, :conf_result) do
......@@ -218,7 +219,7 @@ RSpec.describe Projects::IssuesController do
let(:issue_type) { 'issue' }
before do
get :new, params: { namespace_id: project.namespace, project_id: project, issue_type: issue_type }
get :new, params: { namespace_id: project.namespace, project_id: project, issue: { issue_type: issue_type } }
end
subject { assigns(:issue).issue_type }
......@@ -1067,6 +1068,14 @@ RSpec.describe Projects::IssuesController do
project.issues.first
end
it 'creates the issue successfully', :aggregate_failures do
issue = post_new_issue
expect(issue).to be_a(Issue)
expect(issue.persisted?).to eq(true)
expect(issue.issue_type).to eq('issue')
end
context 'resolving discussions in MergeRequest' do
let(:discussion) { create(:diff_note_on_merge_request).to_discussion }
let(:merge_request) { discussion.noteable }
......
......@@ -10,7 +10,7 @@ import {
GlTabs,
GlBadge,
} from '@gitlab/ui';
import { visitUrl, joinPaths } from '~/lib/utils/url_utility';
import { visitUrl, joinPaths, mergeUrlParams } from '~/lib/utils/url_utility';
import IncidentsList from '~/incidents/components/incidents_list.vue';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import { I18N, INCIDENT_STATUS_TABS } from '~/incidents/constants';
......@@ -169,8 +169,13 @@ describe('Incidents List', () => {
});
});
it('shows the button linking to new incidents page with prefilled incident template', () => {
it('shows the button linking to new incidents page with prefilled incident template when clicked', () => {
expect(findCreateIncidentBtn().exists()).toBe(true);
findCreateIncidentBtn().trigger('click');
expect(mergeUrlParams).toHaveBeenCalledWith(
{ issuable_template: incidentTemplateName, 'issue[issue_type]': incidentType },
newIssuePath,
);
});
it('sets button loading on click', () => {
......
......@@ -149,13 +149,13 @@ RSpec.describe Issues::BuildService do
end
context 'with optional params' do
it 'sets the params on the issue' do
it 'sets the issue_type on the issue' do
issue = build_issue(issue_type: 'incident')
expect(issue.issue_type).to eq('incident')
end
it 'rejects the param if nil' do
it 'defaults to issue if issue_type nil' do
issue = build_issue(issue_type: nil)
expect(issue.issue_type).to eq('issue')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment