Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Spec that shows a bug in associations

  • Loading branch information...
commit 5fb1ed1547d586427cdab92cfafd8a1f58242acd 1 parent e53d546
Dirkjan Bussink dbussink authored

Showing 1 changed file with 27 additions and 1 deletion. Show diff stats Hide diff stats

  1. +27 1 spec/integration/association_spec.rb
28 spec/integration/association_spec.rb
@@ -165,6 +165,19 @@ def self.default_repository_name
165 165 belongs_to :parent, :class_name => 'Node', :child_key => [ :parent_id ]
166 166 end
167 167
  168 + class MadeUpThing
  169 + include DataMapper::Resource
  170 +
  171 + def self.default_repository_name
  172 + ADAPTER
  173 + end
  174 +
  175 + property :id, Serial
  176 + property :name, String
  177 + belongs_to :area
  178 + belongs_to :machine
  179 + end
  180 +
168 181 module Models
169 182 class Project
170 183 include DataMapper::Resource
@@ -227,6 +240,7 @@ def self.default_repository_name
227 240
228 241 belongs_to :galaxy
229 242 end
  243 +
230 244 end
231 245
232 246 describe DataMapper::Associations do
@@ -274,6 +288,7 @@ def self.default_repository_name
274 288 before do
275 289 Machine.auto_migrate!(ADAPTER)
276 290 Area.auto_migrate!(ADAPTER)
  291 + MadeUpThing.auto_migrate!(ADAPTER)
277 292
278 293 machine1 = Machine.create(:name => 'machine1')
279 294 machine2 = Machine.create(:name => 'machine2')
@@ -299,7 +314,7 @@ def self.default_repository_name
299 314 end
300 315
301 316 it 'should save both the object and parent if both are new' do
302   - pending "This is fixed"
  317 + pending "This is a bug that should be fixed"
303 318 area1 = Area.new(:name => 'area1')
304 319 area1.machine = Machine.new(:name => 'machine1')
305 320 area1.machine.save
@@ -338,6 +353,17 @@ class Ostrich
338 353 Area.new(:machine => machine).machine_id.should == machine.id
339 354 end
340 355
  356 + it "should be able to set an association obtained from another association" do
  357 + pending "This is a bug that should be fixed"
  358 + machine1 = Machine.first(:name => 'machine1')
  359 + area1 = Area.first(:name => 'area1')
  360 +
  361 + m = MadeUpThing.create(:machine => machine1, :area => area1.machine, :name => "Weird")
  362 +
  363 + m.machine_id.should == machine1.id
  364 + m.area_id.should == area1.machine.id
  365 + end
  366 +
341 367 it 'should save the parent upon saving of child' do
342 368 e = Machine.new(:name => 'machine10')
343 369 y = Area.create(:name => 'area10', :machine => e)

0 comments on commit 5fb1ed1

Please sign in to comment.
Something went wrong with that request. Please try again.