Commit 8300ae366cc2a2e342002a96e735445e8bf15f14

Authored by Dan Knox
1 parent 6880ace1

Fix the Cancel button on the Edit Wiki page.

The Cancel button on the Edit Wiki page was still redirecting back
to the "Index" page which is no longer the default Wiki page.

This commit changes the Cancel button in the following ways:

  * Pressing Cancel while editing an existing Wiki page will now
    redirect you back to the latest version of that page.
  * Pressing Cancel while editing a brand new Wiki home page that
    does not yet exist will redirect you to back to the same Edit
    Wiki Home page.
app/views/wikis/_form.html.haml
... ... @@ -30,4 +30,7 @@
30 30 .input= f.text_field :message, class: 'span8'
31 31 .actions
32 32 = f.submit 'Save', class: "btn-save btn"
33   - = link_to "Cancel", project_wiki_path(@project, :index), class: "btn btn-cancel"
  33 + - if @wiki && @wiki.persisted?
  34 + = link_to "Cancel", project_wiki_path(@project, @wiki), class: "btn btn-cancel"
  35 + - else
  36 + = link_to "Cancel", project_wiki_path(@project, :home), class: "btn btn-cancel"
... ...
features/project/wiki.feature
... ... @@ -8,6 +8,10 @@ Feature: Project Wiki
8 8 Given I create the Wiki Home page
9 9 Then I should see the newly created wiki page
10 10  
  11 + Scenario: Pressing Cancel while editing a brand new Wiki
  12 + Given I click on the Cancel button
  13 + Then I should be redirected back to the Edit Home Wiki page
  14 +
11 15 Scenario: Edit existing page
12 16 Given I have an existing Wiki page
13 17 And I browse to that Wiki page
... ... @@ -15,6 +19,13 @@ Feature: Project Wiki
15 19 And I change the content
16 20 Then I should see the updated content
17 21  
  22 + Scenario: Pressing Cancel while editing an existing Wiki page
  23 + Given I have an existing Wiki page
  24 + And I browse to that Wiki page
  25 + And I click on the Edit button
  26 + And I click on the Cancel button
  27 + Then I should be redirected back to that Wiki page
  28 +
18 29 Scenario: View page history
19 30 Given I have an existing wiki page
20 31 And That page has two revisions
... ...
features/steps/project/project_wiki.rb
... ... @@ -4,6 +4,17 @@ class ProjectWiki < Spinach::FeatureSteps
4 4 include SharedNote
5 5 include SharedPaths
6 6  
  7 + Given 'I click on the Cancel button' do
  8 + within(:css, ".actions") do
  9 + click_on "Cancel"
  10 + end
  11 + end
  12 +
  13 + Then 'I should be redirected back to the Edit Home Wiki page' do
  14 + url = URI.parse(current_url)
  15 + url.path.should == project_wiki_path(project, :home)
  16 + end
  17 +
7 18 Given 'I create the Wiki Home page' do
8 19 fill_in "Content", :with => '[link test](test)'
9 20 click_on "Save"
... ... @@ -39,6 +50,11 @@ class ProjectWiki < Spinach::FeatureSteps
39 50 page.should have_content "Updated Wiki Content"
40 51 end
41 52  
  53 + Then 'I should be redirected back to that Wiki page' do
  54 + url = URI.parse(current_url)
  55 + url.path.should == project_wiki_path(project, @page)
  56 + end
  57 +
42 58 And 'That page has two revisions' do
43 59 @page.update("new content", :markdown, "second commit")
44 60 end
... ...