Sha256: b2244888898f0dff266d5083e11cbd6a3fba36668e0468dd1a5ed1e32fbb8d49

Contents?: true

Size: 897 Bytes

Versions: 8

Compression:

Stored size: 897 Bytes

Contents

require 'abstract_unit'
require 'fixtures/reference_type'
require 'fixtures/reference_code'

class CloneTest < Test::Unit::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
    super
    self.class.classes = CLASSES
  end
  
  def test_truth
    testing_with do
      clone = @first.clone
      assert_equal @first.attributes.block(@klass.primary_key), clone.attributes
      if composite?
        @klass.primary_key.each {|key| assert_nil clone[key], "Primary key '#{key}' should be nil"} 
      else
        assert_nil clone[@klass.primary_key], "Sole primary key should be nil"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
composite_primary_keys-0.7.1 test/clone_test.rb
composite_primary_keys-0.6.2 test/clone_test.rb
composite_primary_keys-0.6.3 test/clone_test.rb
composite_primary_keys-0.7.0 test/clone_test.rb
composite_primary_keys-0.7.5 test/clone_test.rb
composite_primary_keys-0.7.2 test/clone_test.rb
composite_primary_keys-0.7.3 test/clone_test.rb
composite_primary_keys-0.7.4 test/clone_test.rb