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