Refactor: split UsersController#edit into #edit and #update

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4230 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis
2010-09-30 18:22:46 +00:00
parent d06a1a7fa4
commit 86ba692bf5
8 changed files with 58 additions and 46 deletions
+8 -8
View File
@@ -153,9 +153,9 @@ class UsersControllerTest < ActionController::TestCase
end
def test_edit
def test_update
ActionMailer::Base.deliveries.clear
post :edit, :id => 2, :user => {:firstname => 'Changed'}, :notification_option => 'all', :pref => {:hide_mail => '1', :comments_sorting => 'desc'}
put :update, :id => 2, :user => {:firstname => 'Changed'}, :notification_option => 'all', :pref => {:hide_mail => '1', :comments_sorting => 'desc'}
user = User.find(2)
assert_equal 'Changed', user.firstname
@@ -165,7 +165,7 @@ class UsersControllerTest < ActionController::TestCase
assert ActionMailer::Base.deliveries.empty?
end
def test_edit_with_activation_should_send_a_notification
def test_update_with_activation_should_send_a_notification
u = User.new(:firstname => 'Foo', :lastname => 'Bar', :mail => 'foo.bar@somenet.foo', :language => 'fr')
u.login = 'foo'
u.status = User::STATUS_REGISTERED
@@ -173,7 +173,7 @@ class UsersControllerTest < ActionController::TestCase
ActionMailer::Base.deliveries.clear
Setting.bcc_recipients = '1'
post :edit, :id => u.id, :user => {:status => User::STATUS_ACTIVE}
put :update, :id => u.id, :user => {:status => User::STATUS_ACTIVE}
assert u.reload.active?
mail = ActionMailer::Base.deliveries.last
assert_not_nil mail
@@ -181,12 +181,12 @@ class UsersControllerTest < ActionController::TestCase
assert mail.body.include?(ll('fr', :notice_account_activated))
end
def test_edit_with_password_change_should_send_a_notification
def test_updat_with_password_change_should_send_a_notification
ActionMailer::Base.deliveries.clear
Setting.bcc_recipients = '1'
u = User.find(2)
post :edit, :id => u.id, :user => {}, :password => 'newpass', :password_confirmation => 'newpass', :send_information => '1'
put :update, :id => u.id, :user => {}, :password => 'newpass', :password_confirmation => 'newpass', :send_information => '1'
assert_equal User.hash_password('newpass'), u.reload.hashed_password
mail = ActionMailer::Base.deliveries.last
@@ -195,13 +195,13 @@ class UsersControllerTest < ActionController::TestCase
assert mail.body.include?('newpass')
end
test "POST :edit with a password change to an AuthSource user switching to Internal authentication" do
test "put :update with a password change to an AuthSource user switching to Internal authentication" do
# Configure as auth source
u = User.find(2)
u.auth_source = AuthSource.find(1)
u.save!
post :edit, :id => u.id, :user => {:auth_source_id => ''}, :password => 'newpass', :password_confirmation => 'newpass'
put :update, :id => u.id, :user => {:auth_source_id => ''}, :password => 'newpass', :password_confirmation => 'newpass'
assert_equal nil, u.reload.auth_source
assert_equal User.hash_password('newpass'), u.reload.hashed_password
+1 -1
View File
@@ -35,7 +35,7 @@ class AdminTest < ActionController::IntegrationTest
assert_kind_of User, logged_user
assert_equal "Paul", logged_user.firstname
post "users/edit", :id => user.id, :user => { :status => User::STATUS_LOCKED }
put "users/#{user.id}/edit", :id => user.id, :user => { :status => User::STATUS_LOCKED }
assert_redirected_to "/users/#{ user.id }/edit"
locked_user = User.try_to_login("psmith", "psmith09")
assert_equal nil, locked_user
+2 -1
View File
@@ -251,10 +251,11 @@ class RoutingTest < ActionController::IntegrationTest
should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership'
should_route :post, "/users/new", :controller => 'users', :action => 'create'
should_route :post, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123'
should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12'
should_route :put, "/users/444/edit", :controller => 'users', :action => 'update', :id => '444'
end
# TODO: should they all be scoped under /projects/:project_id ?