Add tests for the wiki pipeline

parent 765a2c73
......@@ -175,13 +175,15 @@ describe 'GitLab Markdown', feature: true do
end
end
context 'default pipeline' do
before(:all) do
@feat = MarkdownFeature.new
before(:all) do
@feat = MarkdownFeature.new
# `markdown` helper expects a `@project` variable
@project = @feat.project
# `markdown` helper expects a `@project` variable
@project = @feat.project
end
context 'default pipeline' do
before(:all) do
@html = markdown(@feat.raw_markdown)
end
......@@ -221,6 +223,57 @@ describe 'GitLab Markdown', feature: true do
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
def current_user
@feat.user
......
......@@ -230,3 +230,12 @@ References should be parseable even inside _<%= merge_request.to_reference %>_ e
- [ ] Incomplete sub-task 2
- [x] Complete sub-task 1
- [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
end
end
def project_wiki
@project_wiki ||= ProjectWiki.new(project, user)
end
def issue
@issue ||= create(:issue, project: project)
end
......
......@@ -66,6 +66,24 @@ module MarkdownMatchers
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
matcher :reference_users do
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