Sha256: 8eec2dbec43eeab457fccacc2db17aa6ecd89380aa79d5ca68ae992690140990

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require File.expand_path('../test_helper', __FILE__)

class UserWithPassword < User
  include Authpwn::UserExtensions::PasswordField
end

class PasswordFieldTest < ActiveSupport::TestCase
  def setup
    @user = UserWithPassword.new :password => 'awesome',
                                 :password_confirmation => 'awesome'
    
    @john = UserWithPassword.find_by_id(users(:john).id)
    @jane = UserWithPassword.find_by_id(users(:jane).id)
    @bill = UserWithPassword.find_by_id(users(:bill).id)
  end
  
  test 'setup' do
    assert @user.valid?
  end
  
  test 'password required' do
    @user.password = @user.password_confirmation = nil
    assert !@user.valid?
  end
  
  test 'password assumed ok for existing records' do
    @john.save!
    assert @john.valid?
  end
  
  test 'password confirmation' do
    @user.password_confirmation = 'not awesome'
    assert !@user.valid?
  end
  
  test 'password_credential' do
    assert_equal credentials(:john_password), @john.password_credential
    assert_equal credentials(:jane_password), @jane.password_credential
    assert_nil @bill.password_credential
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
authpwn_rails-0.10.5 test/password_field_test.rb
authpwn_rails-0.10.4 test/password_field_test.rb
authpwn_rails-0.10.3 test/password_field_test.rb
authpwn_rails-0.10.2 test/password_field_test.rb