Sha256: e3e2efc1f596184f875f2631f84a24d13f99568f5c247691df644a6e7ebdca55

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

require 'test_helper'

class UserTest < ActiveSupport::TestCase

  test 'user must have a valid password on create' do
    assert !User.create(:username => 'bob', :password => nil).valid?
    assert !User.create(:username => 'bob', :password => '').valid?
    assert  User.create(:username => 'bob', :password => 'secret').valid?
  end

  test 'user need not supply password when updating other attributes' do
    User.create :username => 'bob', :password => 'secret'
    user = User.last  # reload from database so password is nil
    assert_nil user.password
    assert user.update_attributes(:username => 'Robert')
  end

  test 'user must have a valid password when updating password' do
    user = User.create :username => 'bob', :password => 'secret'
    assert !user.update_attributes(:password => '')
    assert !user.update_attributes(:password => nil)
    assert  user.update_attributes(:password => 'topsecret')
  end

  test 'has_matching_password?' do
    User.create :username => 'bob', :password => 'secret'
    user = User.last
    assert user.has_matching_password?('secret')
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
quo_vadis-1.0.7 test/unit/user_test.rb
quo_vadis-1.0.6 test/unit/user_test.rb
quo_vadis-1.0.5 test/unit/user_test.rb
quo_vadis-1.0.4 test/unit/user_test.rb
quo_vadis-1.0.3 test/unit/user_test.rb
quo_vadis-1.0.2 test/unit/user_test.rb