diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
commit | 41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch) | |
tree | 9c8d89a8624828992f06d892cd2f43818ff5dcc8 /spec/helpers/markup_helper_spec.rb | |
parent | 0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff) |
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'spec/helpers/markup_helper_spec.rb')
-rw-r--r-- | spec/helpers/markup_helper_spec.rb | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb index ab2f6fa5b7e..a7e657f2636 100644 --- a/spec/helpers/markup_helper_spec.rb +++ b/spec/helpers/markup_helper_spec.rb @@ -315,33 +315,27 @@ RSpec.describe MarkupHelper do end describe '#render_wiki_content' do - let(:wiki) { double('WikiPage', path: "file.#{extension}") } - let(:wiki_repository) { double('Repository') } + let(:wiki) { build(:wiki, container: project) } let(:content) { 'wiki content' } + let(:slug) { 'nested/page' } + let(:path) { "file.#{extension}" } + let(:wiki_page) { double('WikiPage', path: path, content: content, slug: slug, wiki: wiki) } + let(:context) do { pipeline: :wiki, project: project, wiki: wiki, - page_slug: 'nested/page', issuable_reference_expansion_enabled: true, - repository: wiki_repository + page_slug: slug, issuable_reference_expansion_enabled: true, + repository: wiki.repository, requested_path: path } end - before do - expect(wiki).to receive(:content).and_return(content) - expect(wiki).to receive(:slug).and_return('nested/page') - expect(wiki).to receive(:repository).and_return(wiki_repository) - allow(wiki).to receive(:container).and_return(project) - - helper.instance_variable_set(:@wiki, wiki) - end - context 'when file is Markdown' do let(:extension) { 'md' } it 'renders using #markdown_unsafe helper method' do expect(helper).to receive(:markdown_unsafe).with('wiki content', context) - helper.render_wiki_content(wiki) + helper.render_wiki_content(wiki_page) end context 'when context has labels' do @@ -350,7 +344,7 @@ RSpec.describe MarkupHelper do let(:content) { '~Bug' } it 'renders label' do - result = helper.render_wiki_content(wiki) + result = helper.render_wiki_content(wiki_page) doc = Nokogiri::HTML.parse(result) expect(doc.css('.gl-label-link')).not_to be_empty @@ -366,7 +360,7 @@ RSpec.describe MarkupHelper do end it 'renders uploads relative to project' do - result = helper.render_wiki_content(wiki) + result = helper.render_wiki_content(wiki_page) expect(result).to include("#{project.full_path}#{upload_link}") end @@ -379,7 +373,7 @@ RSpec.describe MarkupHelper do it 'renders using Gitlab::Asciidoc' do expect(Gitlab::Asciidoc).to receive(:render) - helper.render_wiki_content(wiki) + helper.render_wiki_content(wiki_page) end end @@ -398,7 +392,7 @@ FooBar it 'renders using #markdown_unsafe helper method' do expect(helper).to receive(:markdown_unsafe).with(content, context) - result = helper.render_wiki_content(wiki) + result = helper.render_wiki_content(wiki_page) expect(result).to be_empty end @@ -410,7 +404,7 @@ FooBar it 'renders all other formats using Gitlab::OtherMarkup' do expect(Gitlab::OtherMarkup).to receive(:render) - helper.render_wiki_content(wiki) + helper.render_wiki_content(wiki_page) end end end |