Commit 5a949e609512cdabd7885712a37e04095d1f4600
1 parent
4146e885
Exists in
spb-stable
and in
2 other branches
Add tests for wiki files showing.
Showing
2 changed files
with
55 additions
and
0 deletions
Show diff stats
features/project/wiki.feature
... | ... | @@ -45,3 +45,20 @@ Feature: Project Wiki |
45 | 45 | And I browse to that Wiki page |
46 | 46 | And I click on the "Pages" button |
47 | 47 | Then I should see the existing page in the pages list |
48 | + | |
49 | + Scenario: Image in wiki repo shown on the page | |
50 | + Given I have an existing Wiki page with images linked on page | |
51 | + And I browse to wiki page with images | |
52 | + Then Image should be shown on the page | |
53 | + | |
54 | + Scenario: File does not exist in wiki repo | |
55 | + Given I have an existing Wiki page with images linked on page | |
56 | + And I browse to wiki page with images | |
57 | + And I click on image link | |
58 | + Then I should see the new wiki page form | |
59 | + | |
60 | + Scenario: File exists in wiki repo | |
61 | + Given I have an existing Wiki page with images linked on page | |
62 | + And I browse to wiki page with images | |
63 | + And I click on existing image link | |
64 | + Then I should see the image from wiki repo | ... | ... |
features/steps/project/wiki.rb
... | ... | @@ -86,6 +86,44 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps |
86 | 86 | page.should have_content @page.title |
87 | 87 | end |
88 | 88 | |
89 | + Given 'I have an existing Wiki page with images linked on page' do | |
90 | + wiki.create_page("pictures", "Look at this [image](image.jpg)\n\n ", :markdown, "first commit") | |
91 | + @wiki_page = wiki.find_page("pictures") | |
92 | + end | |
93 | + | |
94 | + And 'I browse to wiki page with images' do | |
95 | + visit project_wiki_path(project, @wiki_page) | |
96 | + end | |
97 | + | |
98 | + And 'I click on existing image link' do | |
99 | + Gollum::Wiki.any_instance.should_receive(:file).with("image.jpg", "master", true).and_return(Gollum::File.new(wiki.wiki)) | |
100 | + Gollum::File.any_instance.should_receive(:mime_type).and_return("image/jpeg") | |
101 | + page.should have_link('image', href: "image.jpg") | |
102 | + click_on "image" | |
103 | + end | |
104 | + | |
105 | + Then 'I should see the image from wiki repo' do | |
106 | + url = URI.parse(current_url) | |
107 | + url.path.should match("wikis/image.jpg") | |
108 | + page.should_not have_xpath('/html') # Page should render the image which means there is no html involved | |
109 | + end | |
110 | + | |
111 | + Then 'Image should be shown on the page' do | |
112 | + page.should have_xpath("//img[@src=\"image.jpg\"]") | |
113 | + end | |
114 | + | |
115 | + And 'I click on image link' do | |
116 | + page.should have_link('image', href: "image.jpg") | |
117 | + click_on "image" | |
118 | + end | |
119 | + | |
120 | + Then 'I should see the new wiki page form' do | |
121 | + url = URI.parse(current_url) | |
122 | + url.path.should match("wikis/image.jpg") | |
123 | + page.should have_content('New Wiki Page') | |
124 | + page.should have_content('Editing - image.jpg') | |
125 | + end | |
126 | + | |
89 | 127 | def wiki |
90 | 128 | @project_wiki = ProjectWiki.new(project, current_user) |
91 | 129 | end | ... | ... |