diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2018-10-17 18:47:05 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-10-17 18:47:05 +0300 |
commit | b8cf360e2ae446db1f21c0275e2047d776730a05 (patch) | |
tree | 08aad72c9813659459247c74fc46b6db4bc2cd91 /spec/features/projects | |
parent | 11152ddf3d4f977232676fea38eca28b7b6e6ddd (diff) |
Fixed bug with the content disposition with wiki attachments
Diffstat (limited to 'spec/features/projects')
-rw-r--r-- | spec/features/projects/wiki/user_views_wiki_empty_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/projects/wiki/user_views_wiki_page_spec.rb | 34 |
2 files changed, 16 insertions, 20 deletions
diff --git a/spec/features/projects/wiki/user_views_wiki_empty_spec.rb b/spec/features/projects/wiki/user_views_wiki_empty_spec.rb index 83ffbb4a94e..e94b3a9432b 100644 --- a/spec/features/projects/wiki/user_views_wiki_empty_spec.rb +++ b/spec/features/projects/wiki/user_views_wiki_empty_spec.rb @@ -54,7 +54,7 @@ describe 'User views empty wiki' do it_behaves_like 'empty wiki and non-accessible issues' end - context 'when user is logged in and a memeber' do + context 'when user is logged in and a member' do let(:project) { create(:project, :public, :wiki_repo) } before do 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 |