summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakeburden <jburden@gitlab.com>2019-09-03 17:26:39 -0400
committerjakeburden <jburden@gitlab.com>2019-09-03 18:06:44 -0400
commite6090e713b53ed748dc1a8fef962732bdf37ddfe (patch)
tree2d5f266a94ccf86177fc83906822cb60d0b3c4c9
parent90dc19e9f0be8ac530b5e5e042791143ce0ba0ce (diff)
downloadgitlab-ce-e6090e713b53ed748dc1a8fef962732bdf37ddfe.tar.gz
Allow for the passing of options to external_link66067-pages-domain-doesnt-set-target-blank
-rw-r--r--app/helpers/external_link_helper.rb4
-rw-r--r--spec/helpers/external_link_helper_spec.rb5
2 files changed, 7 insertions, 2 deletions
diff --git a/app/helpers/external_link_helper.rb b/app/helpers/external_link_helper.rb
index fe908b3ae1c..9dbad1f5032 100644
--- a/app/helpers/external_link_helper.rb
+++ b/app/helpers/external_link_helper.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
module ExternalLinkHelper
- def external_link(body, url)
- link_to url, target: '_blank', rel: 'noopener noreferrer' do
+ def external_link(body, url, options = {})
+ link_to url, { target: '_blank', rel: 'noopener noreferrer' }.merge(options) do
"#{body} #{icon('external-link')}".html_safe
end
end
diff --git a/spec/helpers/external_link_helper_spec.rb b/spec/helpers/external_link_helper_spec.rb
index 60ad188e98b..7fc4ef18731 100644
--- a/spec/helpers/external_link_helper_spec.rb
+++ b/spec/helpers/external_link_helper_spec.rb
@@ -9,4 +9,9 @@ describe ExternalLinkHelper do
expect(external_link('https://gitlab.com', 'https://gitlab.com').to_s)
.to eq('<a target="_blank" rel="noopener noreferrer" href="https://gitlab.com">https://gitlab.com <i aria-hidden="true" data-hidden="true" class="fa fa-external-link"></i></a>')
end
+
+ it 'allows options when creating external link with icon' do
+ expect(external_link('https://gitlab.com', 'https://gitlab.com', { "data-foo": "bar", class: "externalLink" }).to_s)
+ .to eq('<a target="_blank" rel="noopener noreferrer" data-foo="bar" class="externalLink" href="https://gitlab.com">https://gitlab.com <i aria-hidden="true" data-hidden="true" class="fa fa-external-link"></i></a>')
+ end
end