From 5107f6b304fef473cd8ad04287f14fd3e9747674 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 22 Mar 2017 11:26:47 -0500 Subject: [PATCH] Fix linking to new issue with selected template Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/26595 --- app/helpers/issuables_helper.rb | 2 +- .../26595-fix-issue-preselected-template.yml | 4 ++++ spec/features/issues_spec.rb | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/26595-fix-issue-preselected-template.yml diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index a777db2826b..b27ddb962df 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -251,6 +251,6 @@ 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 end diff --git a/changelogs/unreleased/26595-fix-issue-preselected-template.yml b/changelogs/unreleased/26595-fix-issue-preselected-template.yml new file mode 100644 index 00000000000..a94765f8f2a --- /dev/null +++ b/changelogs/unreleased/26595-fix-issue-preselected-template.yml @@ -0,0 +1,4 @@ +--- +title: Fix linking to new issue with selected template via url parameter +merge_request: +author: diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index a58aedc924e..7afceb88cf9 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -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