diff options
author | Marin Jankovski <marin@gitlab.com> | 2014-05-05 15:47:47 +0400 |
---|---|---|
committer | Marin Jankovski <marin@gitlab.com> | 2014-05-05 15:47:47 +0400 |
commit | 5a949e609512cdabd7885712a37e04095d1f4600 (patch) | |
tree | 4849c1cc7cc335b34c30acbdb737ac0de53ad8cc /features/steps/project | |
parent | 4146e885dde2338b25c1a176ede2f5a2d0946f96 (diff) |
Add tests for wiki files showing.
Diffstat (limited to 'features/steps/project')
-rw-r--r-- | features/steps/project/wiki.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/features/steps/project/wiki.rb b/features/steps/project/wiki.rb index a819ee37d7f..4195ce5b28c 100644 --- a/features/steps/project/wiki.rb +++ b/features/steps/project/wiki.rb @@ -86,6 +86,44 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps page.should have_content @page.title end + Given 'I have an existing Wiki page with images linked on page' do + wiki.create_page("pictures", "Look at this [image](image.jpg)\n\n ![image](image.jpg)", :markdown, "first commit") + @wiki_page = wiki.find_page("pictures") + end + + And 'I browse to wiki page with images' do + visit project_wiki_path(project, @wiki_page) + end + + And 'I click on existing image link' do + Gollum::Wiki.any_instance.should_receive(:file).with("image.jpg", "master", true).and_return(Gollum::File.new(wiki.wiki)) + Gollum::File.any_instance.should_receive(:mime_type).and_return("image/jpeg") + page.should have_link('image', href: "image.jpg") + click_on "image" + end + + Then 'I should see the image from wiki repo' do + url = URI.parse(current_url) + url.path.should match("wikis/image.jpg") + page.should_not have_xpath('/html') # Page should render the image which means there is no html involved + end + + Then 'Image should be shown on the page' do + page.should have_xpath("//img[@src=\"image.jpg\"]") + end + + And 'I click on image link' do + page.should have_link('image', href: "image.jpg") + click_on "image" + end + + Then 'I should see the new wiki page form' do + url = URI.parse(current_url) + url.path.should match("wikis/image.jpg") + page.should have_content('New Wiki Page') + page.should have_content('Editing - image.jpg') + end + def wiki @project_wiki = ProjectWiki.new(project, current_user) end |