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
2ea166fc
Commit
2ea166fc
authored
Oct 10, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure relative url and asset_host are honored, specs.
parent
4149fc24
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
3 deletions
+20
-3
Gemfile.lock
Gemfile.lock
+1
-1
lib/gitlab/markdown.rb
lib/gitlab/markdown.rb
+6
-1
spec/helpers/gitlab_markdown_helper_spec.rb
spec/helpers/gitlab_markdown_helper_spec.rb
+13
-1
No files found.
Gemfile.lock
View file @
2ea166fc
...
@@ -241,7 +241,7 @@ GEM
...
@@ -241,7 +241,7 @@ GEM
html-pipeline (1.11.0)
html-pipeline (1.11.0)
activesupport (>= 2)
activesupport (>= 2)
nokogiri (~> 1.4)
nokogiri (~> 1.4)
html-pipeline-gitlab (0.1.
4
)
html-pipeline-gitlab (0.1.
5
)
actionpack (~> 4)
actionpack (~> 4)
gitlab_emoji (~> 0.0.1)
gitlab_emoji (~> 0.0.1)
html-pipeline (~> 1.11.0)
html-pipeline (~> 1.11.0)
...
...
lib/gitlab/markdown.rb
View file @
2ea166fc
...
@@ -78,9 +78,14 @@ module Gitlab
...
@@ -78,9 +78,14 @@ module Gitlab
HTML
::
Pipeline
::
Gitlab
::
GitlabEmojiFilter
HTML
::
Pipeline
::
Gitlab
::
GitlabEmojiFilter
]
]
markdown_context
=
{
asset_root:
Gitlab
.
config
.
gitlab
.
url
,
asset_host:
Gitlab
::
Application
.
config
.
asset_host
}
markdown_pipeline
=
HTML
::
Pipeline
::
Gitlab
.
new
(
filters
).
pipeline
markdown_pipeline
=
HTML
::
Pipeline
::
Gitlab
.
new
(
filters
).
pipeline
result
=
markdown_pipeline
.
call
(
text
)
result
=
markdown_pipeline
.
call
(
text
,
markdown_context
)
text
=
result
[
:output
].
to_html
(
save_with:
0
)
text
=
result
[
:output
].
to_html
(
save_with:
0
)
allowed_attributes
=
ActionView
::
Base
.
sanitized_allowed_attributes
allowed_attributes
=
ActionView
::
Base
.
sanitized_allowed_attributes
...
...
spec/helpers/gitlab_markdown_helper_spec.rb
View file @
2ea166fc
...
@@ -576,9 +576,21 @@ describe GitlabMarkdownHelper do
...
@@ -576,9 +576,21 @@ describe GitlabMarkdownHelper do
end
end
it
"should generate absolute urls for emoji"
do
it
"should generate absolute urls for emoji"
do
markdown
(
":smile:"
).
should
include
(
"src=
\"
#{
url_helper
(
'emoji/smile'
)
}
"
)
markdown
(
":smile:"
).
should
include
(
"src=
\"
http://localhost/assets/emoji/smile.png
"
)
end
end
it
"should generate absolute urls for emoji if relative url is present"
do
Gitlab
.
config
.
gitlab
.
stub
(
:url
).
and_return
(
'http://localhost/gitlab/root'
)
markdown
(
":smile:"
).
should
include
(
"src=
\"
http://localhost/gitlab/root/assets/emoji/smile.png"
)
end
it
"should generate absolute urls for emoji if asset_host is present"
do
Gitlab
::
Application
.
config
.
stub
(
:asset_host
).
and_return
(
"https://cdn.example.com"
)
ActionView
::
Base
.
any_instance
.
stub_chain
(
:config
,
:asset_host
).
and_return
(
"https://cdn.example.com"
)
markdown
(
":smile:"
).
should
include
(
"src=
\"
https://cdn.example.com/assets/emoji/smile.png"
)
end
it
"should handle relative urls for a file in master"
do
it
"should handle relative urls for a file in master"
do
actual
=
"[GitLab API doc](doc/api/README.md)
\n
"
actual
=
"[GitLab API doc](doc/api/README.md)
\n
"
expected
=
"<p><a href=
\"
/
#{
project
.
path_with_namespace
}
/blob/
#{
@ref
}
/doc/api/README.md
\"
>GitLab API doc</a></p>
\n
"
expected
=
"<p><a href=
\"
/
#{
project
.
path_with_namespace
}
/blob/
#{
@ref
}
/doc/api/README.md
\"
>GitLab API doc</a></p>
\n
"
...
...
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