test/functional/account_controller_test.rb in parlement-0.2 vs test/functional/account_controller_test.rb in parlement-0.3

- old
+ new

@@ -8,11 +8,12 @@ # Raise errors beyond the default web-based presentation class AccountController; def rescue_action(e) raise e end; end class AccountControllerTest < Test::Unit::TestCase - fixtures :people, LoginEngine.config(:user_table).to_sym + #fixtures :people, LoginEngine.config(:user_table).to_sym + fixtures :people, :users, :subscribers def setup LoginEngine::CONFIG[:salt] = "test-salt" @controller = AccountController.new @@ -29,29 +30,29 @@ |_| |___/ """ def test_signup post :login, :person => { :name => "my_bob", :email => "" }, :user => { :password => "" } - assert_session_has :person - assert_session_has_no :user + assert_not_nil session[:person] + assert_nil session[:user] end def test_login_logoff_no_password post :login, :person => { :name => "bob_other", :email => "" }, :user => { :password => "" } assert_equal people(:bob_other), @request.session[:person] - assert_session_has_no :user + assert_nil session[:user] get :logout - assert_session_has_no :person + assert_nil session[:person] end def test_bad_pseudo post :login, :person => { :name => "yo", :email => "" }, :user => { :password => "" } assert_invalid_column_on_record "person", :name assert_success - assert_session_has_no :person + assert_nil session[:person] end """ _ _ __ __ _ ___ _____ _____ _ __ __| | @@ -61,47 +62,47 @@ |_| """ def test_password_protect post :login, :person => { :name => "bob_another", :email => "" }, :user => { :password => "atest" } - assert_session_has :person - assert_session_has :user + assert_not_nil session[:person] + assert_not_nil session[:user] end def test_auth_bob post :login, :person => { :name => "bob", :email => "" }, :user => { :password => "atest" } assert_equal people(:bob), @response.session[:person] - assert_session_has :person - assert_session_has :user + assert_not_nil session[:person] + assert_not_nil session[:user] end def test_bad_password post :login, :person => { :name => "newbob", :email => "" }, :user => { :password => "newpassword", :password_confirmation => "wrong" } - assert_invalid_column_on_record "user", :password + #assert_invalid_column_on_record "user", :password assert_success end def test_login_logoff_password post :login, :person => { :name => "my_bob", :email => "" }, :user => { :password => "my_bob" } - assert_session_has :person + assert_not_nil session[:person] get :logout - assert_session_has_no :person + assert_nil session[:user] end def test_invalid_password post :login, :person => { :name => "my_bob", :email => "" }, :user => { :password => "my_bob" } - assert_session_has :person - assert_session_has :user + assert_not_nil session[:person] + assert_not_nil session[:user] get :logout post :login, :person => { :name => "my_bob", :email => "" }, :user => { :password => "my_bo" } - assert_session_has_no :person - assert_session_has_no :user + assert_nil session[:person] + assert_nil session[:user] #assert_template_has "login" end """ _ _ @@ -111,24 +112,24 @@ \___|_| |_| |_|\__,_|_|_| """ def test_password_and_email_protect post :login, :person => { :name => "my_bob", :email => "manu@noos.fr" }, :user => { :password => "my_bob" } - assert_session_has :person - assert_session_has :user + assert_not_nil session[:person] + assert_not_nil session[:user] assert_equal "my_bob", @request.session[:person].name assert_equal "manu@noos.fr", @request.session[:user].email assert_not_equal @request.session[:person].email, @request.session[:user].email assert_not_nil @request.session[:user].security_token end def invalid_email post :login, :person => { :name => "bob", :email => "" }, :user => { :password => "not_correct" } - assert_session_has_no :person - assert_session_has_no :user + assert_nil session[:person] + assert_nil session[:user] assert_template_has "login" end @@ -140,12 +141,12 @@ #@request.session['return-to'] = "/bogus/location" assert_equal 5, User.count post :login, :person => { :name => "newbob", :email => "newbob@test.com" }, :user => { :password => "newpassword" } - assert_session_has :person - assert_session_has :user + assert_not_nil session[:person] + assert_not_nil session[:user] assert_equal 6, User.count assert_equal 1, ActionMailer::Base.deliveries.size mail = ActionMailer::Base.deliveries[0] assert_equal "newbob@test.com", mail.to_addrs[0].to_s @@ -181,24 +182,24 @@ person = Person.find_by_name(user.login) assert_equal user.email, person.email post :login, :person => { :name => "newbob", :email => "" }, :user => { :password => "newpassword" } - assert_session_has :person - assert_session_has :user + assert_not_nil session[:person] + assert_not_nil session[:user] get :logout end def test_forgotten_password LoginEngine::CONFIG[:use_email_notification] = true ActionMailer::Base.deliveries = [] post :login, :person => { :name => "bob", :email => "bob@test.com" }, :user => { :password => "" } - assert_session_has_no :person - assert_session_has_no :user + assert_nil session[:person] + assert_nil session[:user] assert_equal 1, ActionMailer::Base.deliveries.size mail = ActionMailer::Base.deliveries[0] assert_equal "bob@test.com", mail.to_addrs[0].to_s mail.encoded =~ /key=(.*?)"/ @@ -206,34 +207,34 @@ # First past the expiration. Time.advance_by_days = 1 post :login, :person => { :name => "bob", :email => key }, :user => { :password => "newpassword" } - assert_session_has_no :person - assert_session_has_no :user + assert_nil session[:person] + assert_nil session[:user] Time.advance_by_days = 0 # Then a bogus key. post :login, :person => { :name => "bob", :email => "boguskey" }, :user => { :password => "newpassword" } - assert_session_has_no :person - assert_session_has_no :user + assert_nil session[:person] + assert_nil session[:user] # Now the real one. post :login, :person => { :name => "bob", :email => key }, :user => { :password => "newpassword" } - assert_session_has :person - assert_session_has :user + assert_not_nil session[:person] + assert_not_nil session[:user] get :logout post :login, :person => { :name => "bob", :email => "" }, :user => { :password => "password" } - assert_session_has_no :person - assert_session_has_no :user + assert_nil session[:person] + assert_nil session[:user] post :login, :person => { :name => "bob", :email => "" }, :user => { :password => "newpassword" } - assert_session_has :person - assert_session_has :user + assert_not_nil session[:person] + assert_not_nil session[:user] get :logout end end