diff --git a/test/fixtures/profiles.yml b/test/fixtures/profiles.yml index 10ded38..c7f94ad 100644 --- a/test/fixtures/profiles.yml +++ b/test/fixtures/profiles.yml @@ -1,17 +1,19 @@ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -one: +johndoe: id: 1 name: 'John Doe' identifier: johndoe virtual_community_id: 1 + owner_id: 1 template: 'default' icons_theme: 'default' theme: 'default' -two: +joerandomhacker: id: 2 name: 'Joe Random Hacker' identifier: joerandomhacker virtual_community_id: 1 + owner_id: 2 template: 'simple' icons_theme: 'simple' theme: 'simple' diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index f7be9db..a36e681 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,17 +1,17 @@ -quentin: +johndoe: id: 1 - login: quentin - email: quentin@example.com + login: johndoe + email: johndoe@example.com salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test - #crypted_password: "ce2/iFrNtQ8=\n" # quentin, use only if you're using 2-way encryption + #crypted_password: "ce2/iFrNtQ8=\n" # johndoe, use only if you're using 2-way encryption created_at: <%= 5.days.ago.to_s :db %> # activated_at: <%= 5.days.ago.to_s :db %> # only if you're activating new signups -aaron: +joerandomhacker: id: 2 - login: aaron - email: aaron@example.com + login: joerandomhacker + email: joerandomhacker@example.com salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test # activation_code: aaronscode # only if you're activating new signups - created_at: <%= 1.days.ago.to_s :db %> \ No newline at end of file + created_at: <%= 1.days.ago.to_s :db %> diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 9ad1c56..dd4a8ef 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -18,13 +18,13 @@ class AccountControllerTest < Test::Unit::TestCase end def test_should_login_and_redirect - post :login, :login => 'quentin', :password => 'test' + post :login, :login => 'johndoe', :password => 'test' assert session[:user] assert_response :redirect end def test_should_fail_login_and_not_redirect - post :login, :login => 'quentin', :password => 'bad password' + post :login, :login => 'johndoe', :password => 'bad password' assert_nil session[:user] assert_response :success end @@ -69,45 +69,45 @@ class AccountControllerTest < Test::Unit::TestCase end def test_should_logout - login_as :quentin + login_as :johndoe get :logout assert_nil session[:user] assert_response :redirect end def test_should_remember_me - post :login, :login => 'quentin', :password => 'test', :remember_me => "1" + post :login, :login => 'johndoe', :password => 'test', :remember_me => "1" assert_not_nil @response.cookies["auth_token"] end def test_should_not_remember_me - post :login, :login => 'quentin', :password => 'test', :remember_me => "0" + post :login, :login => 'johndoe', :password => 'test', :remember_me => "0" assert_nil @response.cookies["auth_token"] end def test_should_delete_token_on_logout - login_as :quentin + login_as :johndoe get :logout assert_equal @response.cookies["auth_token"], [] end def test_should_login_with_cookie - users(:quentin).remember_me - @request.cookies["auth_token"] = cookie_for(:quentin) + users(:johndoe).remember_me + @request.cookies["auth_token"] = cookie_for(:johndoe) get :index assert @controller.send(:logged_in?) end def test_should_fail_expired_cookie_login - users(:quentin).remember_me - users(:quentin).update_attribute :remember_token_expires_at, 5.minutes.ago - @request.cookies["auth_token"] = cookie_for(:quentin) + users(:johndoe).remember_me + users(:johndoe).update_attribute :remember_token_expires_at, 5.minutes.ago + @request.cookies["auth_token"] = cookie_for(:johndoe) get :index assert !@controller.send(:logged_in?) end def test_should_fail_cookie_login - users(:quentin).remember_me + users(:johndoe).remember_me @request.cookies["auth_token"] = auth_token('invalid_auth_token') get :index assert !@controller.send(:logged_in?) @@ -119,7 +119,7 @@ class AccountControllerTest < Test::Unit::TestCase end def test_should_display_logged_in_user_options - login_as 'quentin' + login_as 'johndoe' get :index assert_template 'index' end diff --git a/test/integration/enable_disable_features_test.rb b/test/integration/enable_disable_features_test.rb index 377ed5c..6b4d3cc 100644 --- a/test/integration/enable_disable_features_test.rb +++ b/test/integration/enable_disable_features_test.rb @@ -5,7 +5,7 @@ class EnableDisableFeaturesTest < ActionController::IntegrationTest def test_enable_features uses_host 'anhetegua.net' - login 'quentin', 'test' + login 'johndoe', 'test' get '/admin/features' assert_response :success assert_tag :tag => 'input', :attributes => { :name => 'features[feature1]' } diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 54380d0..e18ba36 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../test_helper' class ProfileTest < Test::Unit::TestCase - fixtures :profiles, :virtual_communities + fixtures :profiles, :virtual_communities, :users def test_identifier_validation p = Profile.new @@ -39,4 +39,9 @@ class ProfileTest < Test::Unit::TestCase assert_kind_of VirtualCommunity, p.virtual_community end + def test_can_have_user_as_owner + p = profiles(:johndoe) + assert_kind_of User, p.owner + end + end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 8166c09..be238bc 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -42,30 +42,41 @@ class UserTest < Test::Unit::TestCase end def test_should_reset_password - users(:quentin).update_attributes(:password => 'new password', :password_confirmation => 'new password') - assert_equal users(:quentin), User.authenticate('quentin', 'new password') + users(:johndoe).update_attributes(:password => 'new password', :password_confirmation => 'new password') + assert_equal users(:johndoe), User.authenticate('johndoe', 'new password') end def test_should_not_rehash_password - users(:quentin).update_attributes(:login => 'quentin2') - assert_equal users(:quentin), User.authenticate('quentin2', 'test') + users(:johndoe).update_attributes(:login => 'johndoe2') + assert_equal users(:johndoe), User.authenticate('johndoe2', 'test') end def test_should_authenticate_user - assert_equal users(:quentin), User.authenticate('quentin', 'test') + assert_equal users(:johndoe), User.authenticate('johndoe', 'test') end def test_should_set_remember_token - users(:quentin).remember_me - assert_not_nil users(:quentin).remember_token - assert_not_nil users(:quentin).remember_token_expires_at + users(:johndoe).remember_me + assert_not_nil users(:johndoe).remember_token + assert_not_nil users(:johndoe).remember_token_expires_at end def test_should_unset_remember_token - users(:quentin).remember_me - assert_not_nil users(:quentin).remember_token - users(:quentin).forget_me - assert_nil users(:quentin).remember_token + users(:johndoe).remember_me + assert_not_nil users(:johndoe).remember_token + users(:johndoe).forget_me + assert_nil users(:johndoe).remember_token + end + + def test_should_create_profile + users_count = User.count + profiles_count = Profile.count + + user = User.create!(:login => 'new_user', :email => 'new_user@example.com', :password => 'test', :password_confirmation => 'test') + + assert Profile.exists?(['user_id = ?', user.id]) + assert_equal users_count + 1, User.count + assert_equal profiles_count + 1, Profile.count end protected -- libgit2 0.21.2