Sha256: 130fc3c9b9ca00d9b3082a745c7b09ab1c1b005174487f5052615d2a99cd9b45

Contents?: true

Size: 891 Bytes

Versions: 12

Compression:

Stored size: 891 Bytes

Contents

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

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_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

12 entries across 12 versions & 3 rubygems

Version Path
kovyrin-composite_primary_keys-2.3.2 test/test_clone.rb
composite_primary_keys-3.0.9 test/test_clone.rb
composite_primary_keys-3.0.8 test/test_clone.rb
composite_primary_keys-3.0.7 test/test_clone.rb
composite_primary_keys-3.0.4 test/test_clone.rb
composite_primary_keys-3.0.3 test/test_clone.rb
composite_primary_keys-3.0.0.b3 test/test_clone.rb
composite_primary_keys-3.0.0.b2 test/test_clone.rb
globe-composite_primary_keys-3.0.1 test/test_clone.rb
composite_primary_keys-2.3.5.1 test/test_clone.rb
composite_primary_keys-2.3.5 test/test_clone.rb
composite_primary_keys-2.3.2 test/test_clone.rb