spec/unit/mongoid/identity_spec.rb in mongoid-1.2.7 vs spec/unit/mongoid/identity_spec.rb in mongoid-1.2.8
- old
+ new
@@ -4,12 +4,33 @@
describe ".create" do
let(:name) { Name.new }
- it "sets the document _type to the class name" do
- Mongoid::Identity.create(name)
- name._type.should == "Name"
+ context "when persisting types" do
+
+ it "sets the document _type to the class name" do
+ Mongoid::Identity.create(name)
+ name._type.should == "Name"
+ end
+
+ end
+
+ context "when not persisting types" do
+
+ before do
+ Mongoid.persist_types = false
+ @name = Name.new
+ end
+
+ after do
+ Mongoid.persist_types = true
+ end
+
+ it "does not set the type" do
+ @name._type.should be_nil
+ end
+
end
it "returns the document" do
Mongoid::Identity.create(name).should == name
end