Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: carrierwaveuploader/carrierwave-mongoid
base: v0.4.0
...
head fork: carrierwaveuploader/carrierwave-mongoid
compare: v0.5.0
Checking mergeability… Don't worry, you can still create the pull request.
  • 13 commits
  • 7 files changed
  • 0 commit comments
  • 3 contributors
View
1  .gitignore
@@ -4,5 +4,6 @@ pkg/*
.bundle
spec/public
.rvmrc
+.ruby-version
Gemfile.lock
log/*
View
28 README.md
@@ -1,4 +1,4 @@
-# CarrierWave for Mongoid [![Build Status](https://travis-ci.org/jnicklas/carrierwave-mongoid.png?branch=master)](http://travis-ci.org/jnicklas/carrierwave-mongoid)
+# CarrierWave for Mongoid [![Gem Version](https://badge.fury.io/rb/carrierwave-mongoid.png)](http://badge.fury.io/rb/carrierwave-mongoid) [![Build Status](https://travis-ci.org/jnicklas/carrierwave-mongoid.png?branch=master)](http://travis-ci.org/jnicklas/carrierwave-mongoid)
This gem adds support for Mongoid and MongoDB's GridFS to
[CarrierWave](https://github.com/jnicklas/carrierwave/)
@@ -72,23 +72,27 @@ end
## Version differences
-### 0.3.x
+| Version | Notes |
+|----------|---------------------------------------------------------------------------------|
+| ~> 0.4.0 | ([compare][compare-0.4], [dependencies][deps-0.4]) |
+| ~> 0.3.0 | ([compare][compare-0.3], [dependencies][deps-0.3]) Mongoid >= 3.0 |
+| ~> 0.2.0 | ([compare][compare-0.2], [dependencies][deps-0.2]) Rails >= 3.2, Mongoid ~> 2.0 |
+| ~> 0.1.0 | ([compare][compare-0.1], [dependencies][deps-0.1]) Rails <= 3.1 |
-carrierwave-mongoid ~> 0.3.0 is only compatible with Mongoid 3.0 or higher.
+[compare-0.4]: https://github.com/jnicklas/carrierwave-mongoid/compare/v0.3.1...v0.4.0
+[compare-0.3]: https://github.com/jnicklas/carrierwave-mongoid/compare/v0.2.1...v0.3.1
+[compare-0.2]: https://github.com/jnicklas/carrierwave-mongoid/compare/v0.1.7...v0.2.2
+[compare-0.1]: https://github.com/jnicklas/carrierwave-mongoid/compare/v0.1.1...v0.1.7
-### 0.2.x
-
-carrierwave-mongoid ~> 0.2.0 is only compatible with Rails 3.2 or higher.
-
-### 0.1.x
-
-carrierwave-mongoid ~> 0.1.1 depends on carrierwave ~> 0.5.7. This version of
-carrierwave is only compatible with Rails 3.1 or earlier.
+[deps-0.4]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.4.0
+[deps-0.3]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.3.1
+[deps-0.2]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.2.2
+[deps-0.1]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.1.7
### Changes from earlier versions of CarrierWave <= 0.5.6
CarrierWave used to have built-in Mongoid support. This gem replaces that
-support and only only supports Mongoid ~> 2.1
+support and only supports Mongoid ~> 2.1
You can use `upload_identifier` to retrieve the original name of the uploaded file.
View
1  carrierwave-mongoid.gemspec
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
s.homepage = "https://github.com/jnicklas/carrierwave-mongoid"
s.summary = %q{Mongoid support for CarrierWave}
s.description = %q{Mongoid support for CarrierWave}
+ s.license = "MIT"
s.rubyforge_project = "carrierwave-mongoid"
View
4 lib/carrierwave/mongoid.rb
@@ -39,6 +39,10 @@ def #{column}=(new_file)
super
end
+ def remove_#{column}!
+ super unless paranoid? && flagged_for_destroy?
+ end
+
# Overrides Mongoid's default dirty behavior to instead work more like
# ActiveRecord's. Mongoid doesn't deem an attribute as changed unless
# the new value is different than the original. Given that CarrierWave
View
2  lib/carrierwave/mongoid/version.rb
@@ -1,5 +1,5 @@
module Carrierwave
module Mongoid
- VERSION = "0.4.0"
+ VERSION = "0.5.0"
end
end
View
4 lib/carrierwave/storage/grid_fs.rb
@@ -75,7 +75,7 @@ class << File
def grid
self.class.grid
end
- end
+ end # File
##
# Store the file in MongoDB's GridFS GridStore
@@ -109,6 +109,6 @@ def retrieve!(identifier)
CarrierWave::Storage::GridFS::File.new(uploader, uploader.store_path(identifier))
end
- end # File
+ end # GridFS
end # Storage
end # CarrierWave
View
27 spec/mongoid_spec.rb
@@ -766,6 +766,33 @@ def filename
end
end
+ describe "with paranoia enabled" do
+ before do
+ @class = reset_mongo_class
+ @class.collection.drop
+ @class.class_eval do
+ include Mongoid::Paranoia
+ end
+
+ @doc = @class.new(image: stub_file("old.jpeg"))
+ @doc.save.should be_true
+ end
+
+ it "should not remove underlying image after #destroy" do
+ @doc.destroy.should be_true
+ @class.count.should eql(0)
+ @class.deleted.count.should eql(1)
+ File.exist?(public_path('uploads/old.jpeg')).should be_true
+ end
+
+ it "should remove underlying image after #destroy!" do
+ @doc.destroy!.should be_true
+ @class.count.should eql(0)
+ @class.deleted.count.should eql(0)
+ File.exist?(public_path('uploads/old.jpeg')).should be_false
+ end
+ end
+
context "JSON serialization with multiple uploaders" do
before do
@class = reset_mongo_class

No commit comments for this range

Something went wrong with that request. Please try again.