Sha256: d7ede77d9bba5d23e585a498f6c0ca30545b26773645c3367fa71fa667de29a5
Contents?: true
Size: 1.1 KB
Versions: 10
Compression:
Stored size: 1.1 KB
Contents
require 'helper' setup_active_record class User < ActiveRecord::Base include HasConstant include HasConstant::Orm::ActiveRecord has_constant :salutations, ['Mr', 'Mrs'] end if defined?(ActiveRecord) class ActiveRecordTest < Test::Unit::TestCase should 'save values as integers' do u = User.new(:salutation => 'Mr') u.save! assert_equal 'Mr', u.salutation assert_equal 0, u.attributes['salutation'] end context 'scopes' do setup do @man = User.create!(:salutation => 'Mr') @woman = User.create!(:salutation => 'Mrs') end should 'provide by_constant scope' do assert_equal 1, User.by_constant('salutation', 'Mr').count assert_equal @man, User.by_constant('salutation', 'Mr').first end should 'provide singular_is scope' do assert_equal 1, User.salutation_is('Mr').count assert_equal @man, User.salutation_is('Mr').first end should 'provide singular_is_not scope' do assert_equal 1, User.salutation_is_not('Mr').count assert_equal @woman, User.salutation_is_not('Mr').first end end end if defined?(ActiveRecord)
Version data entries
10 entries across 10 versions & 1 rubygems