Sha256: f856ed3035bf15391d38faa74445660bcaf24c9bea44e8f445ac428e196a5bf3

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))

# TODO: combine this into many_to_one_spec.rb

describe 'Many to One Associations when foreign key is part of a composite key, with an integer and a boolean making up the composite key' do
  before :all do
    class ::ManyModel
      include DataMapper::Resource

      property :integer_key, Integer, :key => true
      property :boolean_key, Boolean, :key => true

      belongs_to :one_model, :child_key => [ :integer_key ]
    end

    class ::OneModel
      include DataMapper::Resource

      property :integer_key, Integer, :key => true

      has n, :many_models, :child_key => [ :integer_key ]
    end
    DataMapper.finalize
  end

  supported_by :all do
    before :all do
      @one  = OneModel.create(:integer_key => 1)
      @many = ManyModel.create(:integer_key => 1, :boolean_key => false)
    end

    it 'should be able to access parent' do
      @many.one_model.should == @one
    end

    it 'should be able to access the child' do
      @one.many_models.should == [ @many ]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dm-core-1.0.2 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb
dm-core-1.0.1 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb
dm-core-1.0.0 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb
dm-core-1.0.0.rc3 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb