Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
fc0a90fa
Commit
fc0a90fa
authored
Oct 07, 2020
by
Justin Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update external_link to use GitLab SVG
parent
36f127f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
app/helpers/external_link_helper.rb
app/helpers/external_link_helper.rb
+1
-1
spec/helpers/external_link_helper_spec.rb
spec/helpers/external_link_helper_spec.rb
+7
-4
No files found.
app/helpers/external_link_helper.rb
View file @
fc0a90fa
...
...
@@ -3,7 +3,7 @@
module
ExternalLinkHelper
def
external_link
(
body
,
url
,
options
=
{})
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
spec/helpers/external_link_helper_spec.rb
View file @
fc0a90fa
...
...
@@ -6,12 +6,15 @@ RSpec.describe ExternalLinkHelper do
include
IconsHelper
it
'returns external link with icon'
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>'
)
link
=
external_link
(
'https://gitlab.com'
,
'https://gitlab.com'
).
to_s
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
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>'
)
link
=
external_link
(
'https://gitlab.com'
,
'https://gitlab.com'
,
{
"data-foo"
:
"bar"
,
class:
"externalLink"
}).
to_s
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment