-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
I've been struggling with this for most of today Here's finally a simple repro.
This repro spec in https://github.com/dblock/mongoid/commit/3cb08404f5c3b2b2611d32c6214556e2d637592e, run rspec spec/functional/mongoid/relations/referenced/many_to_many_spec.rb:213.
Given
class Exhibitor
include Mongoid::Document
belongs_to :exhibition
has_and_belongs_to_many :artworks
end
class Exhibition
include Mongoid::Document
has_many :exhibitors
end
class Artwork
include Mongoid::Document
has_and_belongs_to_many :exhibitors
end
let(:artwork) do
Artwork.create
end
let(:exhibition) do
Exhibition.create
end
let(:exhibitor) do
Exhibitor.create(
)
end
before do
artwork.exhibitors << exhibitor
end
it "doesn't create additional artwork objects" do
Artwork.count.should == 1
end
Fails:
1) Mongoid::Relations::Referenced::ManyToMany#push when the relations are not polymorphic when one side has been persisted doesn't create additional person objects
Failure/Error: Artwork.count.should == 1
expected: 1
got: 2 (using ==)
- ./spec/functional/mongoid/relations/referenced/many_to_many_spec.rb:195:in `block (6 levels) in <top (required)>'
2) Mongoid::Relations::Referenced::ManyToMany#concat when the relations are not polymorphic when one side has been persisted doesn't create additional person objects
Failure/Error: Artwork.count.should == 1
expected: 1
got: 3 (using ==)
- ./spec/functional/mongoid/relations/referenced/many_to_many_spec.rb:195:in `block (6 levels) in <top (required)>'