2014-04-09 07:35:58 -04:00
|
|
|
class Spinach::Features::ProjectWiki < Spinach::FeatureSteps
|
2012-09-10 11:35:03 -04:00
|
|
|
include SharedAuthentication
|
|
|
|
include SharedProject
|
|
|
|
include SharedNote
|
|
|
|
include SharedPaths
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I click on the Cancel button' do
|
2015-12-02 07:59:42 -05:00
|
|
|
page.within(:css, ".wiki-form .form-actions") do
|
2013-03-20 00:28:10 -04:00
|
|
|
click_on "Cancel"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should be redirected back to the Edit Home Wiki page' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(current_path).to eq namespace_project_wiki_path(project.namespace, project, :home)
|
2013-03-20 00:28:10 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I create the Wiki Home page' do
|
2014-04-09 07:35:58 -04:00
|
|
|
fill_in "wiki_content", with: '[link test](test)'
|
2013-08-02 05:15:30 -04:00
|
|
|
click_on "Create page"
|
2012-09-10 11:35:03 -04:00
|
|
|
end
|
|
|
|
|
2016-07-21 22:55:59 -04:00
|
|
|
step 'I create the Wiki Home page with no content' do
|
|
|
|
fill_in "wiki_content", with: ''
|
|
|
|
click_on "Create page"
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should see the newly created wiki page' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content "Home"
|
|
|
|
expect(page).to have_content "link test"
|
2012-09-10 11:35:03 -04:00
|
|
|
|
|
|
|
click_link "link test"
|
2015-12-02 07:59:42 -05:00
|
|
|
expect(page).to have_content "Edit Page"
|
2012-09-10 11:35:03 -04:00
|
|
|
end
|
2013-03-10 17:37:26 -04:00
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I have an existing Wiki page' do
|
2013-03-10 17:37:26 -04:00
|
|
|
wiki.create_page("existing", "content", :markdown, "first commit")
|
|
|
|
@page = wiki.find_page("existing")
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I browse to that Wiki page' do
|
2015-01-24 13:02:58 -05:00
|
|
|
visit namespace_project_wiki_path(project.namespace, project, @page)
|
2013-03-10 17:37:26 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I click on the Edit button' do
|
2013-03-10 17:37:26 -04:00
|
|
|
click_on "Edit"
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I change the content' do
|
2013-05-05 10:01:10 -04:00
|
|
|
fill_in "Content", with: 'Updated Wiki Content'
|
2013-08-02 05:15:30 -04:00
|
|
|
click_on "Save changes"
|
2013-03-10 17:37:26 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should see the updated content' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content "Updated Wiki Content"
|
2013-03-10 17:37:26 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should be redirected back to that Wiki page' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(current_path).to eq namespace_project_wiki_path(project.namespace, project, @page)
|
2013-03-20 00:28:10 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'That page has two revisions' do
|
2013-03-10 17:37:26 -04:00
|
|
|
@page.update("new content", :markdown, "second commit")
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I click the History button' do
|
2013-03-10 17:37:26 -04:00
|
|
|
click_on "History"
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should see both revisions' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content current_user.name
|
|
|
|
expect(page).to have_content "first commit"
|
|
|
|
expect(page).to have_content "second commit"
|
2013-03-10 17:37:26 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I click on the "Delete this page" button' do
|
2015-12-02 07:59:42 -05:00
|
|
|
click_on "Delete"
|
2013-03-10 17:37:26 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'The page should be deleted' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content "Page was successfully deleted"
|
2013-03-10 17:37:26 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I click on the "Pages" button' do
|
2013-03-10 17:37:26 -04:00
|
|
|
click_on "Pages"
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should see the existing page in the pages list' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content current_user.name
|
|
|
|
expect(page).to have_content @page.title
|
2013-03-10 17:37:26 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I have an existing Wiki page with images linked on page' do
|
2016-03-30 18:03:49 -04:00
|
|
|
wiki.create_page("pictures", "Look at this [image](image.jpg)\n\n ![alt text](image.jpg)", :markdown, "first commit")
|
2014-05-05 07:47:47 -04:00
|
|
|
@wiki_page = wiki.find_page("pictures")
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I browse to wiki page with images' do
|
2015-01-24 13:02:58 -05:00
|
|
|
visit namespace_project_wiki_path(project.namespace, project, @wiki_page)
|
2014-05-05 07:47:47 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I click on existing image link' do
|
2014-05-06 03:57:08 -04:00
|
|
|
file = Gollum::File.new(wiki.wiki)
|
|
|
|
Gollum::Wiki.any_instance.stub(:file).with("image.jpg", "master", true).and_return(file)
|
|
|
|
Gollum::File.any_instance.stub(:mime_type).and_return("image/jpeg")
|
2016-06-08 01:02:50 -04:00
|
|
|
expect(page).to have_link('image', href: "#{wiki.wiki_base_path}/image.jpg")
|
2014-05-05 07:47:47 -04:00
|
|
|
click_on "image"
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should see the image from wiki repo' do
|
2015-06-12 00:44:13 -04:00
|
|
|
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
|
2014-05-07 05:52:07 -04:00
|
|
|
Gollum::Wiki.any_instance.unstub(:file)
|
|
|
|
Gollum::File.any_instance.unstub(:mime_type)
|
2014-05-05 07:47:47 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'Image should be shown on the page' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_xpath("//img[@src=\"image.jpg\"]")
|
2014-05-05 07:47:47 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I click on image link' do
|
2016-06-08 01:02:50 -04:00
|
|
|
expect(page).to have_link('image', href: "#{wiki.wiki_base_path}/image.jpg")
|
2014-05-05 07:47:47 -04:00
|
|
|
click_on "image"
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should see the new wiki page form' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(current_path).to match('wikis/image.jpg')
|
|
|
|
expect(page).to have_content('New Wiki Page')
|
2016-02-08 17:56:45 -05:00
|
|
|
expect(page).to have_content('Edit Page')
|
2014-05-05 07:47:47 -04:00
|
|
|
end
|
|
|
|
|
2015-04-07 11:58:12 -04:00
|
|
|
step 'I create a New page with paths' do
|
|
|
|
click_on 'New Page'
|
2016-07-24 08:57:26 -04:00
|
|
|
fill_in 'Page slug', with: 'one/two/three-test'
|
2015-12-02 07:59:42 -05:00
|
|
|
click_on 'Create Page'
|
2015-04-07 11:58:12 -04:00
|
|
|
fill_in "wiki_content", with: 'wiki content'
|
|
|
|
click_on "Create page"
|
2016-07-24 08:57:26 -04:00
|
|
|
expect(current_path).to include 'one/two/three-test'
|
2015-04-07 11:58:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see non-escaped link in the pages list' do
|
2016-07-24 08:57:26 -04:00
|
|
|
expect(page).to have_xpath("//a[@href='/#{project.path_with_namespace}/wikis/one/two/three-test']")
|
2015-04-07 11:58:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I edit the Wiki page with a path' do
|
2016-08-11 12:48:32 -04:00
|
|
|
expect(page).to have_content('three')
|
2015-04-07 11:58:12 -04:00
|
|
|
click_on 'three'
|
2016-08-11 12:48:32 -04:00
|
|
|
expect(find('.nav-text')).to have_content('Three')
|
2015-04-07 11:58:12 -04:00
|
|
|
click_on 'Edit'
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see a non-escaped path' do
|
2016-07-24 08:57:26 -04:00
|
|
|
expect(current_path).to include 'one/two/three-test'
|
2015-04-07 11:58:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see the Editing page' do
|
2015-12-03 12:42:37 -05:00
|
|
|
expect(page).to have_content('Edit Page')
|
2015-04-07 11:58:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I view the page history of a Wiki page that has a path' do
|
|
|
|
click_on 'three'
|
|
|
|
click_on 'Page History'
|
|
|
|
end
|
|
|
|
|
2015-09-01 20:57:56 -04:00
|
|
|
step 'I click on Page History' do
|
|
|
|
click_on 'Page History'
|
|
|
|
end
|
|
|
|
|
2015-04-07 11:58:12 -04:00
|
|
|
step 'I should see the page history' do
|
2016-02-08 17:56:45 -05:00
|
|
|
page.within(:css, ".nav-text") do
|
|
|
|
expect(page).to have_content('History')
|
|
|
|
end
|
2015-04-07 11:58:12 -04:00
|
|
|
end
|
|
|
|
|
2015-04-30 11:40:21 -04:00
|
|
|
step 'I search for Wiki content' do
|
2016-01-21 21:18:03 -05:00
|
|
|
fill_in "Search", with: "wiki_content"
|
2015-04-30 11:40:21 -04:00
|
|
|
click_button "Search"
|
|
|
|
end
|
|
|
|
|
2015-09-01 20:57:56 -04:00
|
|
|
step 'I should see a link with a version ID' do
|
|
|
|
find('a[href*="?version_id"]')
|
|
|
|
end
|
|
|
|
|
2016-07-21 22:55:59 -04:00
|
|
|
step 'I should see a "Content can\'t be blank" error message' do
|
|
|
|
expect(page).to have_content('The form contains the following error:')
|
|
|
|
expect(page).to have_content('Content can\'t be blank')
|
|
|
|
end
|
|
|
|
|
2013-03-10 17:37:26 -04:00
|
|
|
def wiki
|
2014-04-09 07:35:58 -04:00
|
|
|
@project_wiki = ProjectWiki.new(project, current_user)
|
2013-03-10 17:37:26 -04:00
|
|
|
end
|
2012-09-10 11:35:03 -04:00
|
|
|
end
|