summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-04-17 20:22:32 +0000
committerDouwe Maan <douwe@gitlab.com>2016-04-17 20:22:32 +0000
commit1c93b33587a5e0a0596b43772ee9e709e9962368 (patch)
tree6483b7290a02f10c79679e0e490724cdd0412e2d
parent5048064dc5e7ca30f65209c7ccd9fb90f9ac49db (diff)
parenta281f68b64c72bfad7796b8dc0ae3805583c66b6 (diff)
downloadgitlab-ce-1c93b33587a5e0a0596b43772ee9e709e9962368.tar.gz
Merge branch 'number_sign_for_external_issue_ref' into 'master'
Add number sign on external issue reference text Currently, external issue link is `<a ...>123</a>`. After it will be: `<a ...>#123</a>`. See merge request !3350
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/external_issue.rb6
-rw-r--r--spec/models/external_issue_spec.rb15
3 files changed, 22 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index d8fbfafb72c..de520330781 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -75,6 +75,7 @@ v 8.7.0 (unreleased)
- Fix emoji categories in the emoji picker
- Add encrypted credentials for imported projects and migrate old ones
- Author and participants are displayed first on users autocompletion
+ - Show number sign on external issue reference text (Florent Baldino)
v 8.6.6
- Expire the exists cache before deletion to ensure project dir actually exists (Stan Hu). !3413
diff --git a/app/models/external_issue.rb b/app/models/external_issue.rb
index b8585d4e577..b7894c99846 100644
--- a/app/models/external_issue.rb
+++ b/app/models/external_issue.rb
@@ -37,4 +37,10 @@ class ExternalIssue
def to_reference(_from_project = nil)
id
end
+
+ def reference_link_text(from_project = nil)
+ return "##{id}" if /^\d+$/.match(id)
+
+ id
+ end
end
diff --git a/spec/models/external_issue_spec.rb b/spec/models/external_issue_spec.rb
index 9b144dd1ecc..4fc3b065592 100644
--- a/spec/models/external_issue_spec.rb
+++ b/spec/models/external_issue_spec.rb
@@ -36,4 +36,19 @@ describe ExternalIssue, models: true do
expect(issue.title).to eq "External Issue #{issue}"
end
end
+
+ describe '#reference_link_text' do
+ context 'if issue id has a prefix' do
+ it 'returns the issue ID' do
+ expect(issue.reference_link_text).to eq 'EXT-1234'
+ end
+ end
+
+ context 'if issue id is a number' do
+ let(:issue) { described_class.new('1234', project) }
+ it 'returns the issue ID prefixed by #' do
+ expect(issue.reference_link_text).to eq '#1234'
+ end
+ end
+ end
end