@@ -0,0 +1,45 | |||
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2015 Jean-Philippe Lang | |
|
3 | # | |
|
4 | # This program is free software; you can redistribute it and/or | |
|
5 | # modify it under the terms of the GNU General Public License | |
|
6 | # as published by the Free Software Foundation; either version 2 | |
|
7 | # of the License, or (at your option) any later version. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
14 | # You should have received a copy of the GNU General Public License | |
|
15 | # along with this program; if not, write to the Free Software | |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
|
17 | ||
|
18 | require File.expand_path('../../../test_helper', __FILE__) | |
|
19 | ||
|
20 | class WikiHelperTest < ActionView::TestCase | |
|
21 | include WikiHelper | |
|
22 | include Rails.application.routes.url_helpers | |
|
23 | ||
|
24 | fixtures :projects, :users, | |
|
25 | :roles, :member_roles, :members, | |
|
26 | :enabled_modules, :wikis, :wiki_pages | |
|
27 | ||
|
28 | def test_wiki_page_edit_cancel_path_for_new_page_without_parent_should_be_wiki_index | |
|
29 | wiki = Wiki.find(1) | |
|
30 | page = WikiPage.new(:wiki => wiki) | |
|
31 | assert_equal '/projects/ecookbook/wiki/index', wiki_page_edit_cancel_path(page) | |
|
32 | end | |
|
33 | ||
|
34 | def test_wiki_page_edit_cancel_path_for_new_page_with_parent_should_be_parent | |
|
35 | wiki = Wiki.find(1) | |
|
36 | page = WikiPage.new(:wiki => wiki, :parent => wiki.find_page('Another_page')) | |
|
37 | assert_equal '/projects/ecookbook/wiki/Another_page', wiki_page_edit_cancel_path(page) | |
|
38 | end | |
|
39 | ||
|
40 | def test_wiki_page_edit_cancel_path_for_existing_page_should_be_the_page | |
|
41 | wiki = Wiki.find(1) | |
|
42 | page = wiki.find_page('Child_1') | |
|
43 | assert_equal '/projects/ecookbook/wiki/Child_1', wiki_page_edit_cancel_path(page) | |
|
44 | end | |
|
45 | end |
@@ -51,4 +51,17 module WikiHelper | |||
|
51 | 51 | link_to(h(parent.pretty_title), {:controller => 'wiki', :action => 'show', :id => parent.title, :project_id => parent.project, :version => nil}) |
|
52 | 52 | }) |
|
53 | 53 | end |
|
54 | ||
|
55 | # Returns the path for the Cancel link when editing a wiki page | |
|
56 | def wiki_page_edit_cancel_path(page) | |
|
57 | if page.new_record? | |
|
58 | if parent = page.parent | |
|
59 | project_wiki_page_path(parent.project, parent.title) | |
|
60 | else | |
|
61 | project_wiki_index_path(page.project) | |
|
62 | end | |
|
63 | else | |
|
64 | project_wiki_page_path(page.project, page.title) | |
|
65 | end | |
|
66 | end | |
|
54 | 67 | end |
@@ -33,8 +33,11 | |||
|
33 | 33 | <p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p> |
|
34 | 34 | </div> |
|
35 | 35 | |
|
36 | <p><%= submit_tag l(:button_save) %> | |
|
37 | <%= preview_link({:controller => 'wiki', :action => 'preview', :project_id => @project, :id => @page.title }, 'wiki_form') %></p> | |
|
36 | <p> | |
|
37 | <%= submit_tag l(:button_save) %> | |
|
38 | <%= preview_link({:controller => 'wiki', :action => 'preview', :project_id => @project, :id => @page.title }, 'wiki_form') %> | |
|
39 | | <%= link_to l(:button_cancel), wiki_page_edit_cancel_path(@page) %> | |
|
40 | </p> | |
|
38 | 41 | <%= wikitoolbar_for 'content_text' %> |
|
39 | 42 | <% end %> |
|
40 | 43 |
General Comments 0
You need to be logged in to leave comments.
Login now