
Resources reloaded from a class method .get are not in the current repository
Reported by Ashley Moran | September 11th, 2009 @ 09:19 AM | in 0.10.0
This may or may not be related to #931, and so may or may not be fixed already. Unfortunately I've had trouble upgrading to 0.10RC2 because of software not recompiling through MacPorts on Snow Leopard.
This one is really easily demonstrated with a spec example:
require 'rubygems'
require 'dm-core'
require 'spec'
require 'spec/autorun'
SQLITE_FILE = File.join(`pwd`.chomp, "test.db")
DataMapper.setup(:default, "sqlite3:#{SQLITE_FILE}")
DataMapper.setup(:reloaded, "sqlite3:#{SQLITE_FILE}")
class Parent
include DataMapper::Resource
property :id, Serial
has n, :debts
end
class Debt
include DataMapper::Resource
property :id, Serial
belongs_to :parent
end
Spec::Runner.configure do |config|
config.before(:each) do
Parent.auto_migrate!
Debt.auto_migrate!
end
config.before(:each) do
DataMapper::Repository.context << repository(:default)
end
config.after(:each) do
DataMapper::Repository.context.pop
end
end
describe Parent, "with debts, 1 to n" do
before(:each) do
@parent = Parent.new
@parent.debts << Debt.new(:parent => @parent)
@parent.save
end
it "1 to n associations appears to be sharing associations across an identity map" do
repository(:reloaded) do
parent_reloaded = Parent.get(@parent.id)
first_debt = parent_reloaded.debts.first
Debt.get(first_debt.id).repository.name.should == first_debt.repository.name
end
end
end
Comments and changes to this ticket
-
Martin Gamsjaeger (snusnu) September 12th, 2009 @ 06:50 PM
- Milestone set to 0.10.0
- State changed from new to resolved
Tested this on latest edge and it's green.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »