Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Spec that shows a bug in associations

  • Loading branch information...
commit 5fb1ed1547d586427cdab92cfafd8a1f58242acd 1 parent e53d546
@dbussink dbussink authored
Showing with 27 additions and 1 deletion.
  1. +27 −1 spec/integration/association_spec.rb
View
28 spec/integration/association_spec.rb
@@ -165,6 +165,19 @@ def self.default_repository_name
belongs_to :parent, :class_name => 'Node', :child_key => [ :parent_id ]
end
+ class MadeUpThing
+ include DataMapper::Resource
+
+ def self.default_repository_name
+ ADAPTER
+ end
+
+ property :id, Serial
+ property :name, String
+ belongs_to :area
+ belongs_to :machine
+ end
+
module Models
class Project
include DataMapper::Resource
@@ -227,6 +240,7 @@ def self.default_repository_name
belongs_to :galaxy
end
+
end
describe DataMapper::Associations do
@@ -274,6 +288,7 @@ def self.default_repository_name
before do
Machine.auto_migrate!(ADAPTER)
Area.auto_migrate!(ADAPTER)
+ MadeUpThing.auto_migrate!(ADAPTER)
machine1 = Machine.create(:name => 'machine1')
machine2 = Machine.create(:name => 'machine2')
@@ -299,7 +314,7 @@ def self.default_repository_name
end
it 'should save both the object and parent if both are new' do
- pending "This is fixed"
+ pending "This is a bug that should be fixed"
area1 = Area.new(:name => 'area1')
area1.machine = Machine.new(:name => 'machine1')
area1.machine.save
@@ -338,6 +353,17 @@ class Ostrich
Area.new(:machine => machine).machine_id.should == machine.id
end
+ it "should be able to set an association obtained from another association" do
+ pending "This is a bug that should be fixed"
+ machine1 = Machine.first(:name => 'machine1')
+ area1 = Area.first(:name => 'area1')
+
+ m = MadeUpThing.create(:machine => machine1, :area => area1.machine, :name => "Weird")
+
+ m.machine_id.should == machine1.id
+ m.area_id.should == area1.machine.id
+ end
+
it 'should save the parent upon saving of child' do
e = Machine.new(:name => 'machine10')
y = Area.create(:name => 'area10', :machine => e)
Please sign in to comment.
Something went wrong with that request. Please try again.