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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
4c506c44
Commit
4c506c44
authored
May 07, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix using link to uploads in global snippets
Closes #17342, closes #17363
parent
4cc85a58
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
lib/banzai/filter/upload_link_filter.rb
lib/banzai/filter/upload_link_filter.rb
+3
-1
spec/lib/banzai/filter/upload_link_filter_spec.rb
spec/lib/banzai/filter/upload_link_filter_spec.rb
+18
-0
No files found.
lib/banzai/filter/upload_link_filter.rb
View file @
4c506c44
...
@@ -31,7 +31,9 @@ module Banzai
...
@@ -31,7 +31,9 @@ module Banzai
end
end
def
build_url
(
uri
)
def
build_url
(
uri
)
File
.
join
(
Gitlab
.
config
.
gitlab
.
url
,
context
[
:project
].
path_with_namespace
,
uri
)
return
'#'
unless
project
=
context
[
:project
]
File
.
join
(
Gitlab
.
config
.
gitlab
.
url
,
project
.
path_with_namespace
,
uri
)
end
end
# Ensure that a :project key exists in context
# Ensure that a :project key exists in context
...
...
spec/lib/banzai/filter/upload_link_filter_spec.rb
View file @
4c506c44
...
@@ -8,6 +8,10 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do
...
@@ -8,6 +8,10 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do
project:
project
project:
project
})
})
raw_filter
(
doc
,
contexts
)
end
def
raw_filter
(
doc
,
contexts
=
{})
described_class
.
call
(
doc
,
contexts
)
described_class
.
call
(
doc
,
contexts
)
end
end
...
@@ -70,4 +74,18 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do
...
@@ -70,4 +74,18 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do
expect
(
doc
.
at_css
(
'img'
)[
'src'
]).
to
match
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
project
.
path_with_namespace
}
/uploads/%ED%95%9C%EA%B8%80.png"
expect
(
doc
.
at_css
(
'img'
)[
'src'
]).
to
match
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
project
.
path_with_namespace
}
/uploads/%ED%95%9C%EA%B8%80.png"
end
end
end
end
context
'when project context does not exist'
do
let
(
:upload_link
)
{
link
(
'/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'
)
}
it
'does not raise error'
do
expect
{
raw_filter
(
upload_link
,
project:
nil
)
}.
to_not
raise_error
end
it
'provides an empty link'
do
doc
=
raw_filter
(
upload_link
,
project:
nil
)
expect
(
doc
.
at_css
(
'a'
)[
'href'
]).
to
eq
'#'
end
end
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