+ try_password_login user.display_name, "test"
+
+ assert_template "sessions/new"
+ assert_select "span.username", false
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
+ assert_select "a[href='mailto:openstreetmap@example.com']", "support"
+ end
+ end
+
+ def test_login_username_password_suspended_upcase
+ user = create(:user, :suspended)
+
+ try_password_login user.display_name.upcase, "test"
+
+ assert_template "sessions/new"
+ assert_select "span.username", false
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
+ assert_select "a[href='mailto:openstreetmap@example.com']", "support"
+ end
+ end
+
+ def test_login_username_password_suspended_downcase
+ user = create(:user, :suspended)
+
+ try_password_login user.display_name.downcase, "test"
+
+ assert_template "sessions/new"
+ assert_select "span.username", false
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
+ assert_select "a[href='mailto:openstreetmap@example.com']", "support"
+ end
+ end
+
+ def test_login_username_password_blocked
+ user = create(:user)
+ create(:user_block, :needs_view, :user => user)
+
+ try_password_login user.display_name.upcase, "test"
+
+ assert_template "user_blocks/show"
+ assert_select "span.username", user.display_name
+ end
+
+ def test_login_username_password_blocked_upcase
+ user = create(:user)
+ create(:user_block, :needs_view, :user => user)
+
+ try_password_login user.display_name, "test"
+
+ assert_template "user_blocks/show"
+ assert_select "span.username", user.display_name
+ end
+
+ def test_login_username_password_blocked_downcase
+ user = create(:user)
+ create(:user_block, :needs_view, :user => user)
+
+ try_password_login user.display_name.downcase, "test"
+
+ assert_template "user_blocks/show"
+ assert_select "span.username", user.display_name
+ end
+
+ def test_login_email_password_remember_me
+ user = create(:user)
+
+ try_password_login user.email, "test", "yes"
+
+ assert_template "changesets/history"
+ assert_select "span.username", user.display_name
+ assert session.key?(:_remember_for)
+ end
+
+ def test_login_username_password_remember_me
+ user = create(:user)
+
+ try_password_login user.display_name, "test", "yes"
+
+ assert_template "changesets/history"
+ assert_select "span.username", user.display_name
+ assert session.key?(:_remember_for)
+ end
+
+ def test_login_openid_success
+ user = create(:user, :auth_provider => "openid", :auth_uid => "http://example.com/john.doe")
+ OmniAuth.config.add_mock(:openid, :uid => user.auth_uid)
+
+ get "/login", :params => { :referer => "/history" }
+ assert_redirected_to login_path(:cookie_test => true, :referer => "/history")