summaryrefslogtreecommitdiff
path: root/users
diff options
context:
space:
mode:
Diffstat (limited to 'users')
-rw-r--r--users/app/controllers/users_controller.rb2
-rw-r--r--users/test/functional/users_controller_test.rb31
2 files changed, 32 insertions, 1 deletions
diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb
index 46ecc32..ecab53b 100644
--- a/users/app/controllers/users_controller.rb
+++ b/users/app/controllers/users_controller.rb
@@ -22,7 +22,7 @@ class UsersController < ApplicationController
def update
@user = current_user
- @user.update!(params[:user])
+ @user.update(params[:user])
respond_with(@user, :location => edit_user_path(@user))
end
end
diff --git a/users/test/functional/users_controller_test.rb b/users/test/functional/users_controller_test.rb
index 1cb28a6..feae2dd 100644
--- a/users/test/functional/users_controller_test.rb
+++ b/users/test/functional/users_controller_test.rb
@@ -30,4 +30,35 @@ class UsersControllerTest < ActionController::TestCase
assert_redirected_to new_user_path
end
+ test "should get edit view" do
+ params = User.valid_attributes_hash
+ user = stub params.merge(:id => 123, :class => User, :to_key => ['123'], :new_record? => false, :persisted? => :true)
+ login user
+ get :edit, :id => user.id
+ assert_equal user, assigns[:user]
+ end
+
+ test "should process updated params" do
+ params = User.valid_attributes_hash
+ user = stub params.merge(:id => 123)
+ params.stringify_keys!
+ user.expects(:update).with(params).returns(user)
+ login user
+ post :update, :user => params, :id => user.id
+ assert_equal user, assigns[:user]
+ assert_response :redirect
+ assert_redirected_to edit_user_path(user)
+ end
+
+ test "should validate updated params" do
+ params = User.valid_attributes_hash
+ user = stub params.merge(:id => 123)
+ params.stringify_keys!
+ user.expects(:update).with(params).returns(user)
+ login user
+ post :update, :user => params, :id => user.id
+ assert_equal user, assigns[:user]
+ end
+
+
end