+ get "/login"
+ assert_response :redirect
+ assert_redirected_to :controller => :user, :action => :login, :cookie_test => true
+ follow_redirect!
+ assert_response :success
+
+ post "/login", :username => user.email.titlecase, :password => "wrong", :referer => "/history"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_template "login"
+
+ post "/login", :username => user.email.titlecase, :password => "test", :referer => "/history"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_template "changeset/history"
+ assert_select "span.username", "test2"
+ end
+
+ def test_login_email_password_inactive
+ user = users(:inactive_user)
+
+ get "/login"
+ assert_response :redirect
+ assert_redirected_to :controller => :user, :action => :login, :cookie_test => true
+ follow_redirect!
+ assert_response :success
+
+ post "/login", :username => user.email, :password => "wrong", :referer => "/history"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_template "login"
+
+ post "/login", :username => user.email, :password => "test2", :referer => "/history"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_template "confirm"
+ end
+
+ def test_login_email_password_inactive_upcase
+ user = users(:inactive_user)
+
+ get "/login"
+ assert_response :redirect
+ assert_redirected_to :controller => :user, :action => :login, :cookie_test => true
+ follow_redirect!
+ assert_response :success
+
+ post "/login", :username => user.email.upcase, :password => "wrong", :referer => "/history"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_template "login"
+
+ post "/login", :username => user.email.upcase, :password => "test2", :referer => "/history"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_template "confirm"
+ end
+
+ def test_login_email_password_inactive_titlecase
+ user = users(:inactive_user)
+
+ get "/login"
+ assert_response :redirect
+ assert_redirected_to :controller => :user, :action => :login, :cookie_test => true
+ follow_redirect!
+ assert_response :success
+
+ post "/login", :username => user.email.titlecase, :password => "wrong", :referer => "/history"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_template "login"
+
+ post "/login", :username => user.email.titlecase, :password => "test2", :referer => "/history"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_template "confirm"
+ end
+
+ def test_login_email_password_suspended
+ user = users(:suspended_user)
+
+ get "/login"
+ assert_response :redirect
+ assert_redirected_to :controller => :user, :action => :login, :cookie_test => true
+ follow_redirect!
+ assert_response :success
+
+ post "/login", :username => user.email, :password => "wrong", :referer => "/history"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_template "login"
+
+ post "/login", :username => user.email, :password => "test", :referer => "/history"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_template "login"
+ assert_select "div.flash.error", /your account has been suspended/
+ end
+
+ def test_login_email_password_suspended_upcase
+ user = users(:suspended_user)
+
+ get "/login"
+ assert_response :redirect
+ assert_redirected_to :controller => :user, :action => :login, :cookie_test => true
+ follow_redirect!
+ assert_response :success
+
+ post "/login", :username => user.email.upcase, :password => "wrong", :referer => "/history"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_template "login"
+
+ post "/login", :username => user.email.upcase, :password => "test", :referer => "/history"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_template "login"
+ assert_select "div.flash.error", /your account has been suspended/
+ end
+
+ def test_login_email_password_suspended_titlecase
+ user = users(:suspended_user)
+
+ get "/login"
+ assert_response :redirect
+ assert_redirected_to :controller => :user, :action => :login, :cookie_test => true
+ follow_redirect!
+ assert_response :success
+
+ post "/login", :username => user.email.titlecase, :password => "wrong", :referer => "/history"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_template "login"
+
+ post "/login", :username => user.email.titlecase, :password => "test", :referer => "/history"