Skip to content

Commit

Permalink
Example of slug-swapping not supported by Garner::Strategies::Binding…
Browse files Browse the repository at this point in the history
…::Invalidation::BindingIndex
  • Loading branch information
Frank Macreery committed Sep 20, 2013
1 parent 7acfcc6 commit 64e6d3c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions spec/integration/mongoid_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,36 @@
end
end
end

context "with non-unique identities" do
before(:each) do
Garner.configure do |config|
config.mongoid_identity_fields = [:_id, :_slugs]
end

class Other
include Mongoid::Document
include Mongoid::Slug

field :name, :type => String
slug :name
end
end

it "honors objects that take another object's identity" do
one = Other.create!({ :name => "foo" })
garnered_one = Other.garnered_find("foo")
garnered_one.should == one

one.update_attributes!({ :name => "bar" })

two = Other.create!({ :name => "foo" })
garnered_one = Other.garnered_find("bar")
garnered_two = Other.garnered_find("foo")
garnered_one.should == one
garnered_two.should == two
end
end
end

context "binding at the class level" do
Expand Down

0 comments on commit 64e6d3c

Please sign in to comment.