Commit fc0a90fa authored by Justin Ho's avatar Justin Ho

Update external_link to use GitLab SVG

parent 36f127f9
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module ExternalLinkHelper module ExternalLinkHelper
def external_link(body, url, options = {}) def external_link(body, url, options = {})
link_to url, { target: '_blank', rel: 'noopener noreferrer' }.merge(options) do link_to url, { target: '_blank', rel: 'noopener noreferrer' }.merge(options) do
"#{body} #{icon('external-link')}".html_safe "#{body} #{sprite_icon('external-link')}".html_safe
end end
end end
end end
...@@ -6,12 +6,15 @@ RSpec.describe ExternalLinkHelper do ...@@ -6,12 +6,15 @@ RSpec.describe ExternalLinkHelper do
include IconsHelper include IconsHelper
it 'returns external link with icon' do it 'returns external link with icon' do
expect(external_link('https://gitlab.com', 'https://gitlab.com').to_s) link = 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>') expect(link).to start_with('<a target="_blank" rel="noopener noreferrer" href="https://gitlab.com">https://gitlab.com')
expect(link).to include('data-testid="external-link-icon"')
end end
it 'allows options when creating external link with icon' do 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) link = 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>')
expect(link).to start_with('<a target="_blank" rel="noopener noreferrer" data-foo="bar" class="externalLink" href="https://gitlab.com">https://gitlab.com')
expect(link).to include('data-testid="external-link-icon"')
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment