has_moderated 1.1.5 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/has_moderated/associations/base.rb +5 -6
- data/lib/has_moderated/associations/has_one.rb +4 -4
- data/lib/has_moderated/carrier_wave.rb +45 -25
- data/lib/has_moderated/moderated_create.rb +3 -3
- data/lib/has_moderated/moderation_model.rb +4 -4
- data/lib/has_moderated/moderation_preview.rb +11 -11
- data/lib/has_moderated/version.rb +1 -1
- data/test/dummy/log/test.log +34042 -0
- data/test/dummy/public/uploads/tmp/{20121024-1607-1557-8676 → 20121031-1115-2165-7602}/test.jpg +0 -0
- data/test/dummy/public/uploads/tmp/{20121024-1607-1557-8676 → 20121031-1115-2165-7602}/thumb_test.jpg +0 -0
- data/test/dummy/spec/models/photo_spec.rb +113 -1
- data/test/dummy/spec/support/photos.rb +3 -3
- metadata +8 -8
data/test/dummy/public/uploads/tmp/{20121024-1607-1557-8676 → 20121031-1115-2165-7602}/test.jpg
RENAMED
File without changes
|
File without changes
|
@@ -35,6 +35,7 @@ describe Photo do
|
|
35
35
|
Photo.count.should eq(1)
|
36
36
|
photo = Photo.first
|
37
37
|
assert_photo_uploaded(photo.avatar)
|
38
|
+
File.exist?(photo.avatar.versions[:thumb].file.file).should be_true
|
38
39
|
end
|
39
40
|
|
40
41
|
it "should not move temp file when doing preview" do
|
@@ -210,10 +211,121 @@ describe Photo do
|
|
210
211
|
preview.avatar.url.should match(/\A\/uploads\/tmp\/.+\/test.jpg\z/)
|
211
212
|
preview.avatar.current_path.should eq(Moderation.last.parsed_data[:attributes]["avatar_tmp_file"])
|
212
213
|
preview.avatar_url.should eq(preview.avatar.url)
|
213
|
-
preview.avatar.
|
214
|
+
preview.avatar.file.class.should eq(::CarrierWave::HasModeratedTempFile)
|
214
215
|
|
215
216
|
Photo.last.avatar.current_path.should be_blank
|
216
217
|
Photo.last.avatar_url.should be_blank
|
217
218
|
end
|
219
|
+
|
220
|
+
it "should show the temporary file as the photo (create moderation)" do
|
221
|
+
reload_models.photo {
|
222
|
+
mount_uploader :avatar, GenericUploader
|
223
|
+
send :include, HasModerated::CarrierWave
|
224
|
+
has_moderated_create
|
225
|
+
has_moderated_carrierwave_field :avatar
|
226
|
+
}
|
227
|
+
|
228
|
+
photo_file = carrierwave_test_photo
|
229
|
+
photo = Photo.create! :avatar => photo_file
|
230
|
+
tmpEmpty?.should be_false
|
231
|
+
uploadEmpty?.should be_true
|
232
|
+
preview = Moderation.last.preview
|
233
|
+
preview.avatar.url.should match(/\A\/uploads\/tmp\/.+\/test.jpg\z/)
|
234
|
+
preview.avatar.current_path.should eq(Moderation.last.parsed_data[:create][:attributes]["avatar_tmp_file"])
|
235
|
+
preview.avatar_url.should eq(preview.avatar.url)
|
236
|
+
preview.avatar.file.class.should eq(::CarrierWave::HasModeratedTempFile)
|
237
|
+
tmpEmpty?.should be_false
|
238
|
+
uploadEmpty?.should be_true
|
239
|
+
end
|
240
|
+
|
241
|
+
it "should not move image to uploads when calling save on live_preview" do
|
242
|
+
reload_models.photo {
|
243
|
+
mount_uploader :avatar, GenericUploader
|
244
|
+
send :include, HasModerated::CarrierWave
|
245
|
+
has_moderated_create
|
246
|
+
has_moderated_carrierwave_field :avatar
|
247
|
+
}
|
248
|
+
|
249
|
+
photo_file = carrierwave_test_photo
|
250
|
+
photo = Photo.create! :avatar => photo_file
|
251
|
+
tmpEmpty?.should be_false
|
252
|
+
uploadEmpty?.should be_true
|
253
|
+
Moderation.last.live_preview do |m|
|
254
|
+
m.save
|
255
|
+
uploadEmpty?.should be_true
|
256
|
+
end
|
257
|
+
tmpEmpty?.should be_false
|
258
|
+
uploadEmpty?.should be_true
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should not move image to uploads when calling save on preview" do
|
262
|
+
reload_models.photo {
|
263
|
+
mount_uploader :avatar, GenericUploader
|
264
|
+
send :include, HasModerated::CarrierWave
|
265
|
+
has_moderated_create
|
266
|
+
has_moderated_carrierwave_field :avatar
|
267
|
+
}
|
268
|
+
|
269
|
+
photo_file = carrierwave_test_photo
|
270
|
+
photo = Photo.create! :avatar => photo_file
|
271
|
+
tmpEmpty?.should be_false
|
272
|
+
uploadEmpty?.should be_true
|
273
|
+
m = Moderation.last.preview
|
274
|
+
m.save
|
275
|
+
tmpEmpty?.should be_false
|
276
|
+
uploadEmpty?.should be_true
|
277
|
+
end
|
278
|
+
|
279
|
+
it "should show the temporary file as the photo (create assoc moderation)" do
|
280
|
+
reload_models.task {
|
281
|
+
has_many :photos, :class_name => photo_class_name, :foreign_key => "parentable_id"
|
282
|
+
has_moderated_create :with_associations => [:photos]
|
283
|
+
}.photo {
|
284
|
+
mount_uploader :avatar, GenericUploader
|
285
|
+
send :include, HasModerated::CarrierWave
|
286
|
+
has_moderated_carrierwave_field :avatar
|
287
|
+
belongs_to :task, :class_name => task_class_name, :foreign_key => "parentable_id"
|
288
|
+
}
|
289
|
+
|
290
|
+
photo_file = carrierwave_test_photo
|
291
|
+
task = Task.new
|
292
|
+
photo = task.photos.build :avatar => photo_file
|
293
|
+
task.save
|
294
|
+
tmpEmpty?.should be_false
|
295
|
+
uploadEmpty?.should be_true
|
296
|
+
preview = Moderation.last.preview.photos.first
|
297
|
+
preview.avatar.url.should match(/\A\/uploads\/tmp\/.+\/test.jpg\z/)
|
298
|
+
preview.avatar.current_path.should eq(Moderation.last.parsed_data[:create][:associations][:photos].first["avatar_tmp_file"])
|
299
|
+
preview.avatar_url.should eq(preview.avatar.url)
|
300
|
+
preview.avatar.file.class.should eq(::CarrierWave::HasModeratedTempFile)
|
301
|
+
tmpEmpty?.should be_false
|
302
|
+
uploadEmpty?.should be_true
|
303
|
+
end
|
304
|
+
|
305
|
+
it "should show the temporary file as the photo (assoc moderation)" do
|
306
|
+
reload_models.task {
|
307
|
+
has_many :photos, :class_name => photo_class_name, :foreign_key => "parentable_id"
|
308
|
+
has_moderated_association :photos
|
309
|
+
}.photo {
|
310
|
+
mount_uploader :avatar, GenericUploader
|
311
|
+
send :include, HasModerated::CarrierWave
|
312
|
+
has_moderated_carrierwave_field :avatar
|
313
|
+
belongs_to :task, :class_name => task_class_name, :foreign_key => "parentable_id"
|
314
|
+
}
|
315
|
+
|
316
|
+
photo_file = carrierwave_test_photo
|
317
|
+
task = Task.new
|
318
|
+
photo = task.photos.build :avatar => photo_file
|
319
|
+
task.save
|
320
|
+
tmpEmpty?.should be_false
|
321
|
+
uploadEmpty?.should be_true
|
322
|
+
preview = Moderation.last.preview.photos.first
|
323
|
+
preview.avatar.url.should match(/\A\/uploads\/tmp\/.+\/test.jpg\z/)
|
324
|
+
preview.avatar.current_path.should eq(Moderation.last.parsed_data[:associations][:photos].first["avatar_tmp_file"])
|
325
|
+
preview.avatar_url.should eq(preview.avatar.url)
|
326
|
+
preview.avatar.file.class.should eq(::CarrierWave::HasModeratedTempFile)
|
327
|
+
tmpEmpty?.should be_false
|
328
|
+
uploadEmpty?.should be_true
|
329
|
+
end
|
218
330
|
end
|
219
331
|
end
|
@@ -19,15 +19,15 @@ TEMPDIR = File.expand_path("../../../public/uploads/tmp", __FILE__)
|
|
19
19
|
|
20
20
|
def carrierwave_test_photo
|
21
21
|
test_photo_path = File.expand_path("../../../public/test.jpg", __FILE__)
|
22
|
-
File.open(test_photo_path, "
|
22
|
+
File.open(test_photo_path, "rb")
|
23
23
|
end
|
24
24
|
|
25
25
|
def assert_photo_uploaded photo
|
26
26
|
photo.should_not be_nil
|
27
27
|
photo.file.should_not be_nil
|
28
28
|
photo.file.file.should_not be_nil
|
29
|
-
|
29
|
+
|
30
30
|
filename = photo.file.file
|
31
31
|
File.exist?(filename)
|
32
32
|
assert(filename =~ /avatar\/1\/test.jpg\Z/)
|
33
|
-
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_moderated
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -241,8 +241,8 @@ files:
|
|
241
241
|
- test/dummy/public/500.html
|
242
242
|
- test/dummy/public/favicon.ico
|
243
243
|
- test/dummy/public/test.jpg
|
244
|
-
- test/dummy/public/uploads/tmp/
|
245
|
-
- test/dummy/public/uploads/tmp/
|
244
|
+
- test/dummy/public/uploads/tmp/20121031-1115-2165-7602/test.jpg
|
245
|
+
- test/dummy/public/uploads/tmp/20121031-1115-2165-7602/thumb_test.jpg
|
246
246
|
- test/dummy/Rakefile
|
247
247
|
- test/dummy/script/rails
|
248
248
|
- test/dummy/spec/models/photo_spec.rb
|
@@ -264,7 +264,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
264
264
|
version: '0'
|
265
265
|
segments:
|
266
266
|
- 0
|
267
|
-
hash: -
|
267
|
+
hash: -1072446703184255041
|
268
268
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
269
269
|
none: false
|
270
270
|
requirements:
|
@@ -273,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
273
|
version: '0'
|
274
274
|
segments:
|
275
275
|
- 0
|
276
|
-
hash: -
|
276
|
+
hash: -1072446703184255041
|
277
277
|
requirements: []
|
278
278
|
rubyforge_project:
|
279
279
|
rubygems_version: 1.8.24
|
@@ -316,8 +316,8 @@ test_files:
|
|
316
316
|
- test/dummy/public/500.html
|
317
317
|
- test/dummy/public/favicon.ico
|
318
318
|
- test/dummy/public/test.jpg
|
319
|
-
- test/dummy/public/uploads/tmp/
|
320
|
-
- test/dummy/public/uploads/tmp/
|
319
|
+
- test/dummy/public/uploads/tmp/20121031-1115-2165-7602/test.jpg
|
320
|
+
- test/dummy/public/uploads/tmp/20121031-1115-2165-7602/thumb_test.jpg
|
321
321
|
- test/dummy/Rakefile
|
322
322
|
- test/dummy/script/rails
|
323
323
|
- test/dummy/spec/models/photo_spec.rb
|