summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2017-03-22 11:26:47 -0500
committerEric Eastwood <contact@ericeastwood.com>2017-03-29 14:12:12 -0500
commit5107f6b304fef473cd8ad04287f14fd3e9747674 (patch)
treedb733697cf4e649b78161cd55b0437be922d5eca
parent6460489babe3cd25358800804f6befc1bd242f22 (diff)
downloadgitlab-ce-5107f6b304fef473cd8ad04287f14fd3e9747674.tar.gz
Fix linking to new issue with selected template
Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/26595
-rw-r--r--app/helpers/issuables_helper.rb2
-rw-r--r--changelogs/unreleased/26595-fix-issue-preselected-template.yml4
-rw-r--r--spec/features/issues_spec.rb17
3 files changed, 22 insertions, 1 deletions
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