Sha256: 75418fbfc4fd6f41584f8f3c28a204b5c4ccd7079202aa7b56f9fe3c884fef76
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 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 a custom property' do before :all do class ::CustomPK < DataMapper::Property::String key true end class ::Animal include DataMapper::Resource property :id, Serial property :name, String belongs_to :zoo end class ::Zoo include DataMapper::Resource property :id, ::CustomPK has n, :animals end DataMapper.finalize end supported_by :all do before :all do @zoo = Zoo.create(:id => 'foo') @animal = @zoo.animals.create(:name => 'marty') end it 'should have FK of the same property type as zoo PK' do Animal.properties[:zoo_id].class.should be(Zoo.properties[:id].class) end it 'should be able to access parent' do @animal.zoo.should == @zoo end it 'should be able to access the children' do @zoo.animals.should == [ @animal ] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dm-core-1.0.2 | spec/public/associations/many_to_one_with_custom_fk_spec.rb |
dm-core-1.0.1 | spec/public/associations/many_to_one_with_custom_fk_spec.rb |