diff options
author | jessib <jessib@riseup.net> | 2013-04-08 11:04:01 -0700 |
---|---|---|
committer | jessib <jessib@riseup.net> | 2013-04-08 11:04:01 -0700 |
commit | 176845b45f6982b0bf26aa69e7432562eed97c69 (patch) | |
tree | 1dd74d5afcdb8cfb96588937eda612b37449923c /users/test/functional/v1 | |
parent | 602229c463c58be9ffb909570155d14d59f6b4d5 (diff) | |
parent | 654ab25fa4659119d5ddaa9ae116fce69a386ab1 (diff) |
Merge pull request #41 from azul/feature/allow-getting-salt
Allow getting salt and proper error messages for invalid login attempts
Diffstat (limited to 'users/test/functional/v1')
-rw-r--r-- | users/test/functional/v1/sessions_controller_test.rb | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/users/test/functional/v1/sessions_controller_test.rb b/users/test/functional/v1/sessions_controller_test.rb index be085ce..1226c9d 100644 --- a/users/test/functional/v1/sessions_controller_test.rb +++ b/users/test/functional/v1/sessions_controller_test.rb @@ -7,26 +7,10 @@ class V1::SessionsControllerTest < ActionController::TestCase setup do @request.env['HTTP_HOST'] = 'api.lvh.me' - @user = stub :login => "me", :id => 123 + @user = stub_record :user @client_hex = 'a123' end - test "renders json" do - request.env['warden'].expects(:winning_strategy) - get :new, :format => :json - assert_response :success - assert_json_error nil - end - - test "renders warden errors" do - strategy = stub :message => {:field => :translate_me} - request.env['warden'].stubs(:winning_strategy).returns(strategy) - I18n.expects(:t).with(:translate_me).at_least_once.returns("translation stub") - get :new, :format => :json - assert_response 422 - assert_json_error :field => "translation stub" - end - # Warden takes care of parsing the params and # rendering the response. So not much to test here. test "should perform handshake" do @@ -36,6 +20,15 @@ class V1::SessionsControllerTest < ActionController::TestCase post :create, :login => @user.login, 'A' => @client_hex end + test "should send salt" do + User.expects(:find_by_login).with(@user.login).returns(@user) + + post :create, :login => @user.login + + assert_equal @user, assigns(:user) + assert_json_response salt: @user.salt + end + test "should authorize" do request.env['warden'].expects(:authenticate!) @controller.expects(:current_user).returns(@user) |