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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
a8c836c3
Commit
a8c836c3
authored
Jan 12, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for the wiki pipeline
parent
765a2c73
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
5 deletions
+89
-5
spec/features/markdown_spec.rb
spec/features/markdown_spec.rb
+58
-5
spec/fixtures/markdown.md.erb
spec/fixtures/markdown.md.erb
+9
-0
spec/support/markdown_feature.rb
spec/support/markdown_feature.rb
+4
-0
spec/support/matchers/markdown_matchers.rb
spec/support/matchers/markdown_matchers.rb
+18
-0
No files found.
spec/features/markdown_spec.rb
View file @
a8c836c3
...
@@ -175,13 +175,15 @@ describe 'GitLab Markdown', feature: true do
...
@@ -175,13 +175,15 @@ describe 'GitLab Markdown', feature: true do
end
end
end
end
context
'default pipeline'
do
before
(
:all
)
do
before
(
:all
)
do
@feat
=
MarkdownFeature
.
new
@feat
=
MarkdownFeature
.
new
# `markdown` helper expects a `@project` variable
# `markdown` helper expects a `@project` variable
@project
=
@feat
.
project
@project
=
@feat
.
project
end
context
'default pipeline'
do
before
(
:all
)
do
@html
=
markdown
(
@feat
.
raw_markdown
)
@html
=
markdown
(
@feat
.
raw_markdown
)
end
end
...
@@ -221,6 +223,57 @@ describe 'GitLab Markdown', feature: true do
...
@@ -221,6 +223,57 @@ describe 'GitLab Markdown', feature: true do
end
end
end
end
context
'wiki pipeline'
do
before
do
@project_wiki
=
@feat
.
project_wiki
file
=
Gollum
::
File
.
new
(
@project_wiki
.
wiki
)
expect
(
file
).
to
receive
(
:path
).
and_return
(
'images/example.jpg'
)
expect
(
@project_wiki
).
to
receive
(
:find_file
).
with
(
'images/example.jpg'
).
and_return
(
file
)
@html
=
markdown
(
@feat
.
raw_markdown
,
{
pipeline: :wiki
,
project_wiki:
@project_wiki
})
end
it_behaves_like
'all pipelines'
it
'includes RelativeLinkFilter'
do
expect
(
doc
).
not_to
parse_relative_links
end
it
'includes EmojiFilter'
do
expect
(
doc
).
to
parse_emoji
end
it
'includes TableOfContentsFilter'
do
expect
(
doc
).
to
create_header_links
end
it
'includes AutolinkFilter'
do
expect
(
doc
).
to
create_autolinks
end
it
'includes all reference filters'
do
aggregate_failures
do
expect
(
doc
).
to
reference_users
expect
(
doc
).
to
reference_issues
expect
(
doc
).
to
reference_merge_requests
expect
(
doc
).
to
reference_snippets
expect
(
doc
).
to
reference_commit_ranges
expect
(
doc
).
to
reference_commits
expect
(
doc
).
to
reference_labels
expect
(
doc
).
to
reference_milestones
end
end
it
'includes TaskListFilter'
do
expect
(
doc
).
to
parse_task_lists
end
it
'includes GollumTagsFilter'
do
expect
(
doc
).
to
parse_gollum_tags
end
end
# Fake a `current_user` helper
# Fake a `current_user` helper
def
current_user
def
current_user
@feat
.
user
@feat
.
user
...
...
spec/fixtures/markdown.md.erb
View file @
a8c836c3
...
@@ -230,3 +230,12 @@ References should be parseable even inside _<%= merge_request.to_reference %>_ e
...
@@ -230,3 +230,12 @@ References should be parseable even inside _<%= merge_request.to_reference %>_ e
- [ ] Incomplete sub-task 2
- [ ] Incomplete sub-task 2
- [x] Complete sub-task 1
- [x] Complete sub-task 1
- [X] Complete task 2
- [X] Complete task 2
#### Gollum Tags
- [[linked-resource]]
- [[link-text|linked-resource]]
- [[http://example.com]]
- [[link-text|http://example.com/pdfs/gollum.pdf]]
- [[images/example.jpg]]
- [[http://example.com/images/example.jpg]]
spec/support/markdown_feature.rb
View file @
a8c836c3
...
@@ -28,6 +28,10 @@ class MarkdownFeature
...
@@ -28,6 +28,10 @@ class MarkdownFeature
end
end
end
end
def
project_wiki
@project_wiki
||=
ProjectWiki
.
new
(
project
,
user
)
end
def
issue
def
issue
@issue
||=
create
(
:issue
,
project:
project
)
@issue
||=
create
(
:issue
,
project:
project
)
end
end
...
...
spec/support/matchers/markdown_matchers.rb
View file @
a8c836c3
...
@@ -66,6 +66,24 @@ module MarkdownMatchers
...
@@ -66,6 +66,24 @@ module MarkdownMatchers
end
end
end
end
# GollumTagsFilter
matcher
:parse_gollum_tags
do
def
have_image
(
src
)
have_css
(
"img[src*='
#{
src
}
']"
)
end
set_default_markdown_messages
match
do
|
actual
|
expect
(
actual
).
to
have_link
(
'linked-resource'
,
href:
'linked-resource'
)
expect
(
actual
).
to
have_link
(
'link-text'
,
href:
'linked-resource'
)
expect
(
actual
).
to
have_link
(
'http://example.com'
,
href:
'http://example.com'
)
expect
(
actual
).
to
have_link
(
'link-text'
,
href:
'http://example.com/pdfs/gollum.pdf'
)
expect
(
actual
).
to
have_image
(
'/namespace1/gitlabhq/wikis/images/example.jpg'
)
expect
(
actual
).
to
have_image
(
'http://example.com/images/example.jpg'
)
end
end
# UserReferenceFilter
# UserReferenceFilter
matcher
:reference_users
do
matcher
:reference_users
do
set_default_markdown_messages
set_default_markdown_messages
...
...
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