##// END OF EJS Templates
svn propset "svn:eol-style" native test/functional/auth_sources_controller_test.rb...
Toshi MARUYAMA -
r8346:e7de511bbc1a
parent child
Show More
@@ -1,90 +1,90
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 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 AuthSourcesControllerTest < ActionController::TestCase
20 class AuthSourcesControllerTest < ActionController::TestCase
21 fixtures :users
21 fixtures :users
22
22
23 def setup
23 def setup
24 @request.session[:user_id] = 1
24 @request.session[:user_id] = 1
25 end
25 end
26
26
27 def test_index
27 def test_index
28 get :index
28 get :index
29
29
30 assert_response :success
30 assert_response :success
31 assert_template 'index'
31 assert_template 'index'
32 assert_not_nil assigns(:auth_sources)
32 assert_not_nil assigns(:auth_sources)
33 end
33 end
34
34
35 def test_new
35 def test_new
36 get :new
36 get :new
37
37
38 assert_response :success
38 assert_response :success
39 assert_template 'new'
39 assert_template 'new'
40 assert_kind_of AuthSource, assigns(:auth_source)
40 assert_kind_of AuthSource, assigns(:auth_source)
41 assert assigns(:auth_source).new_record?
41 assert assigns(:auth_source).new_record?
42 end
42 end
43
43
44 def test_create
44 def test_create
45 assert_difference 'AuthSource.count' do
45 assert_difference 'AuthSource.count' do
46 post :create, :auth_source => {:name => 'Test'}
46 post :create, :auth_source => {:name => 'Test'}
47 end
47 end
48
48
49 assert_redirected_to '/auth_sources'
49 assert_redirected_to '/auth_sources'
50 auth_source = AuthSource.first(:order => 'id DESC')
50 auth_source = AuthSource.first(:order => 'id DESC')
51 assert_equal 'Test', auth_source.name
51 assert_equal 'Test', auth_source.name
52 end
52 end
53
53
54 def test_edit
54 def test_edit
55 auth_source = AuthSource.generate!(:name => 'TestEdit')
55 auth_source = AuthSource.generate!(:name => 'TestEdit')
56 get :edit, :id => auth_source.id
56 get :edit, :id => auth_source.id
57
57
58 assert_response :success
58 assert_response :success
59 assert_template 'edit'
59 assert_template 'edit'
60 assert_equal auth_source, assigns(:auth_source)
60 assert_equal auth_source, assigns(:auth_source)
61 end
61 end
62
62
63 def test_update
63 def test_update
64 auth_source = AuthSource.generate!(:name => 'TestEdit')
64 auth_source = AuthSource.generate!(:name => 'TestEdit')
65 post :update, :id => auth_source.id, :auth_source => {:name => 'TestUpdate'}
65 post :update, :id => auth_source.id, :auth_source => {:name => 'TestUpdate'}
66
66
67 assert_redirected_to '/auth_sources'
67 assert_redirected_to '/auth_sources'
68 assert_equal 'TestUpdate', auth_source.reload.name
68 assert_equal 'TestUpdate', auth_source.reload.name
69 end
69 end
70
70
71 def test_destroy_without_users
71 def test_destroy_without_users
72 auth_source = AuthSource.generate!(:name => 'TestEdit')
72 auth_source = AuthSource.generate!(:name => 'TestEdit')
73 assert_difference 'AuthSource.count', -1 do
73 assert_difference 'AuthSource.count', -1 do
74 post :destroy, :id => auth_source.id
74 post :destroy, :id => auth_source.id
75 end
75 end
76
76
77 assert_redirected_to '/auth_sources'
77 assert_redirected_to '/auth_sources'
78 end
78 end
79
79
80 def test_destroy_with_users
80 def test_destroy_with_users
81 auth_source = AuthSource.generate!(:name => 'TestEdit')
81 auth_source = AuthSource.generate!(:name => 'TestEdit')
82 User.generate!(:auth_source => auth_source)
82 User.generate!(:auth_source => auth_source)
83 assert_no_difference 'AuthSource.count' do
83 assert_no_difference 'AuthSource.count' do
84 post :destroy, :id => auth_source.id
84 post :destroy, :id => auth_source.id
85 end
85 end
86
86
87 assert_redirected_to '/auth_sources'
87 assert_redirected_to '/auth_sources'
88 assert AuthSource.find(auth_source.id)
88 assert AuthSource.find(auth_source.id)
89 end
89 end
90 end
90 end
General Comments 0
You need to be logged in to leave comments. Login now