summaryrefslogtreecommitdiff
path: root/users/test/functional/users_controller_test.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-11-26 12:16:53 +0100
committerAzul <azul@leap.se>2012-11-26 12:16:53 +0100
commit1ea7da1314a46a87512e4f3d7f99249883f4f12f (patch)
treeab07f2e702b5f5eee9638ef751669f88298faad2 /users/test/functional/users_controller_test.rb
parent716dc248e940be8bd323a9d92f98785737fc99a0 (diff)
parentcdda8f095d49cdda94c3527ecb92cb15c300327b (diff)
Merge branch 'feature/users-change-passwords' into develop
Diffstat (limited to 'users/test/functional/users_controller_test.rb')
-rw-r--r--users/test/functional/users_controller_test.rb29
1 files changed, 15 insertions, 14 deletions
diff --git a/users/test/functional/users_controller_test.rb b/users/test/functional/users_controller_test.rb
index 4318928..ced8ee9 100644
--- a/users/test/functional/users_controller_test.rb
+++ b/users/test/functional/users_controller_test.rb
@@ -11,27 +11,27 @@ class UsersControllerTest < ActionController::TestCase
test "should create new user" do
user = stub_record User
- User.expects(:create!).with(user.params).returns(user)
- post :create, :user => user.params
+ User.expects(:create).with(user.params).returns(user)
+ post :create, :user => user.params, :format => :json
assert_nil session[:user_id]
- assert_response :redirect
- assert_redirected_to root_url
+ assert_json_response user
+ assert_response :success
end
test "should redirect to signup form on failed attempt" do
params = User.valid_attributes_hash.slice(:login)
user = User.new(params)
params.stringify_keys!
- User.expects(:create!).with(params).raises(VALIDATION_FAILED.new(user))
- post :create, :user => params
- assert_nil session[:user_id]
- assert_equal user, assigns[:user]
- assert_response :redirect
- assert_redirected_to new_user_path
+ assert !user.valid?
+ User.expects(:create).with(params).returns(user)
+ post :create, :user => params, :format => :json
+ assert_json_error user.errors.messages
+ assert_response 422
end
test "should get edit view" do
user = stub_record User
+ User.expects(:find_by_param).with(user.id.to_s).returns(user)
login user
get :edit, :id => user.id
assert_equal user, assigns[:user]
@@ -39,11 +39,12 @@ class UsersControllerTest < ActionController::TestCase
test "should process updated params" do
user = stub_record User
- user.expects(:update).with(user.params).returns(user)
+ user.expects(:update_attributes).with(user.params).returns(true)
+ User.expects(:find_by_param).with(user.id.to_s).returns(user)
login user
- post :update, :user => user.params, :id => user.id
+ put :update, :user => user.params, :id => user.id, :format => :json
assert_equal user, assigns[:user]
- assert_response :redirect
- assert_redirected_to edit_user_path(user)
+ assert_equal " ", @response.body
+ assert_response 204
end
end