Add Spinach coverage for Gollum Wiki system and correct the Delete link.
The previously failing Spinach steps have been fixed with this commit. I have also added new steps that cover the entire usage of the Wiki system. The new Spinach steps revealed a minor bug in the Delete page process. The path for the "Delete this page" button was previously set to `project_wikis_page(@project, @wiki)` when it should have been using the singular `project_wiki_page(@project, @wiki)` path helper. The link has been corrected and all steps are now passing.
This commit is contained in:
parent
ea9b3687db
commit
1479f17227
5 changed files with 102 additions and 10 deletions
|
@ -5,6 +5,6 @@
|
||||||
= render 'form'
|
= render 'form'
|
||||||
|
|
||||||
.pull-right
|
.pull-right
|
||||||
- if can? current_user, :admin_wiki, @project
|
- if @wiki.persisted? && can?(current_user, :admin_wiki, @project)
|
||||||
= link_to project_wikis_path(@project, @wiki), confirm: "Are you sure you want to delete this page?", method: :delete, class: "btn btn-small btn-remove" do
|
= link_to project_wiki_path(@project, @wiki), confirm: "Are you sure you want to delete this page?", method: :delete, class: "btn btn-small btn-remove" do
|
||||||
Delete this page
|
Delete this page
|
||||||
|
|
|
@ -5,5 +5,32 @@ Feature: Project Wiki
|
||||||
Given I visit project wiki page
|
Given I visit project wiki page
|
||||||
|
|
||||||
Scenario: Add new page
|
Scenario: Add new page
|
||||||
Given I create Wiki page
|
Given I create the Wiki Home page
|
||||||
Then I should see newly created wiki page
|
Then I should see the newly created wiki page
|
||||||
|
|
||||||
|
Scenario: Edit existing page
|
||||||
|
Given I have an existing Wiki page
|
||||||
|
And I browse to that Wiki page
|
||||||
|
And I click on the Edit button
|
||||||
|
And I change the content
|
||||||
|
Then I should see the updated content
|
||||||
|
|
||||||
|
Scenario: View page history
|
||||||
|
Given I have an existing wiki page
|
||||||
|
And That page has two revisions
|
||||||
|
And I browse to that Wiki page
|
||||||
|
And I click the History button
|
||||||
|
Then I should see both revisions
|
||||||
|
|
||||||
|
Scenario: Destroy Wiki page
|
||||||
|
Given I have an existing wiki page
|
||||||
|
And I browse to that Wiki page
|
||||||
|
And I click on the Edit button
|
||||||
|
And I click on the "Delete this page" button
|
||||||
|
Then The page should be deleted
|
||||||
|
|
||||||
|
Scenario: View all pages
|
||||||
|
Given I have an existing wiki page
|
||||||
|
And I browse to that Wiki page
|
||||||
|
And I click on the "Pages" button
|
||||||
|
Then I should see the existing page in the pages list
|
||||||
|
|
|
@ -4,17 +4,73 @@ class ProjectWiki < Spinach::FeatureSteps
|
||||||
include SharedNote
|
include SharedNote
|
||||||
include SharedPaths
|
include SharedPaths
|
||||||
|
|
||||||
Given 'I create Wiki page' do
|
Given 'I create the Wiki Home page' do
|
||||||
fill_in "Title", :with => 'Test title'
|
|
||||||
fill_in "Content", :with => '[link test](test)'
|
fill_in "Content", :with => '[link test](test)'
|
||||||
click_on "Save"
|
click_on "Save"
|
||||||
end
|
end
|
||||||
|
|
||||||
Then 'I should see newly created wiki page' do
|
Then 'I should see the newly created wiki page' do
|
||||||
page.should have_content "Test title"
|
page.should have_content "Home"
|
||||||
page.should have_content "link test"
|
page.should have_content "link test"
|
||||||
|
|
||||||
click_link "link test"
|
click_link "link test"
|
||||||
page.should have_content "Editing page"
|
page.should have_content "Editing page"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Given 'I have an existing Wiki page' do
|
||||||
|
wiki.create_page("existing", "content", :markdown, "first commit")
|
||||||
|
@page = wiki.find_page("existing")
|
||||||
|
end
|
||||||
|
|
||||||
|
And 'I browse to that Wiki page' do
|
||||||
|
visit project_wiki_path(project, @page)
|
||||||
|
end
|
||||||
|
|
||||||
|
And 'I click on the Edit button' do
|
||||||
|
click_on "Edit"
|
||||||
|
end
|
||||||
|
|
||||||
|
And 'I change the content' do
|
||||||
|
fill_in "Content", :with => 'Updated Wiki Content'
|
||||||
|
click_on "Save"
|
||||||
|
end
|
||||||
|
|
||||||
|
Then 'I should see the updated content' do
|
||||||
|
page.should have_content "Updated Wiki Content"
|
||||||
|
end
|
||||||
|
|
||||||
|
And 'That page has two revisions' do
|
||||||
|
@page.update("new content", :markdown, "second commit")
|
||||||
|
end
|
||||||
|
|
||||||
|
And 'I click the History button' do
|
||||||
|
click_on "History"
|
||||||
|
end
|
||||||
|
|
||||||
|
Then 'I should see both revisions' do
|
||||||
|
page.should have_content current_user.name
|
||||||
|
page.should have_content "first commit"
|
||||||
|
page.should have_content "second commit"
|
||||||
|
end
|
||||||
|
|
||||||
|
And 'I click on the "Delete this page" button' do
|
||||||
|
click_on "Delete this page"
|
||||||
|
end
|
||||||
|
|
||||||
|
Then 'The page should be deleted' do
|
||||||
|
page.should have_content "Page was successfully deleted"
|
||||||
|
end
|
||||||
|
|
||||||
|
And 'I click on the "Pages" button' do
|
||||||
|
click_on "Pages"
|
||||||
|
end
|
||||||
|
|
||||||
|
Then 'I should see the existing page in the pages list' do
|
||||||
|
page.should have_content current_user.name
|
||||||
|
page.should have_content @page.title.titleize
|
||||||
|
end
|
||||||
|
|
||||||
|
def wiki
|
||||||
|
@gollum_wiki = GollumWiki.new(project, current_user)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -161,7 +161,7 @@ module SharedPaths
|
||||||
end
|
end
|
||||||
|
|
||||||
Given "I visit my project's wiki page" do
|
Given "I visit my project's wiki page" do
|
||||||
visit project_wiki_path(@project, :index)
|
visit project_wiki_path(@project, :home)
|
||||||
end
|
end
|
||||||
|
|
||||||
When 'I visit project hooks page' do
|
When 'I visit project hooks page' do
|
||||||
|
@ -256,7 +256,7 @@ module SharedPaths
|
||||||
end
|
end
|
||||||
|
|
||||||
Given 'I visit project wiki page' do
|
Given 'I visit project wiki page' do
|
||||||
visit project_wiki_path(@project, :index)
|
visit project_wiki_path(@project, :home)
|
||||||
end
|
end
|
||||||
|
|
||||||
def root_ref
|
def root_ref
|
||||||
|
|
|
@ -32,6 +32,9 @@ DatabaseCleaner.strategy = :truncation
|
||||||
Spinach.hooks.before_scenario do
|
Spinach.hooks.before_scenario do
|
||||||
# Use tmp dir for FS manipulations
|
# Use tmp dir for FS manipulations
|
||||||
Gitlab.config.gitlab_shell.stub(repos_path: Rails.root.join('tmp', 'test-git-base-path'))
|
Gitlab.config.gitlab_shell.stub(repos_path: Rails.root.join('tmp', 'test-git-base-path'))
|
||||||
|
Gitlab::Shell.any_instance.stub(:add_repository) do |path|
|
||||||
|
create_temp_repo("#{Rails.root}/tmp/test-git-base-path/#{path}.git")
|
||||||
|
end
|
||||||
FileUtils.rm_rf Gitlab.config.gitlab_shell.repos_path
|
FileUtils.rm_rf Gitlab.config.gitlab_shell.repos_path
|
||||||
FileUtils.mkdir_p Gitlab.config.gitlab_shell.repos_path
|
FileUtils.mkdir_p Gitlab.config.gitlab_shell.repos_path
|
||||||
DatabaseCleaner.start
|
DatabaseCleaner.start
|
||||||
|
@ -46,3 +49,9 @@ Spinach.hooks.before_run do
|
||||||
|
|
||||||
include FactoryGirl::Syntax::Methods
|
include FactoryGirl::Syntax::Methods
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_temp_repo(path)
|
||||||
|
FileUtils.mkdir_p path
|
||||||
|
command = "git init --quiet --bare #{path};"
|
||||||
|
system(command)
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue