glebtv-carrierwave-mongoid 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile.lock +17 -16
- data/README.md +214 -0
- data/gemfiles/carrierwave-0.8.gemfile +5 -0
- data/gemfiles/mongoid-3.0.gemfile +1 -0
- data/glebtv-carrierwave-mongoid.gemspec +3 -2
- data/lib/carrierwave/mongoid.rb +14 -0
- data/lib/carrierwave/mongoid/version.rb +1 -1
- data/spec/mongoid_spec.rb +45 -0
- data/spec/spec_helper.rb +9 -9
- data/spec/storage/grid_fs_spec.rb +8 -8
- metadata +36 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c88e0e0662ea059d12b9b6d8d6c692552ac4c25
|
4
|
+
data.tar.gz: f145561e76ac5ddb30ba2c38d4f4dcdc548ed4de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c079cfc4e0d55bb0e3336e3cf7f0171222ff803c99a55c4e6db18b4b89c82270976279fa2a9b10281bf25509e0e71fd67ff915f3c0843ce5b208c35207204b9
|
7
|
+
data.tar.gz: 606aa75b38a400347eee1033a7685c745225bc3d2309bf06a39621ec4148650eb3695b26c591977e9f7f1758331013691c2ba663e1812dc23502e30c58af096c
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
glebtv-carrierwave-mongoid (0.6.
|
5
|
-
carrierwave (
|
4
|
+
glebtv-carrierwave-mongoid (0.6.5)
|
5
|
+
carrierwave (>= 0.8.0, < 0.10.0)
|
6
|
+
mongoid (>= 3.0, < 5.0)
|
6
7
|
mongoid (>= 3.0, < 5.0)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: http://rubygems.org/
|
10
11
|
specs:
|
11
|
-
activemodel (3.2.
|
12
|
-
activesupport (= 3.2.
|
12
|
+
activemodel (3.2.15)
|
13
|
+
activesupport (= 3.2.15)
|
13
14
|
builder (~> 3.0.0)
|
14
|
-
activesupport (3.2.
|
15
|
+
activesupport (3.2.15)
|
15
16
|
i18n (~> 0.6, >= 0.6.4)
|
16
17
|
multi_json (~> 1.0)
|
17
18
|
builder (3.0.4)
|
@@ -21,18 +22,18 @@ GEM
|
|
21
22
|
json (>= 1.7)
|
22
23
|
coderay (1.0.9)
|
23
24
|
diff-lcs (1.2.4)
|
24
|
-
i18n (0.6.
|
25
|
-
json (1.8.
|
25
|
+
i18n (0.6.5)
|
26
|
+
json (1.8.1)
|
26
27
|
method_source (0.8.2)
|
27
28
|
mini_magick (3.6.0)
|
28
29
|
subexec (~> 0.2.1)
|
29
|
-
mongoid (3.1.
|
30
|
+
mongoid (3.1.5)
|
30
31
|
activemodel (~> 3.2)
|
31
32
|
moped (~> 1.4)
|
32
33
|
origin (~> 1.0)
|
33
|
-
tzinfo (~> 0.3.
|
34
|
-
moped (1.5.
|
35
|
-
multi_json (1.
|
34
|
+
tzinfo (~> 0.3.29)
|
35
|
+
moped (1.5.1)
|
36
|
+
multi_json (1.8.2)
|
36
37
|
origin (1.1.0)
|
37
38
|
pry (0.9.12.2)
|
38
39
|
coderay (~> 1.0.5)
|
@@ -43,13 +44,13 @@ GEM
|
|
43
44
|
rspec-core (~> 2.14.0)
|
44
45
|
rspec-expectations (~> 2.14.0)
|
45
46
|
rspec-mocks (~> 2.14.0)
|
46
|
-
rspec-core (2.14.
|
47
|
-
rspec-expectations (2.14.
|
47
|
+
rspec-core (2.14.6)
|
48
|
+
rspec-expectations (2.14.3)
|
48
49
|
diff-lcs (>= 1.1.3, < 2.0)
|
49
|
-
rspec-mocks (2.14.
|
50
|
+
rspec-mocks (2.14.4)
|
50
51
|
slop (3.4.6)
|
51
52
|
subexec (0.2.3)
|
52
|
-
tzinfo (0.3.
|
53
|
+
tzinfo (0.3.38)
|
53
54
|
|
54
55
|
PLATFORMS
|
55
56
|
ruby
|
@@ -59,4 +60,4 @@ DEPENDENCIES
|
|
59
60
|
mini_magick
|
60
61
|
pry
|
61
62
|
rake (~> 10.0)
|
62
|
-
rspec (~> 2.
|
63
|
+
rspec (~> 2.14)
|
data/README.md
CHANGED
@@ -3,3 +3,217 @@
|
|
3
3
|
# CarrierWave for Mongoid
|
4
4
|
|
5
5
|
See upstream for details: https://github.com/carrierwaveuploader/carrierwave-mongoid
|
6
|
+
|
7
|
+
|
8
|
+
This functionality used to be part of CarrierWave but has since been extracted
|
9
|
+
into this gem.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Install the latest release:
|
14
|
+
|
15
|
+
gem install carrierwave-mongoid
|
16
|
+
|
17
|
+
Require it in your code:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require 'carrierwave/mongoid'
|
21
|
+
```
|
22
|
+
|
23
|
+
Or, in Rails you can add it to your Gemfile:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
|
27
|
+
```
|
28
|
+
|
29
|
+
Note: If using Rails 4, you'll need to make sure `mongoid-grid_fs` is `>= 1.9.0`.
|
30
|
+
If in doubt, run `bundle update mongoid-grid_fs`
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
gem 'mongoid-grid_fs', github: 'ahoward/mongoid-grid_fs'
|
34
|
+
```
|
35
|
+
|
36
|
+
## Getting Started
|
37
|
+
|
38
|
+
Follow the "Getting Started" directions in the main
|
39
|
+
[Carrierwave repository](https://raw.github.com/carrierwaveuploader/carrierwave/).
|
40
|
+
|
41
|
+
[Suggested] Add the field to your attr_accessor list for mass assignment
|
42
|
+
protection:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
attr_accessible :avatar, :avatar_cache
|
46
|
+
```
|
47
|
+
|
48
|
+
Now you can cache files by assigning them to the attribute; they will
|
49
|
+
automatically be stored when the record is saved. Ex:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
u = User.new
|
53
|
+
u.avatar = File.open('somewhere')
|
54
|
+
u.save!
|
55
|
+
```
|
56
|
+
|
57
|
+
## Using MongoDB's GridFS store
|
58
|
+
|
59
|
+
In your uploader, set the storage to `:grid_fs`:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
class AvatarUploader < CarrierWave::Uploader::Base
|
63
|
+
storage :grid_fs
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
Bringing it all together, you can also configure Carrierwave to use Mongoid's
|
68
|
+
database connection and default all storage to GridFS. That might look something
|
69
|
+
like this:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
CarrierWave.configure do |config|
|
73
|
+
config.storage = :grid_fs
|
74
|
+
config.root = Rails.root.join('tmp')
|
75
|
+
config.cache_dir = "uploads"
|
76
|
+
end
|
77
|
+
```
|
78
|
+
|
79
|
+
## Serving uploading files
|
80
|
+
|
81
|
+
Since GridFS doesn't make the files available via HTTP, you'll need to stream
|
82
|
+
them yourself. For example, in Rails, you could use the `send_data` method:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
class UsersController < ApplicationController
|
86
|
+
def avatar
|
87
|
+
content = @user.avatar.read
|
88
|
+
if stale?(etag: content, last_modified: @user.updated_at.utc, public: true)
|
89
|
+
send_data content, type: @user.avatar.file.content_type, disposition: "inline"
|
90
|
+
expires_in 0, public: true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# and in routes.rb
|
96
|
+
resources :users do
|
97
|
+
get :avatar, on: :member
|
98
|
+
end
|
99
|
+
```
|
100
|
+
|
101
|
+
You can optionally tell CarrierWave the URL you will serve your images from,
|
102
|
+
allowing it to generate the correct URL, by setting `grid_fs_access_url`:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
CarrierWave.configure do |config|
|
106
|
+
config.grid_fs_access_url = "/systems/uploads"
|
107
|
+
end
|
108
|
+
```
|
109
|
+
|
110
|
+
## Route configuration
|
111
|
+
|
112
|
+
If you follow the instruction to this point, the uploaded images will be
|
113
|
+
stored to GridFS, and you are responsible for serving the images a public
|
114
|
+
endpoint. If you would like to use the `#url` method on the uploaded file, you
|
115
|
+
will need to take some additional steps.
|
116
|
+
|
117
|
+
The `grid_fs_access_url` configuration option is the prefix for the path of
|
118
|
+
the stored file in carrierwave.
|
119
|
+
|
120
|
+
Let's assume that we have a mounted `avatar` uploader on a `User` model and a
|
121
|
+
`GridfsController`. Let's also assume that your uploader definition
|
122
|
+
(i.e. `app/uploaders/avatar_uploader.rb`) defines `store_dir` like this:
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
def store_dir
|
126
|
+
"#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
127
|
+
end
|
128
|
+
```
|
129
|
+
|
130
|
+
If `grid_fs_access_url` (in `config/initializers/carrierwave.rb`) were:
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
config.grid_fs_access_url = '/uploads/grid'
|
134
|
+
```
|
135
|
+
|
136
|
+
You would need to define a route in your `config/routes.rb` like so:
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
match '/uploads/grid/user/avatar/:id/:filename' => 'gridfs#avatar'
|
140
|
+
```
|
141
|
+
|
142
|
+
Now, `user.avatar.url` should return an appropriate url path to use in your
|
143
|
+
views.
|
144
|
+
|
145
|
+
### Different uploaded versions
|
146
|
+
|
147
|
+
If you need to include different versions (e.g. thumbnails), additional routes
|
148
|
+
will help:
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
match '/uploads/grid/user/avatar/:id/:filename' => 'gridfs#thumb_avatar', constraints: { filename: /thumb.*/ }
|
152
|
+
```
|
153
|
+
|
154
|
+
## Version differences
|
155
|
+
|
156
|
+
| Version | Notes |
|
157
|
+
|----------|---------------------------------------------------------------------------------|
|
158
|
+
| ~> 0.6.0 | ([compare][compare-0.6], [dependencies][deps-0.6]) Mongoid 3 & 4, bug fixes |
|
159
|
+
| ~> 0.5.0 | ([compare][compare-0.5], [dependencies][deps-0.5]) Mongoid::Paranoia support |
|
160
|
+
| ~> 0.4.0 | ([compare][compare-0.4], [dependencies][deps-0.4]) Carrierwave bump |
|
161
|
+
| ~> 0.3.0 | ([compare][compare-0.3], [dependencies][deps-0.3]) Mongoid >= 3.0 |
|
162
|
+
| ~> 0.2.0 | ([compare][compare-0.2], [dependencies][deps-0.2]) Rails >= 3.2, Mongoid ~> 2.0 |
|
163
|
+
| ~> 0.1.0 | ([compare][compare-0.1], [dependencies][deps-0.1]) Rails <= 3.1 |
|
164
|
+
|
165
|
+
[compare-0.6]: https://github.com/carrierwaveuploader/carrierwave-mongoid/compare/v0.5.0...v0.6.3
|
166
|
+
[compare-0.5]: https://github.com/carrierwaveuploader/carrierwave-mongoid/compare/v0.4.0...v0.5.0
|
167
|
+
[compare-0.4]: https://github.com/carrierwaveuploader/carrierwave-mongoid/compare/v0.3.1...v0.4.0
|
168
|
+
[compare-0.3]: https://github.com/carrierwaveuploader/carrierwave-mongoid/compare/v0.2.1...v0.3.1
|
169
|
+
[compare-0.2]: https://github.com/carrierwaveuploader/carrierwave-mongoid/compare/v0.1.7...v0.2.2
|
170
|
+
[compare-0.1]: https://github.com/carrierwaveuploader/carrierwave-mongoid/compare/v0.1.1...v0.1.7
|
171
|
+
|
172
|
+
[deps-0.6]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.6.3
|
173
|
+
[deps-0.5]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.5.0
|
174
|
+
[deps-0.4]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.4.0
|
175
|
+
[deps-0.3]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.3.1
|
176
|
+
[deps-0.2]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.2.2
|
177
|
+
[deps-0.1]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.1.7
|
178
|
+
|
179
|
+
### Changes from earlier versions of CarrierWave <= 0.5.6
|
180
|
+
|
181
|
+
CarrierWave used to have built-in Mongoid support. This gem replaces that
|
182
|
+
support and only supports Mongoid ~> 2.1
|
183
|
+
|
184
|
+
You can use `upload_identifier` to retrieve the original name of the uploaded file.
|
185
|
+
|
186
|
+
In the earlier version, the mount_uploader-method for mongoid had been defined
|
187
|
+
in lib/carrierwave/orm/mongoid. This code has been moved to
|
188
|
+
carrierwave/mongoid. If you update from earlier versions, don't forget to adjust
|
189
|
+
your require accordingly in your carrierwave-initializer.
|
190
|
+
|
191
|
+
The default mount column used to be the name of the upload column plus
|
192
|
+
`_filename`. Now it is simply the name of the column. Most of the time, the
|
193
|
+
column was called `upload`, so it would have been mounted to `upload_filename`.
|
194
|
+
If you'd like to avoid a database migration, simply use the `:mount_on` option
|
195
|
+
to specify the field name explicitly. Therefore, you only have to add a
|
196
|
+
`_filename` to your column name. For example, if your column is called
|
197
|
+
`:upload`:
|
198
|
+
|
199
|
+
```ruby
|
200
|
+
class Dokument
|
201
|
+
mount_uploader :upload, DokumentUploader, mount_on: :upload_filename
|
202
|
+
end
|
203
|
+
```
|
204
|
+
|
205
|
+
## Known issues and limitations
|
206
|
+
|
207
|
+
Note that files mounted in embedded documents aren't saved when parent documents
|
208
|
+
are saved. By default, mongoid does not cascade callbacks on embedded
|
209
|
+
documents. In order to save the attached files on embedded documents, you must
|
210
|
+
either explicitly call save on the embedded documents or you must configure the
|
211
|
+
embedded association to cascade the callbacks automatically. For example:
|
212
|
+
|
213
|
+
```ruby
|
214
|
+
class User
|
215
|
+
embeds_many :pictures, cascade_callbacks: true
|
216
|
+
end
|
217
|
+
```
|
218
|
+
|
219
|
+
You can read more about this [here](https://github.com/carrierwaveuploader/carrierwave/issues#issue/81)
|
@@ -18,9 +18,10 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_dependency "carrierwave", ["~> 0.9.0"]
|
22
21
|
s.add_dependency "mongoid", [">= 3.0", "< 5.0"]
|
23
|
-
s.
|
22
|
+
s.add_dependency "carrierwave", [">= 0.8.0", "< 0.10.0"]
|
23
|
+
s.add_dependency "mongoid", [">= 3.0", "< 5.0"]
|
24
|
+
s.add_development_dependency "rspec", ["~> 2.14"]
|
24
25
|
s.add_development_dependency "rake", ["~> 10.0"]
|
25
26
|
s.add_development_dependency "mini_magick"
|
26
27
|
s.add_development_dependency "pry"
|
data/lib/carrierwave/mongoid.rb
CHANGED
@@ -45,6 +45,12 @@ module CarrierWave
|
|
45
45
|
super
|
46
46
|
end
|
47
47
|
|
48
|
+
def remove_#{column}=(arg)
|
49
|
+
column = _mounter(:#{column}).serialization_column
|
50
|
+
send(:"\#{column}_will_change!")
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
48
54
|
def remove_#{column}!
|
49
55
|
super unless respond_to?(:paranoid?) && paranoid? && flagged_for_destroy?
|
50
56
|
end
|
@@ -59,6 +65,14 @@ module CarrierWave
|
|
59
65
|
changed_attributes.has_key?("#{column}")
|
60
66
|
end
|
61
67
|
|
68
|
+
# The default Mongoid attribute_will_change! method is not enough
|
69
|
+
# when we want to upload a new file in an existing embedded document.
|
70
|
+
# The custom version of that method forces the callbacks to be
|
71
|
+
# ran and so does the upload.
|
72
|
+
def #{column}_will_change!
|
73
|
+
changed_attributes["#{column}"] = '_new_'
|
74
|
+
end
|
75
|
+
|
62
76
|
def find_previous_model_for_#{column}
|
63
77
|
if self.embedded?
|
64
78
|
ancestors = [[ self.metadata.key, self._parent ]].tap { |x| x.unshift([ x.first.last.metadata.key, x.first.last._parent ]) while x.first.last.embedded? }
|
data/spec/mongoid_spec.rb
CHANGED
@@ -569,6 +569,7 @@ describe CarrierWave::Mongoid do
|
|
569
569
|
|
570
570
|
@class.class_eval do
|
571
571
|
embeds_many :mongo_locations, cascade_callbacks: true
|
572
|
+
accepts_nested_attributes_for :mongo_locations
|
572
573
|
end
|
573
574
|
|
574
575
|
@doc = @class.new
|
@@ -592,6 +593,18 @@ describe CarrierWave::Mongoid do
|
|
592
593
|
doc.mongo_locations.first[:image].should == 'test.jpeg'
|
593
594
|
end
|
594
595
|
|
596
|
+
it "changes the file" do
|
597
|
+
@doc.update_attributes mongo_locations_attributes: { '0' => { _id: @embedded_doc._id, image: stub_file('test.jpeg') } }
|
598
|
+
@doc.reload
|
599
|
+
@doc.mongo_locations.first[:image].should == 'test.jpeg'
|
600
|
+
end
|
601
|
+
|
602
|
+
it "removes a file" do
|
603
|
+
@doc.update_attributes mongo_locations_attributes: { '0' => { _id: @embedded_doc._id, remove_image: "1" } }
|
604
|
+
@doc.reload
|
605
|
+
@doc.mongo_locations.first[:image].should_not be_present
|
606
|
+
end
|
607
|
+
|
595
608
|
describe 'with double embedded documents' do
|
596
609
|
|
597
610
|
before do
|
@@ -666,6 +679,38 @@ describe CarrierWave::Mongoid do
|
|
666
679
|
include_examples "double embedded documents"
|
667
680
|
end
|
668
681
|
end
|
682
|
+
|
683
|
+
describe 'with embedded documents and nested attributes' do
|
684
|
+
before do
|
685
|
+
@embedded_doc_class = define_mongo_class('MongoLocation') do
|
686
|
+
include Mongoid::Document
|
687
|
+
mount_uploader :image, @uploader
|
688
|
+
embedded_in :mongo_user
|
689
|
+
end
|
690
|
+
|
691
|
+
@class.class_eval do
|
692
|
+
embeds_many :mongo_locations, cascade_callbacks: true
|
693
|
+
accepts_nested_attributes_for :mongo_locations
|
694
|
+
end
|
695
|
+
|
696
|
+
@doc = @class.new(mongo_locations_attributes: [{image: stub_file("old.jpeg")}])
|
697
|
+
@doc.save.should be_true
|
698
|
+
@embedded_doc = @doc.mongo_locations.first
|
699
|
+
end
|
700
|
+
|
701
|
+
it "should set the image on a save" do
|
702
|
+
@doc.reload
|
703
|
+
@doc.mongo_locations.first.image.path.should match(/old\.jpeg$/)
|
704
|
+
@embedded_doc.image.path.should match(/old\.jpeg$/)
|
705
|
+
end
|
706
|
+
|
707
|
+
it "should update the image on update_attributes" do
|
708
|
+
@doc.update_attributes(mongo_locations_attributes: [{id: @embedded_doc.id, image: stub_file("new.jpeg")}]).should be_true
|
709
|
+
@doc.reload
|
710
|
+
@doc.mongo_locations.first.image.path.should match(/new\.jpeg$/)
|
711
|
+
@embedded_doc.image.path.should match(/new\.jpeg$/)
|
712
|
+
end
|
713
|
+
end
|
669
714
|
end
|
670
715
|
|
671
716
|
describe '#mount_uploader removing old files with versions' do
|
data/spec/spec_helper.rb
CHANGED
@@ -35,9 +35,9 @@ module CarrierWave
|
|
35
35
|
t = Tempfile.new(filename)
|
36
36
|
FileUtils.copy_file(file_path(filename), t.path)
|
37
37
|
|
38
|
-
t.stub
|
39
|
-
|
40
|
-
|
38
|
+
t.stub(:local_path => "",
|
39
|
+
:original_filename => filename || fake_name,
|
40
|
+
:content_type => mime_type)
|
41
41
|
|
42
42
|
return t
|
43
43
|
end
|
@@ -59,12 +59,12 @@ module CarrierWave
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
class SIO < StringIO
|
63
|
-
attr_accessor :filename
|
64
|
-
|
65
|
-
def initialize(filename, *args, &block)
|
66
|
-
@filename = filename
|
67
|
-
super(*args, &block)
|
62
|
+
class SIO < StringIO
|
63
|
+
attr_accessor :filename
|
64
|
+
|
65
|
+
def initialize(filename, *args, &block)
|
66
|
+
@filename = filename
|
67
|
+
super(*args, &block)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -7,7 +7,7 @@ require 'spec_helper'
|
|
7
7
|
shared_examples_for "a GridFS connection" do
|
8
8
|
describe '#store!' do
|
9
9
|
before do
|
10
|
-
@uploader.stub
|
10
|
+
@uploader.stub(:store_path).and_return('uploads/bar.txt')
|
11
11
|
@grid_fs_file = @storage.store!(@file)
|
12
12
|
end
|
13
13
|
|
@@ -49,7 +49,7 @@ shared_examples_for "a GridFS connection" do
|
|
49
49
|
before do
|
50
50
|
@grid.clear
|
51
51
|
@grid['uploads/bar.txt'] = StringIO.new('A test, 1234')
|
52
|
-
@uploader.stub
|
52
|
+
@uploader.stub(:store_path).with('bar.txt').and_return('uploads/bar.txt')
|
53
53
|
@grid_fs_file = @storage.retrieve!('bar.txt')
|
54
54
|
end
|
55
55
|
|
@@ -66,17 +66,17 @@ shared_examples_for "a GridFS connection" do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should return a relative URL path if access_url is set to the root path" do
|
69
|
-
@uploader.stub
|
69
|
+
@uploader.stub(:grid_fs_access_url).and_return("/")
|
70
70
|
@grid_fs_file.url.should == "/uploads/bar.txt"
|
71
71
|
end
|
72
72
|
|
73
73
|
it "should return a URL path if access_url is set to a file path" do
|
74
|
-
@uploader.stub
|
74
|
+
@uploader.stub(:grid_fs_access_url).and_return("/image/show")
|
75
75
|
@grid_fs_file.url.should == "/image/show/uploads/bar.txt"
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should return an absolute URL if access_url is set to an absolute URL" do
|
79
|
-
@uploader.stub
|
79
|
+
@uploader.stub(:grid_fs_access_url).and_return("http://example.com/images/")
|
80
80
|
@grid_fs_file.url.should == "http://example.com/images/uploads/bar.txt"
|
81
81
|
end
|
82
82
|
|
@@ -88,12 +88,12 @@ shared_examples_for "a GridFS connection" do
|
|
88
88
|
|
89
89
|
describe '#retrieve! on a store_dir with leading slash' do
|
90
90
|
before do
|
91
|
-
@uploader.stub
|
91
|
+
@uploader.stub(:store_path).with('bar.txt').and_return('/uploads/bar.txt')
|
92
92
|
@grid_fs_file = @storage.retrieve!('bar.txt')
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should return a relative URL path if access_url is set to the root path" do
|
96
|
-
@uploader.stub
|
96
|
+
@uploader.stub(:grid_fs_access_url).and_return("/")
|
97
97
|
@grid_fs_file.url.should == "/uploads/bar.txt"
|
98
98
|
end
|
99
99
|
end
|
@@ -181,4 +181,4 @@ if defined?(Mongoid::GridFs)
|
|
181
181
|
@grid.clear
|
182
182
|
end
|
183
183
|
end
|
184
|
-
end
|
184
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glebtv-carrierwave-mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GlebTv
|
@@ -10,22 +10,48 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mongoid
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
22
|
+
- - <
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '5.0'
|
25
|
+
type: :runtime
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '3.0'
|
32
|
+
- - <
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '5.0'
|
15
35
|
- !ruby/object:Gem::Dependency
|
16
36
|
name: carrierwave
|
17
37
|
requirement: !ruby/object:Gem::Requirement
|
18
38
|
requirements:
|
19
|
-
- -
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.8.0
|
42
|
+
- - <
|
20
43
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
44
|
+
version: 0.10.0
|
22
45
|
type: :runtime
|
23
46
|
prerelease: false
|
24
47
|
version_requirements: !ruby/object:Gem::Requirement
|
25
48
|
requirements:
|
26
|
-
- -
|
49
|
+
- - '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 0.8.0
|
52
|
+
- - <
|
27
53
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.
|
54
|
+
version: 0.10.0
|
29
55
|
- !ruby/object:Gem::Dependency
|
30
56
|
name: mongoid
|
31
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,14 +78,14 @@ dependencies:
|
|
52
78
|
requirements:
|
53
79
|
- - ~>
|
54
80
|
- !ruby/object:Gem::Version
|
55
|
-
version: '2.
|
81
|
+
version: '2.14'
|
56
82
|
type: :development
|
57
83
|
prerelease: false
|
58
84
|
version_requirements: !ruby/object:Gem::Requirement
|
59
85
|
requirements:
|
60
86
|
- - ~>
|
61
87
|
- !ruby/object:Gem::Version
|
62
|
-
version: '2.
|
88
|
+
version: '2.14'
|
63
89
|
- !ruby/object:Gem::Dependency
|
64
90
|
name: rake
|
65
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,6 +144,7 @@ files:
|
|
118
144
|
- LICENSE
|
119
145
|
- README.md
|
120
146
|
- Rakefile
|
147
|
+
- gemfiles/carrierwave-0.8.gemfile
|
121
148
|
- gemfiles/carrierwave-master.gemfile
|
122
149
|
- gemfiles/mongoid-3.0.gemfile
|
123
150
|
- gemfiles/mongoid-3.1.gemfile
|
@@ -158,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
185
|
version: '0'
|
159
186
|
requirements: []
|
160
187
|
rubyforge_project:
|
161
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.1.10
|
162
189
|
signing_key:
|
163
190
|
specification_version: 4
|
164
191
|
summary: This fork makes GridFS optional
|