Commit 3693be11 authored by Sean Arnold's avatar Sean Arnold

Remove optional_issue_params method

- move issue_type into whitelisted params
parent 48cfe985
......@@ -65,7 +65,7 @@ module Issues
private
def whitelisted_issue_params
base_params = [:title, :description, :confidential]
base_params = [:title, :description, :confidential, :issue_type]
admin_params = [:milestone_id]
if can?(current_user, :admin_issue, project)
......@@ -75,16 +75,9 @@ module Issues
end
end
def optional_issue_params
optional_params = [:issue_type]
params.slice(*optional_params).reject { |_, v| v.nil? }
end
def build_issue_params
{ author: current_user }.merge(issue_params_with_info_from_discussions)
.merge(whitelisted_issue_params)
.merge(optional_issue_params)
end
end
end
......
......@@ -148,15 +148,15 @@ RSpec.describe Issues::BuildService do
expect(issue.milestone).to be_nil
end
context 'with optional params' do
context 'setting issue type' 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 'defaults to issue if issue_type nil' do
issue = build_issue(issue_type: nil)
it 'defaults to issue if issue_type not given' do
issue = build_issue
expect(issue.issue_type).to eq('issue')
end
......
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