Sha256: 176c523388d3e02153f41b5438b30cdbcbc1b05c04efa6e6cd010d58782ecb4b

Contents?: true

Size: 1.01 KB

Versions: 11

Compression:

Stored size: 1.01 KB

Contents

require '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

11 entries across 11 versions & 3 rubygems

Version Path
ardm-core-1.3.0 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb
ardm-core-1.2.1 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb
dm-core-1.2.1 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb
ghost_dm-core-1.3.0.beta spec/public/associations/many_to_one_with_boolean_cpk_spec.rb
dm-core-1.2.0 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb
dm-core-1.2.0.rc2 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb
dm-core-1.2.0.rc1 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb
dm-core-1.1.0 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb
dm-core-1.1.0.rc3 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb
dm-core-1.1.0.rc2 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb
dm-core-1.1.0.rc1 spec/public/associations/many_to_one_with_boolean_cpk_spec.rb