This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 1:1 with CPK containing a boolean property
[#994 state:resolved] Signed-off-by: Dan Kubb <dan.kubb@gmail.com>
- Loading branch information
Showing
5 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
spec/public/associations/one_to_one_with_boolean_cpk_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
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 | ||
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 |