Skip to content

Commit

Permalink
Spec that shows a bug in associations
Browse files Browse the repository at this point in the history
  • Loading branch information
dbussink committed Jul 24, 2008
1 parent e53d546 commit 5fb1ed1
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion spec/integration/association_spec.rb
Expand Up @@ -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
Expand Down Expand Up @@ -227,6 +240,7 @@ def self.default_repository_name

belongs_to :galaxy
end

end

describe DataMapper::Associations do
Expand Down Expand Up @@ -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')
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5fb1ed1

Please sign in to comment.