##// END OF EJS Templates
code format clean up WikisControllerTest...
Toshi MARUYAMA -
r12503:669a16376fff
parent child
Show More
@@ -1,83 +1,84
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class WikisControllerTest < ActionController::TestCase
21 21 fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :wikis
22 22
23 23 def setup
24 24 User.current = nil
25 25 end
26 26
27 27 def test_create
28 28 @request.session[:user_id] = 1
29 29 assert_nil Project.find(3).wiki
30 30
31 31 assert_difference 'Wiki.count' do
32 32 xhr :post, :edit, :id => 3, :wiki => { :start_page => 'Start page' }
33 33 assert_response :success
34 34 assert_template 'edit'
35 35 assert_equal 'text/javascript', response.content_type
36 36 end
37 37
38 38 wiki = Project.find(3).wiki
39 39 assert_not_nil wiki
40 40 assert_equal 'Start page', wiki.start_page
41 41 end
42 42
43 43 def test_create_with_failure
44 44 @request.session[:user_id] = 1
45 45
46 46 assert_no_difference 'Wiki.count' do
47 47 xhr :post, :edit, :id => 3, :wiki => { :start_page => '' }
48 48 assert_response :success
49 49 assert_template 'edit'
50 50 assert_equal 'text/javascript', response.content_type
51 51 end
52 52
53 53 assert_include 'errorExplanation', response.body
54 54 assert_include 'Start page can&#x27;t be blank', response.body
55 55 end
56 56
57 57 def test_update
58 58 @request.session[:user_id] = 1
59 59
60 60 assert_no_difference 'Wiki.count' do
61 61 xhr :post, :edit, :id => 1, :wiki => { :start_page => 'Other start page' }
62 62 assert_response :success
63 63 assert_template 'edit'
64 64 assert_equal 'text/javascript', response.content_type
65 65 end
66 66
67 67 wiki = Project.find(1).wiki
68 68 assert_equal 'Other start page', wiki.start_page
69 69 end
70 70
71 71 def test_destroy
72 72 @request.session[:user_id] = 1
73 73 post :destroy, :id => 1, :confirm => 1
74 assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'ecookbook', :tab => 'wiki'
74 assert_redirected_to :controller => 'projects',
75 :action => 'settings', :id => 'ecookbook', :tab => 'wiki'
75 76 assert_nil Project.find(1).wiki
76 77 end
77 78
78 79 def test_not_found
79 80 @request.session[:user_id] = 1
80 81 post :destroy, :id => 999, :confirm => 1
81 82 assert_response 404
82 83 end
83 84 end
General Comments 0
You need to be logged in to leave comments. Login now