Add tests for the wiki pipeline

parent 765a2c73
...@@ -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
......
...@@ -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]]
...@@ -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
......
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment