+ assert_template "changesets/history"
+ assert_select "span.username", user.display_name
+ end
+
+ def test_login_username_password_duplicate_upcase
+ # Attempt to log in as the uppercase_user, it should also work
+ user = create(:user)
+ uppercase_user = build(:user, :display_name => user.display_name.upcase).tap { |u| u.save(:validate => false) }
+
+ try_password_login uppercase_user.display_name, "test"
+
+ assert_template "changesets/history"
+ assert_select "span.username", uppercase_user.display_name
+ end
+
+ def test_login_username_password_duplicate_downcase
+ # When there's no exact match for case, and two possible users, it should fail
+ user = create(:user)
+ _uppercase_user = build(:user, :display_name => user.display_name.upcase).tap { |u| u.save(:validate => false) }
+
+ try_password_login user.display_name.downcase, "test"
+
+ assert_template "sessions/new"
+ assert_select "span.username", false
+ end
+
+ # When there are no duplicate emails, any variation of cases should work
+ def test_login_username_password
+ user = create(:user)
+
+ try_password_login user.display_name, "test"
+
+ assert_template "changesets/history"
+ assert_select "span.username", user.display_name
+ end
+
+ def test_login_username_password_upcase
+ user = create(:user)
+
+ try_password_login user.display_name.upcase, "test"
+
+ assert_template "changesets/history"
+ assert_select "span.username", user.display_name
+ end
+
+ def test_login_username_password_downcase
+ user = create(:user)
+
+ try_password_login user.display_name.downcase, "test"
+
+ assert_template "changesets/history"
+ assert_select "span.username", user.display_name
+ end
+
+ def test_login_username_password_pending
+ user = create(:user, :pending)
+
+ try_password_login user.display_name, "test"