BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
e051ef69
Commit
e051ef69
authored
Feb 27, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '20890-comment-image-inline' into 'master'
Fix inline comment images by removing wrapper #20890 Closes #20890 See merge request !5804
parents
5cd79bd6
b8cab61f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
14 deletions
+7
-14
image_link_filter.rb
lib/banzai/filter/image_link_filter.rb
+1
-8
users_spec.rb
spec/features/atom/users_spec.rb
+1
-1
image_link_filter_spec.rb
spec/lib/banzai/filter/image_link_filter_spec.rb
+5
-5
No files found.
lib/banzai/filter/image_link_filter.rb
View file @
e051ef69
...
...
@@ -8,11 +8,6 @@ module Banzai
# of the anchor, and then replace the img with the link-wrapped version.
def
call
doc
.
xpath
(
'descendant-or-self::img[not(ancestor::a)]'
).
each
do
|
img
|
div
=
doc
.
document
.
create_element
(
'div'
,
class:
'image-container'
)
link
=
doc
.
document
.
create_element
(
'a'
,
class:
'no-attachment-icon'
,
...
...
@@ -22,9 +17,7 @@ module Banzai
link
.
children
=
img
.
clone
div
.
children
=
link
img
.
replace
(
div
)
img
.
replace
(
link
)
end
doc
...
...
spec/features/atom/users_spec.rb
View file @
e051ef69
...
...
@@ -61,7 +61,7 @@ describe "User Feed", feature: true do
end
it
'has XHTML summaries in merge request descriptions'
do
expect
(
body
).
to
match
/Here is the fix: <
\/p><div[^>]*><a[^>]*><img[^>]*\/><\/a><\/div
>/
expect
(
body
).
to
match
/Here is the fix: <
a[^>]*><img[^>]*\/><\/a
>/
end
end
end
...
...
spec/lib/banzai/filter/image_link_filter_spec.rb
View file @
e051ef69
...
...
@@ -13,8 +13,8 @@ describe Banzai::Filter::ImageLinkFilter, lib: true do
end
it
'does not wrap a duplicate link'
do
exp
=
act
=
%q(<a href="/whatever">#{image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')}</a>
)
expect
(
filter
(
act
).
to_html
).
to
eq
exp
doc
=
filter
(
%Q(<a href="/whatever">
#{
image
(
'/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'
)
}
</a>)
)
expect
(
doc
.
to_html
).
to
match
/^<a href="\/whatever"><img[^>]*><\/a>$/
end
it
'works with external images'
do
...
...
@@ -22,8 +22,8 @@ describe Banzai::Filter::ImageLinkFilter, lib: true do
expect
(
doc
.
at_css
(
'img'
)[
'src'
]).
to
eq
doc
.
at_css
(
'a'
)[
'href'
]
end
it
'w
raps the image with a link and a div
'
do
doc
=
filter
(
image
(
'/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'
))
expect
(
doc
.
to_html
).
to
include
(
'<div class="image-container">'
)
it
'w
orks with inline images
'
do
doc
=
filter
(
%Q(<p>test
#{
image
(
'/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'
)
}
inline</p>
)
)
expect
(
doc
.
to_html
).
to
match
/^<p>test <a[^>]*><img[^>]*><\/a> inline<\/p>$/
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