+ try_password_login user.display_name.upcase, "test"
+
+ assert_template "changeset/history"
+ assert_select "span.username", "test2"
+ end
+
+ def test_login_username_password_public_titlecase
+ user = users(:public_user)
+
+ try_password_login user.display_name.titlecase, "test"
+
+ assert_template "changeset/history"
+ assert_select "span.username", "test2"
+ end
+
+ def test_login_username_password_inactive
+ user = users(:inactive_user)
+
+ try_password_login user.display_name, "test2"
+
+ assert_template "confirm"
+ assert_select "span.username", false
+ end
+
+ def test_login_username_password_inactive_upcase
+ user = users(:inactive_user)
+
+ try_password_login user.display_name.upcase, "test2"
+
+ assert_template "confirm"
+ assert_select "span.username", false
+ end
+
+ def test_login_username_password_inactive_titlecase
+ user = users(:inactive_user)
+
+ try_password_login user.display_name.titlecase, "test2"
+
+ assert_template "confirm"
+ assert_select "span.username", false
+ end
+
+ def test_login_username_password_suspended
+ user = users(:suspended_user)
+
+ try_password_login user.display_name, "test"
+
+ assert_template "login"
+ assert_select "span.username", false
+ assert_select "div.flash.error", /your account has been suspended/
+ end
+
+ def test_login_username_password_suspended_upcase
+ user = users(:suspended_user)
+
+ try_password_login user.display_name.upcase, "test"
+
+ assert_template "login"
+ assert_select "span.username", false
+ assert_select "div.flash.error", /your account has been suspended/
+ end
+
+ def test_login_username_password_suspended_titlecase
+ user = users(:suspended_user)
+
+ try_password_login user.display_name.titlecase, "test"
+
+ assert_template "login"
+ assert_select "span.username", false
+ assert_select "div.flash.error", /your account has been suspended/
+ end
+
+ def test_login_username_password_blocked
+ user = users(:blocked_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", "blocked"
+ end
+
+ def test_login_username_password_blocked_upcase
+ user = users(:blocked_user)
+ create(:user_block, :needs_view, :user => user)
+
+ try_password_login user.display_name, "test"
+
+ assert_template "user_blocks/show"
+ assert_select "span.username", "blocked"
+ end
+
+ def test_login_username_password_blocked_titlecase
+ user = users(:blocked_user)
+ create(:user_block, :needs_view, :user => user)
+
+ try_password_login user.display_name.titlecase, "test"
+
+ assert_template "user_blocks/show"
+ assert_select "span.username", "blocked"
+ end
+
+ def test_login_email_password_remember_me
+ user = users(:normal_user)
+
+ try_password_login user.email, "test", "yes"
+
+ assert_template "changeset/history"
+ assert_select "span.username", "test"
+ assert session.key?(:_remember_for)
+ end
+
+ def test_login_username_password_remember_me
+ user = users(:normal_user)
+
+ try_password_login user.display_name, "test", "yes"
+
+ assert_template "changeset/history"
+ assert_select "span.username", "test"
+ assert session.key?(:_remember_for)
+ end
+
+ def test_login_openid_success
+ OmniAuth.config.add_mock(:openid, :uid => "http://localhost:1123/john.doe")
+
+ get "/login", :referer => "/history"