spec/mongomodel/document/persistence_spec.rb in mongomodel-0.5.3 vs spec/mongomodel/document/persistence_spec.rb in mongomodel-0.5.4
- old
+ new
@@ -92,18 +92,33 @@
end
class ::CustomCollectionNameSubclass < ::CustomCollectionName; end
::CustomCollectionNameSubclass.collection_name.should == 'foobar'
end
+
+ it "allows subclasses to set a custom collection name" do
+ class ::CustomCollectionName < Document; end
+ class ::CustomCollectionNameSubclass < ::CustomCollectionName
+ self.collection_name = 'custom'
+ end
+
+ ::CustomCollectionNameSubclass.collection_name.should == 'custom'
+ end
end
describe "#collection" do
it "is an instrumented collection" do
User.collection.should be_a(InstrumentedCollection)
end
it "uses the correct collection name" do
User.collection.name.should == 'users'
+ end
+
+ it "is updated when the collection name changes" do
+ collection = User.collection
+ User.collection_name = "custom"
+ User.collection.name.should == "custom"
end
end
describe "#database" do
it "returns the current database" do