summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--public/javascripts/application.js7
-rw-r--r--test/system/inline_autocomplete_test.rb16
2 files changed, 22 insertions, 1 deletions
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 7b2e7725e..dcebb0923 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1169,7 +1169,12 @@ function inlineAutoComplete(element) {
fillAttr: 'label',
requireLeadingSpace: true,
selectTemplate: function (issue) {
- return '#' + issue.original.id;
+ let leadingHash = "#"
+ // keep ## syntax which is a valid issue syntax to show issue with title.
+ if (this.currentMentionTextSnapshot.charAt(0) === "#") {
+ leadingHash = "##"
+ }
+ return leadingHash + issue.original.id;
},
menuItemTemplate: function (issue) {
return sanitizeHTML(issue.original.label);
diff --git a/test/system/inline_autocomplete_test.rb b/test/system/inline_autocomplete_test.rb
index dbae41373..7bf453e6d 100644
--- a/test/system/inline_autocomplete_test.rb
+++ b/test/system/inline_autocomplete_test.rb
@@ -42,6 +42,22 @@ class InlineAutocompleteSystemTest < ApplicationSystemTestCase
assert_equal '#12 ', find('#issue_description').value
end
+ def test_inline_autocomplete_for_issues_with_double_hash_keep_syntax
+ log_user('admin', 'admin')
+ visit 'projects/ecookbook/issues/new'
+
+ fill_in 'Description', :with => '##Closed'
+
+ within('.tribute-container') do
+ assert page.has_text? 'Bug #12: Closed issue on a locked version'
+ assert page.has_text? 'Bug #11: Closed issue on a closed version'
+
+ first('li').click
+ end
+
+ assert_equal '##12 ', find('#issue_description').value
+ end
+
def test_inline_autocomplete_filters_autocomplete_items
log_user('jsmith', 'jsmith')
visit 'issues/new'