Sha256: 8580329a5efe77392375b3e8c0d1641fc0602804012f4a8e25c13b0a79eb5a1a
Contents?: true
Size: 678 Bytes
Versions: 7
Compression:
Stored size: 678 Bytes
Contents
require 'test_helper' class ArrayConversionsTest < ActiveSupport::TestCase def setup reload_db :genders => true end test "that conversion of Gender.find(:all).map {...} to enumeration values as symbols works the same as [:male,:female]" do with_enum = Class.new(ActiveRecord::Base) do set_table_name 'dummies' as_enum :gender, Gender.find(:all).map { |g| [g.name.to_sym, g.id] } end assert_equal 0, with_enum.male assert_equal 1, with_enum.female assert_equal 1, with_enum.genders(:female) jane = with_enum.new :gender => :female assert_equal :female, jane.gender assert_equal 1, jane.gender_cd end end
Version data entries
7 entries across 7 versions & 2 rubygems