Commit 67bda08cbe807c4a789e5e35c8cd0b795fa6b787
Exists in
master
and in
4 other branches
Merge pull request #3266 from DanKnox/fix_wiki_cancel_edit_button
Fix the Cancel button on the Edit Wiki page.
Showing
3 changed files
with
31 additions
and
1 deletions
Show diff stats
app/views/wikis/_form.html.haml
| @@ -30,4 +30,7 @@ | @@ -30,4 +30,7 @@ | ||
| 30 | .input= f.text_field :message, class: 'span8' | 30 | .input= f.text_field :message, class: 'span8' |
| 31 | .actions | 31 | .actions |
| 32 | = f.submit 'Save', class: "btn-save btn" | 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,6 +8,10 @@ Feature: Project Wiki | ||
| 8 | Given I create the Wiki Home page | 8 | Given I create the Wiki Home page |
| 9 | Then I should see the newly created wiki page | 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 | Scenario: Edit existing page | 15 | Scenario: Edit existing page |
| 12 | Given I have an existing Wiki page | 16 | Given I have an existing Wiki page |
| 13 | And I browse to that Wiki page | 17 | And I browse to that Wiki page |
| @@ -15,6 +19,13 @@ Feature: Project Wiki | @@ -15,6 +19,13 @@ Feature: Project Wiki | ||
| 15 | And I change the content | 19 | And I change the content |
| 16 | Then I should see the updated content | 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 | Scenario: View page history | 29 | Scenario: View page history |
| 19 | Given I have an existing wiki page | 30 | Given I have an existing wiki page |
| 20 | And That page has two revisions | 31 | And That page has two revisions |
features/steps/project/project_wiki.rb
| @@ -4,6 +4,17 @@ class ProjectWiki < Spinach::FeatureSteps | @@ -4,6 +4,17 @@ class ProjectWiki < Spinach::FeatureSteps | ||
| 4 | include SharedNote | 4 | include SharedNote |
| 5 | include SharedPaths | 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 | Given 'I create the Wiki Home page' do | 18 | Given 'I create the Wiki Home page' do |
| 8 | fill_in "Content", :with => '[link test](test)' | 19 | fill_in "Content", :with => '[link test](test)' |
| 9 | click_on "Save" | 20 | click_on "Save" |
| @@ -39,6 +50,11 @@ class ProjectWiki < Spinach::FeatureSteps | @@ -39,6 +50,11 @@ class ProjectWiki < Spinach::FeatureSteps | ||
| 39 | page.should have_content "Updated Wiki Content" | 50 | page.should have_content "Updated Wiki Content" |
| 40 | end | 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 | And 'That page has two revisions' do | 58 | And 'That page has two revisions' do |
| 43 | @page.update("new content", :markdown, "second commit") | 59 | @page.update("new content", :markdown, "second commit") |
| 44 | end | 60 | end |