Sha256: 30fb1e39228e1a842a4893b13c386a1a34e6da9ce0f4ae3c77a600c59dc97839

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

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

# TODO: combine this into one_to_one_spec.rb

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

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

      has 1, :child_model, :child_key => [ :integer_key, :boolean_key ]
    end

    class ::ChildModel
      include DataMapper::Resource

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

      belongs_to :parent_model, :child_key => [ :integer_key, :boolean_key ]
    end
    DataMapper.finalize
  end

  supported_by :all do
    before :all do
      @parent = ParentModel.create(:integer_key => 1, :boolean_key => false)
      @child  = ChildModel.create(:integer_key => 1, :other_integer_key => 1, :boolean_key => false)
    end

    it 'should be able to access the child' do
      @parent.child_model.should == @child
    end

    it 'should be able to access the parent' do
      @child.parent_model.should == @parent
    end

    it 'should be able to access the parent_key' do
      @child.parent_model.key.should_not be_nil
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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