Sha256: a09315d4eab53447d81bebdce54fa0b41081ea7d9ca2532f87da5165b34f43a0

Contents?: true

Size: 812 Bytes

Versions: 7

Compression:

Stored size: 812 Bytes

Contents

require 'abstract_unit'

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
      assert_equal(@first.attributes.block(@klass.primary_key), 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

7 entries across 7 versions & 1 rubygems

Version Path
composite_primary_keys-4.0.0.beta7 test/test_dup.rb
composite_primary_keys-4.0.0.beta6 test/test_dup.rb
composite_primary_keys-4.0.0.beta5 test/test_dup.rb
composite_primary_keys-4.0.0.beta4 test/test_dup.rb
composite_primary_keys-4.0.0.beta3 test/test_dup.rb
composite_primary_keys-4.0.0.beta2 test/test_dup.rb
composite_primary_keys-4.0.0.beta1 test/test_dup.rb