diff options
Diffstat (limited to 'spec/features/projects/wiki/user_views_wiki_page_spec.rb')
-rw-r--r-- | spec/features/projects/wiki/user_views_wiki_page_spec.rb | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/spec/features/projects/wiki/user_views_wiki_page_spec.rb b/spec/features/projects/wiki/user_views_wiki_page_spec.rb index 9a4ce426e69..4b974a3ca10 100644 --- a/spec/features/projects/wiki/user_views_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_views_wiki_page_spec.rb @@ -2,12 +2,15 @@ require 'spec_helper' describe 'User views a wiki page' do shared_examples 'wiki page user view' do + include WikiHelpers + let(:user) { create(:user) } let(:project) { create(:project, :wiki_repo, namespace: user.namespace) } + let(:path) { 'image.png' } let(:wiki_page) do create(:wiki_page, wiki: project.wiki, - attrs: { title: 'home', content: 'Look at this [image](image.jpg)\n\n ![alt text](image.jpg)' }) + attrs: { title: 'home', content: "Look at this [image](#{path})\n\n ![alt text](#{path})" }) end before do @@ -82,33 +85,26 @@ describe 'User views a wiki page' do expect(find('.wiki-pages')).to have_content(wiki_page.title.capitalize) end - it 'shows a file stored in a page' do - raw_file = Gitlab::GitalyClient::WikiFile.new( - mime_type: 'image/jpeg', - name: 'images/image.jpg', - path: 'images/image.jpg', - raw_data: '' - ) - wiki_file = Gitlab::Git::WikiFile.new(raw_file) - - allow(wiki_file).to receive(:mime_type).and_return('image/jpeg') - allow_any_instance_of(ProjectWiki).to receive(:find_file).with('image.jpg', nil).and_return(wiki_file) + context 'shows a file stored in a page' do + let(:path) { upload_file_to_wiki(project, user, 'dk.png') } - expect(page).to have_xpath("//img[@data-src='#{project.wiki.wiki_base_path}/image.jpg']") - expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/image.jpg") + it do + expect(page).to have_xpath("//img[@data-src='#{project.wiki.wiki_base_path}/#{path}']") + expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/#{path}") - click_on('image') + click_on('image') - expect(current_path).to match('wikis/image.jpg') - expect(page).not_to have_xpath('/html') # Page should render the image which means there is no html involved + expect(current_path).to match("wikis/#{path}") + expect(page).not_to have_xpath('/html') # Page should render the image which means there is no html involved + end end it 'shows the creation page if file does not exist' do - expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/image.jpg") + expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/#{path}") click_on('image') - expect(current_path).to match('wikis/image.jpg') + expect(current_path).to match("wikis/#{path}") expect(page).to have_content('New Wiki Page') expect(page).to have_content('Create page') end |