summaryrefslogtreecommitdiffstats
path: root/test/functional
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-12-12 15:34:35 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-12-12 15:34:35 +0000
commit758f2f0a4efdab9b8e4654efb71fbbdd81fa7b00 (patch)
tree44f647dcb0c343b6a1b74797ae83357b32804d95 /test/functional
parenta49c7f95e236422d560e09a1ecc0555279ab0bbe (diff)
downloadredmine-758f2f0a4efdab9b8e4654efb71fbbdd81fa7b00.tar.gz
redmine-758f2f0a4efdab9b8e4654efb71fbbdd81fa7b00.zip
UsersController tests cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4501 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/users_controller_test.rb82
1 files changed, 33 insertions, 49 deletions
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index d8493740d..dbc4dba46 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -119,55 +119,13 @@ class UsersControllerTest < ActionController::TestCase
project_ids = memberships.map(&:project_id)
assert project_ids.include?(2) #private project admin can see
end
-
- context "GET :new" do
- setup do
- get :new
- end
-
- should_assign_to :user
- should_respond_with :success
- should_render_template :new
- end
-
- context "POST :create" do
- context "when successful" do
- setup do
- post :create, :user => {
- :firstname => 'John',
- :lastname => 'Doe',
- :login => 'jdoe',
- :password => 'test',
- :password_confirmation => 'test',
- :mail => 'jdoe@gmail.com',
- :mail_notification => 'none'
- }
- end
-
- should_assign_to :user
- should_respond_with :redirect
- should_redirect_to('user edit') { {:controller => 'users', :action => 'edit', :id => User.find_by_login('jdoe')}}
-
- should 'set the users mail notification' do
- user = User.last
- assert_equal 'none', user.mail_notification
- end
-
- should 'set the password' do
- user = User.first(:order => 'id DESC')
- assert user.check_password?('test')
- end
- end
-
- context "when unsuccessful" do
- setup do
- post :create, :user => {}
- end
-
- should_assign_to :user
- should_respond_with :success
- should_render_template :new
- end
+
+ def test_new
+ get :new
+
+ assert_response :success
+ assert_template :new
+ assert assigns(:user)
end
def test_create
@@ -204,6 +162,23 @@ class UsersControllerTest < ActionController::TestCase
assert_equal [user.mail], mail.bcc
assert mail.body.include?('secret')
end
+
+ def test_create_with_failure
+ assert_no_difference 'User.count' do
+ post :create, :user => {}
+ end
+
+ assert_response :success
+ assert_template 'new'
+ end
+
+ def test_edit
+ get :edit, :id => 2
+
+ assert_response :success
+ assert_template 'edit'
+ assert_equal User.find(2), assigns(:user)
+ end
def test_update
ActionMailer::Base.deliveries.clear
@@ -216,6 +191,15 @@ class UsersControllerTest < ActionController::TestCase
assert_equal 'desc', user.pref[:comments_sorting]
assert ActionMailer::Base.deliveries.empty?
end
+
+ def test_update_with_failure
+ assert_no_difference 'User.count' do
+ put :update, :id => 2, :user => {:firstname => ''}
+ end
+
+ assert_response :success
+ assert_template 'edit'
+ end
def test_update_with_group_ids_should_assign_groups
put :update, :id => 2, :user => {:group_ids => ['10']}