carrierwave-mongoid 0.6.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/README.md +3 -0
- data/carrierwave-mongoid.gemspec +1 -1
- data/gemfiles/carrierwave-0.9.gemfile +5 -0
- data/lib/carrierwave/mongoid.rb +5 -1
- data/lib/carrierwave/mongoid/version.rb +1 -1
- data/spec/mongoid_spec.rb +63 -27
- metadata +28 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dbf263632bb757b907feefed47df535df9afb48
|
4
|
+
data.tar.gz: bdd37086a47d6897a7dc6aed9294c263a8496c90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b87c77b666919997a01c0a35b92091854ae1a4aa18580555983211482c3dbafcd7d6165bb1760f40f19c14911f49c05775cd83f6a2f88b784cd400db72bb0905
|
7
|
+
data.tar.gz: b1021356aafedbb825cba0ca564322e705b1e2d17a334dc2128fee57807c5344fe5f67ed92076e950c47ccac5de8500be4027ac47f16de626fa9e302b530e72a
|
data/.travis.yml
CHANGED
@@ -4,15 +4,17 @@ notifications:
|
|
4
4
|
email: false
|
5
5
|
|
6
6
|
language: ruby
|
7
|
+
cache: bundler
|
7
8
|
rvm:
|
8
9
|
- 1.9.3
|
9
10
|
- 2.0.0
|
11
|
+
- 2.1.1
|
10
12
|
- jruby-19mode
|
11
|
-
- rbx-19mode
|
12
13
|
|
13
14
|
gemfile:
|
14
15
|
- Gemfile
|
15
16
|
- gemfiles/carrierwave-0.8.gemfile
|
17
|
+
- gemfiles/carrierwave-0.9.gemfile
|
16
18
|
- gemfiles/carrierwave-master.gemfile
|
17
19
|
- gemfiles/mongoid-3.0.gemfile
|
18
20
|
- gemfiles/mongoid-3.1.gemfile
|
data/README.md
CHANGED
@@ -153,6 +153,7 @@ match '/uploads/grid/user/avatar/:id/:filename' => 'gridfs#thumb_avatar', constr
|
|
153
153
|
|
154
154
|
| Version | Notes |
|
155
155
|
|----------|---------------------------------------------------------------------------------|
|
156
|
+
| ~> 0.7.0 | ([compare][compare-0.7], [dependencies][deps-0.7]) Mongoid 3 & 4, bug fixes |
|
156
157
|
| ~> 0.6.0 | ([compare][compare-0.6], [dependencies][deps-0.6]) Mongoid 3 & 4, bug fixes |
|
157
158
|
| ~> 0.5.0 | ([compare][compare-0.5], [dependencies][deps-0.5]) Mongoid::Paranoia support |
|
158
159
|
| ~> 0.4.0 | ([compare][compare-0.4], [dependencies][deps-0.4]) Carrierwave bump |
|
@@ -160,6 +161,7 @@ match '/uploads/grid/user/avatar/:id/:filename' => 'gridfs#thumb_avatar', constr
|
|
160
161
|
| ~> 0.2.0 | ([compare][compare-0.2], [dependencies][deps-0.2]) Rails >= 3.2, Mongoid ~> 2.0 |
|
161
162
|
| ~> 0.1.0 | ([compare][compare-0.1], [dependencies][deps-0.1]) Rails <= 3.1 |
|
162
163
|
|
164
|
+
[compare-0.7]: https://github.com/carrierwaveuploader/carrierwave-mongoid/compare/v0.6.3...v0.7.0
|
163
165
|
[compare-0.6]: https://github.com/carrierwaveuploader/carrierwave-mongoid/compare/v0.5.0...v0.6.3
|
164
166
|
[compare-0.5]: https://github.com/carrierwaveuploader/carrierwave-mongoid/compare/v0.4.0...v0.5.0
|
165
167
|
[compare-0.4]: https://github.com/carrierwaveuploader/carrierwave-mongoid/compare/v0.3.1...v0.4.0
|
@@ -167,6 +169,7 @@ match '/uploads/grid/user/avatar/:id/:filename' => 'gridfs#thumb_avatar', constr
|
|
167
169
|
[compare-0.2]: https://github.com/carrierwaveuploader/carrierwave-mongoid/compare/v0.1.7...v0.2.2
|
168
170
|
[compare-0.1]: https://github.com/carrierwaveuploader/carrierwave-mongoid/compare/v0.1.1...v0.1.7
|
169
171
|
|
172
|
+
[deps-0.7]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.7.0
|
170
173
|
[deps-0.6]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.6.3
|
171
174
|
[deps-0.5]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.5.0
|
172
175
|
[deps-0.4]: https://rubygems.org/gems/carrierwave-mongoid/versions/0.4.0
|
data/carrierwave-mongoid.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
s.add_dependency "carrierwave", [">= 0.8.0", "< 0.
|
23
|
+
s.add_dependency "carrierwave", [">= 0.8.0", "< 0.11.0"]
|
24
24
|
s.add_dependency "mongoid", [">= 3.0", "< 5.0"]
|
25
25
|
s.add_dependency "mongoid-grid_fs", ["~> 1.3"]
|
26
26
|
s.add_development_dependency "rspec", ["~> 2.14"]
|
data/lib/carrierwave/mongoid.rb
CHANGED
@@ -73,7 +73,11 @@ module CarrierWave
|
|
73
73
|
|
74
74
|
def find_previous_model_for_#{column}
|
75
75
|
if self.embedded?
|
76
|
-
|
76
|
+
if self.respond_to?(:__metadata) # Mongoid >= 4.0.0.beta1
|
77
|
+
ancestors = [[ self.__metadata.key, self._parent ]].tap { |x| x.unshift([ x.first.last.__metadata.key, x.first.last._parent ]) while x.first.last.embedded? }
|
78
|
+
else # Mongoid < 4.0.0.beta1
|
79
|
+
ancestors = [[ self.metadata.key, self._parent ]].tap { |x| x.unshift([ x.first.last.metadata.key, x.first.last._parent ]) while x.first.last.embedded? }
|
80
|
+
end
|
77
81
|
first_parent = ancestors.first.last
|
78
82
|
reloaded_parent = first_parent.class.unscoped.find(first_parent.to_key.first)
|
79
83
|
association = ancestors.inject(reloaded_parent) { |parent,(key,ancestor)| (parent.is_a?(Array) ? parent.find(ancestor.to_key.first) : parent).send(key) }
|
data/spec/mongoid_spec.rb
CHANGED
@@ -196,18 +196,36 @@ describe CarrierWave::Mongoid do
|
|
196
196
|
end
|
197
197
|
|
198
198
|
it "should use I18n for integrity error messages" do
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
199
|
+
if Gem::Dependency.new('CarrierWave', '>= 0.10.0').match?('CarrierWave', CarrierWave::VERSION)
|
200
|
+
change_locale_and_store_translations(:en, :mongoid => {
|
201
|
+
:errors => { :models => { :mongo_user => { :attributes => {
|
202
|
+
:image => { :carrierwave_integrity_error => 'is not of an allowed file type'
|
203
|
+
}}}}}}) do
|
204
|
+
@doc.should_not be_valid
|
205
|
+
@doc.errors[:image].should == ['is not of an allowed file type']
|
206
|
+
end
|
207
|
+
|
208
|
+
change_locale_and_store_translations(:pt, :mongoid => {
|
209
|
+
:errors => { :models => { :mongo_user => { :attributes => {
|
210
|
+
:image => { :carrierwave_integrity_error => 'tipo de imagem não permitido.'
|
211
|
+
}}}}}}) do
|
212
|
+
@doc.should_not be_valid
|
213
|
+
@doc.errors[:image].should == ['tipo de imagem não permitido.']
|
214
|
+
end
|
215
|
+
else # Test for older versions of Carrierwave
|
216
|
+
@doc.valid?
|
217
|
+
@doc.errors[:image].should == ['is not of an allowed file type']
|
218
|
+
|
219
|
+
change_locale_and_store_translations(:pt, :mongoid => {
|
220
|
+
:errors => {
|
221
|
+
:messages => {
|
222
|
+
:carrierwave_integrity_error => 'tipo de imagem não permitido.'
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}) do
|
226
|
+
@doc.should_not be_valid
|
227
|
+
@doc.errors[:image].should == ['tipo de imagem não permitido.']
|
228
|
+
end
|
211
229
|
end
|
212
230
|
end
|
213
231
|
end
|
@@ -224,18 +242,36 @@ describe CarrierWave::Mongoid do
|
|
224
242
|
end
|
225
243
|
|
226
244
|
it "should use I18n for processing error messages" do
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
245
|
+
if Gem::Dependency.new('CarrierWave', '>= 0.10.0').match?('CarrierWave', CarrierWave::VERSION)
|
246
|
+
change_locale_and_store_translations(:en, :mongoid => {
|
247
|
+
:errors => { :models => { :mongo_user => { :attributes => {
|
248
|
+
:image => { :carrierwave_processing_error => 'failed to be processed'
|
249
|
+
}}}}}}) do
|
250
|
+
@doc.should_not be_valid
|
251
|
+
@doc.errors[:image].should == ['failed to be processed']
|
252
|
+
end
|
253
|
+
|
254
|
+
change_locale_and_store_translations(:pt, :mongoid => {
|
255
|
+
:errors => { :models => { :mongo_user => { :attributes => {
|
256
|
+
:image => { :carrierwave_processing_error => 'falha ao processar imagem.'
|
257
|
+
}}}}}}) do
|
258
|
+
@doc.should_not be_valid
|
259
|
+
@doc.errors[:image].should == ['falha ao processar imagem.']
|
260
|
+
end
|
261
|
+
else # Test for older versions of Carrierwave
|
262
|
+
@doc.valid?
|
263
|
+
@doc.errors[:image].should == ['failed to be processed']
|
264
|
+
|
265
|
+
change_locale_and_store_translations(:pt, :mongoid => {
|
266
|
+
:errors => {
|
267
|
+
:messages => {
|
268
|
+
:carrierwave_processing_error => 'falha ao processar imagem.'
|
269
|
+
}
|
270
|
+
}
|
271
|
+
}) do
|
272
|
+
@doc.should_not be_valid
|
273
|
+
@doc.errors[:image].should == ['falha ao processar imagem.']
|
274
|
+
end
|
239
275
|
end
|
240
276
|
end
|
241
277
|
end
|
@@ -290,7 +326,7 @@ describe CarrierWave::Mongoid do
|
|
290
326
|
@doc.save.should be_true
|
291
327
|
@doc.reload
|
292
328
|
@doc.image.should be_blank
|
293
|
-
@doc.image_identifier.should
|
329
|
+
@doc.image_identifier.should be_blank
|
294
330
|
end
|
295
331
|
|
296
332
|
end
|
@@ -547,7 +583,7 @@ describe CarrierWave::Mongoid do
|
|
547
583
|
|
548
584
|
@class.class_eval do
|
549
585
|
embeds_one :mongo_location
|
550
|
-
default_scope where(:always_false => false)
|
586
|
+
default_scope ->{ where(:always_false => false) }
|
551
587
|
end
|
552
588
|
|
553
589
|
@doc = @class.new
|
@@ -642,7 +678,7 @@ describe CarrierWave::Mongoid do
|
|
642
678
|
|
643
679
|
@class.class_eval do
|
644
680
|
embeds_many :mongo_locations
|
645
|
-
default_scope where(:always_false => false)
|
681
|
+
default_scope ->{ where(:always_false => false) }
|
646
682
|
end
|
647
683
|
|
648
684
|
@doc = @class.new
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
@@ -9,116 +9,116 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: carrierwave
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 0.8.0
|
21
|
-
- - <
|
21
|
+
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.11.0
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
|
-
- -
|
28
|
+
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: 0.8.0
|
31
|
-
- - <
|
31
|
+
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.11.0
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: mongoid
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.0'
|
41
|
-
- - <
|
41
|
+
- - "<"
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '5.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
46
|
version_requirements: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
|
-
- -
|
48
|
+
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '3.0'
|
51
|
-
- - <
|
51
|
+
- - "<"
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '5.0'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: mongoid-grid_fs
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- - ~>
|
58
|
+
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '1.3'
|
61
61
|
type: :runtime
|
62
62
|
prerelease: false
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - ~>
|
65
|
+
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '1.3'
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
name: rspec
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - ~>
|
72
|
+
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '2.14'
|
75
75
|
type: :development
|
76
76
|
prerelease: false
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- - ~>
|
79
|
+
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '2.14'
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: rake
|
84
84
|
requirement: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- - ~>
|
86
|
+
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '10.0'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
91
|
version_requirements: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- - ~>
|
93
|
+
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '10.0'
|
96
96
|
- !ruby/object:Gem::Dependency
|
97
97
|
name: mini_magick
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- -
|
100
|
+
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
type: :development
|
104
104
|
prerelease: false
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: pry
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
type: :development
|
118
118
|
prerelease: false
|
119
119
|
version_requirements: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
|
-
- -
|
121
|
+
- - ">="
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '0'
|
124
124
|
description: Mongoid support for CarrierWave
|
@@ -128,14 +128,15 @@ executables: []
|
|
128
128
|
extensions: []
|
129
129
|
extra_rdoc_files: []
|
130
130
|
files:
|
131
|
-
- .gitignore
|
132
|
-
- .travis.yml
|
131
|
+
- ".gitignore"
|
132
|
+
- ".travis.yml"
|
133
133
|
- Gemfile
|
134
134
|
- LICENSE
|
135
135
|
- README.md
|
136
136
|
- Rakefile
|
137
137
|
- carrierwave-mongoid.gemspec
|
138
138
|
- gemfiles/carrierwave-0.8.gemfile
|
139
|
+
- gemfiles/carrierwave-0.9.gemfile
|
139
140
|
- gemfiles/carrierwave-master.gemfile
|
140
141
|
- gemfiles/mongoid-3.0.gemfile
|
141
142
|
- gemfiles/mongoid-3.1.gemfile
|
@@ -164,17 +165,17 @@ require_paths:
|
|
164
165
|
- lib
|
165
166
|
required_ruby_version: !ruby/object:Gem::Requirement
|
166
167
|
requirements:
|
167
|
-
- -
|
168
|
+
- - ">="
|
168
169
|
- !ruby/object:Gem::Version
|
169
170
|
version: '0'
|
170
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
172
|
requirements:
|
172
|
-
- -
|
173
|
+
- - ">="
|
173
174
|
- !ruby/object:Gem::Version
|
174
175
|
version: '0'
|
175
176
|
requirements: []
|
176
177
|
rubyforge_project: carrierwave-mongoid
|
177
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.2.2
|
178
179
|
signing_key:
|
179
180
|
specification_version: 4
|
180
181
|
summary: Mongoid support for CarrierWave
|