summaryrefslogtreecommitdiff
path: root/users/test/functional/sessions_controller_test.rb
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2013-04-08 11:04:01 -0700
committerjessib <jessib@riseup.net>2013-04-08 11:04:01 -0700
commit176845b45f6982b0bf26aa69e7432562eed97c69 (patch)
tree1dd74d5afcdb8cfb96588937eda612b37449923c /users/test/functional/sessions_controller_test.rb
parent602229c463c58be9ffb909570155d14d59f6b4d5 (diff)
parent654ab25fa4659119d5ddaa9ae116fce69a386ab1 (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/sessions_controller_test.rb')
-rw-r--r--users/test/functional/sessions_controller_test.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/users/test/functional/sessions_controller_test.rb b/users/test/functional/sessions_controller_test.rb
index f99c0d7..b22c3a3 100644
--- a/users/test/functional/sessions_controller_test.rb
+++ b/users/test/functional/sessions_controller_test.rb
@@ -11,7 +11,6 @@ class SessionsControllerTest < ActionController::TestCase
end
test "should get login screen" do
- request.env['warden'].expects(:winning_strategy)
get :new
assert_response :success
assert_equal "text/html", response.content_type
@@ -19,13 +18,13 @@ class SessionsControllerTest < ActionController::TestCase
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
+ request.env['warden.options'] = {attempted_path: '/1/sessions/asdf.json'}
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")
@@ -34,6 +33,14 @@ class SessionsControllerTest < ActionController::TestCase
assert_json_error :field => "translation stub"
end
+ test "renders failed attempt message" do
+ request.env['warden.options'] = {attempted_path: '/1/sessions/asdf.json'}
+ request.env['warden'].stubs(:winning_strategy).returns(nil)
+ get :new, :format => :json
+ assert_response 422
+ assert_json_error :login => I18n.t(:all_strategies_failed)
+ end
+
# Warden takes care of parsing the params and
# rendering the response. So not much to test here.
test "should perform handshake" do