Sha256: cd5faaa712284dcf9da9282ef0b470bee11f1440867f1c31ef54e73cc47bb861
Contents?: true
Size: 902 Bytes
Versions: 14
Compression:
Stored size: 902 Bytes
Contents
require File.expand_path('../abstract_unit', __FILE__) class TestClone < ActiveSupport::TestCase fixtures :reference_types, :reference_codes CLASSES = { :single => { :class => ReferenceType, :primary_keys => :reference_type_id, }, :dual => { :class => ReferenceCode, :primary_keys => [:reference_type_id, :reference_code], }, } def setup self.class.classes = CLASSES end def test_dup testing_with do clone = @first.dup remove_keys = Array(@klass.primary_key).map &:to_s assert_equal(@first.attributes.except(*remove_keys), clone.attributes) if composite? @klass.primary_key.each do |key| assert_nil(clone[key], "Primary key '#{key}' should be nil") end else assert_nil(clone[@klass.primary_key], "Sole primary key should be nil") end end end end
Version data entries
14 entries across 14 versions & 1 rubygems