Merge branch '26595-fix-issue-preselected-template' into 'master'

Fix linking to new issue with selected template

Closes #26595

See merge request !10155
This commit is contained in:
Rémy Coutable 2017-03-30 11:29:40 +00:00
commit 5920b4a52f
3 changed files with 22 additions and 1 deletions

View file

@ -251,7 +251,7 @@ module IssuablesHelper
end
def selected_template(issuable)
params[:issuable_template] if issuable_templates(issuable).include?(params[:issuable_template])
params[:issuable_template] if issuable_templates(issuable).any?{ |template| template[:name] == params[:issuable_template] }
end
def issuable_todo_button_data(issuable, todo, is_collapsed)

View file

@ -0,0 +1,4 @@
---
title: Fix linking to new issue with selected template via url parameter
merge_request:
author:

View file

@ -13,6 +13,13 @@ describe 'Issues', feature: true do
user2 = create(:user)
project.team << [[@user, user2], :developer]
project.repository.create_file(
@user,
'.gitlab/issue_templates/bug.md',
'this is a test "bug" template',
message: 'added issue template',
branch_name: 'master')
end
describe 'Edit issue' do
@ -600,6 +607,16 @@ describe 'Issues', feature: true do
expect(page.find_field("issue_description").value).to match /\n\n$/
end
end
context 'form filled by URL parameters' do
before do
visit new_namespace_project_issue_path(project.namespace, project, issuable_template: 'bug')
end
it 'fills in template' do
expect(find('.js-issuable-selector .dropdown-toggle-text')).to have_content('bug')
end
end
end
describe 'new issue by email' do