Sha256: bce2f03dd8a0106f850da89859abc1927039e3603c6b168d8306abf7999cafb3

Contents?: true

Size: 1.1 KB

Versions: 12

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

12 entries across 12 versions & 1 rubygems

Version Path
authpwn_rails-0.17.0 test/user_extensions/password_field_test.rb
authpwn_rails-0.16.2 test/user_extensions/password_field_test.rb
authpwn_rails-0.16.1 test/user_extensions/password_field_test.rb
authpwn_rails-0.16.0 test/user_extensions/password_field_test.rb
authpwn_rails-0.15.3 test/user_extensions/password_field_test.rb
authpwn_rails-0.15.2 test/user_extensions/password_field_test.rb
authpwn_rails-0.15.1 test/user_extensions/password_field_test.rb
authpwn_rails-0.15.0 test/user_extensions/password_field_test.rb
authpwn_rails-0.14.3 test/user_extensions/password_field_test.rb
authpwn_rails-0.14.2 test/user_extensions/password_field_test.rb
authpwn_rails-0.14.1 test/user_extensions/password_field_test.rb
authpwn_rails-0.14.0 test/user_extensions/password_field_test.rb