spec/orm/mongomapper_spec.rb in durran-carrierwave-0.3.2.3 vs spec/orm/mongomapper_spec.rb in durran-carrierwave-0.4.3

- old
+ new

@@ -162,20 +162,38 @@ before do @doc = @class.new end - context "when file assigned" do + describe "when file assigned" do it "removes the file from the filesystem" do @doc.image = stub_file('test.jpeg') @doc.save.should be_true File.exist?(public_path('uploads/test.jpeg')).should be_true @doc.image.should be_an_instance_of(@uploader) @doc.image.current_path.should == public_path('uploads/test.jpeg') @doc.destroy File.exist?(public_path('uploads/test.jpeg')).should be_false end + + end + + describe "when file is not assigned" do + + it "deletes the instance of @class after save" do + @doc.save + @class.count.should eql(1) + @doc.destroy + end + + it "deletes the instance of @class after save and then re-looking up the instance" do + # this fails with TypeError in 'CarrierWave::MongoMapper#destroy when file is not assigned deletes the instance of @class' can't modify frozen object + @doc.save + @class.count.should eql(1) + @doc = @class.first + @doc.destroy + end end end \ No newline at end of file