carrierwave-mongoid 0.7.1 → 0.8.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 546cccccad42fd221e2e5b7eb648a6496938066e
4
- data.tar.gz: d72d1396c3087ce802928b71ed3ddaf46c400069
3
+ metadata.gz: e6d704a82ae744ea8d3986f24ec4f23595197f15
4
+ data.tar.gz: 219c19a07e25c6843b7a6ad5c704df981838c8fc
5
5
  SHA512:
6
- metadata.gz: 623ddf9f57b47f8f5578b99c502d7aa5835e6bc9da8b678f3524dd9e9076d3f3054be2d97ab76b1f05f2937b5f6dc4de1cb6e45fb28d93e4f22e93a01f613746
7
- data.tar.gz: 571f755e7e4f399a84867a3079136fd79189a38867ea7d63e13c08147261aea732722d250eed800f7bedf046ddd99c352ae4c0e9599d81299310e796403d81e1
6
+ metadata.gz: 7c3224e77f60d7f838ae6aaacfae419117a8e2ce7b30c40a1db665697b7c0a3f358f849c4dbc330c14b41679a6b395419577f2807f4bc0e7816f0f5aae9c1917
7
+ data.tar.gz: 800f1a5496c8b70b828e2c31dd6fcc946e0ae415cecbfce741a84e3f28be33f4c51bd4ad2e8ab1cadca954168ef1c3214d126fb63ee4f72cb809bbef259e381d
@@ -1,3 +1,4 @@
1
+ sudo: false
1
2
  services: mongodb
2
3
 
3
4
  notifications:
@@ -6,16 +7,19 @@ notifications:
6
7
  language: ruby
7
8
  cache: bundler
8
9
  rvm:
9
- - 1.9.3
10
10
  - 2.0.0
11
- - 2.1.1
11
+ - 2.1
12
+ - 2.2
12
13
  - jruby-19mode
13
14
 
14
15
  gemfile:
15
16
  - Gemfile
16
- - gemfiles/carrierwave-0.8.gemfile
17
17
  - gemfiles/carrierwave-0.9.gemfile
18
18
  - gemfiles/carrierwave-master.gemfile
19
- - gemfiles/mongoid-3.0.gemfile
20
19
  - gemfiles/mongoid-3.1.gemfile
21
20
  - gemfiles/mongoid-4.0.gemfile
21
+
22
+ matrix:
23
+ allow_failures:
24
+ - gemfile: gemfiles/carrierwave-master.gemfile
25
+ fast_finish: true
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # CarrierWave for Mongoid [![Gem Version](https://badge.fury.io/rb/carrierwave-mongoid.svg)](http://badge.fury.io/rb/carrierwave-mongoid) [![Build Status](https://travis-ci.org/carrierwaveuploader/carrierwave-mongoid.svg)](http://travis-ci.org/carrierwaveuploader/carrierwave-mongoid) [![Code Climate](http://img.shields.io/codeclimate/github/carrierwaveuploader/carrierwave-mongoid.svg)](https://codeclimate.com/github/carrierwaveuploader/carrierwave-mongoid)
1
+ # CarrierWave for Mongoid
2
2
 
3
3
  This gem adds support for Mongoid and MongoDB's GridFS to
4
4
  [CarrierWave](https://github.com/carrierwaveuploader/carrierwave/)
@@ -6,6 +6,8 @@ This gem adds support for Mongoid and MongoDB's GridFS to
6
6
  This functionality used to be part of CarrierWave but has since been extracted
7
7
  into this gem.
8
8
 
9
+ [![Gem Version](http://img.shields.io/gem/v/carrierwave-mongoid.svg)](https://rubygems.org/gems/carrierwave-mongoid) [![Build Status](https://travis-ci.org/carrierwaveuploader/carrierwave-mongoid.svg)](http://travis-ci.org/carrierwaveuploader/carrierwave-mongoid) [![Code Climate](http://img.shields.io/codeclimate/github/carrierwaveuploader/carrierwave-mongoid.svg)](https://codeclimate.com/github/carrierwaveuploader/carrierwave-mongoid)
10
+
9
11
  ## Installation
10
12
 
11
13
  Install the latest release:
@@ -34,7 +36,7 @@ gem 'mongoid-grid_fs', github: 'ahoward/mongoid-grid_fs'
34
36
  ## Getting Started
35
37
 
36
38
  Follow the "Getting Started" directions in the main
37
- [Carrierwave repository](https://raw.github.com/carrierwaveuploader/carrierwave/).
39
+ [Carrierwave repository](https://github.com/carrierwaveuploader/carrierwave/).
38
40
 
39
41
  [Suggested] Add the field to your attr_accessor list for mass assignment
40
42
  protection:
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.require_paths = ["lib"]
22
22
 
23
23
  s.add_dependency "carrierwave", [">= 0.8.0", "< 0.11.0"]
24
- s.add_dependency "mongoid", [">= 3.0", "< 5.0"]
24
+ s.add_dependency "mongoid", [">= 3.0", "<= 6.0"]
25
25
  s.add_dependency "mongoid-grid_fs", [">= 1.3", "< 3.0"]
26
26
  s.add_development_dependency "rspec", ["~> 2.14"]
27
27
  s.add_development_dependency "rake", ["~> 10.0"]
@@ -1,5 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "mongoid", github: "mongoid/mongoid", branch: "3.1.0-stable"
3
+ gem "mongoid", "~> 3.1.0"
4
4
 
5
5
  gemspec path: "../"
@@ -1,6 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "mongoid-grid_fs", github: "ahoward/mongoid-grid_fs", branch: "master"
4
- gem "mongoid", github: "mongoid/mongoid", branch: "master"
3
+ gem "mongoid", "~> 4.0.0"
5
4
 
6
5
  gemspec path: "../"
@@ -1,5 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "carrierwave", "~> 0.8.0"
3
+ gem "mongoid", "~> 5.0.0"
4
4
 
5
5
  gemspec path: "../"
@@ -44,8 +44,10 @@ module CarrierWave
44
44
  end
45
45
 
46
46
  def remove_#{column}=(arg)
47
- column = _mounter(:#{column}).serialization_column
48
- send(:"\#{column}_will_change!")
47
+ if ['1', true].include?(arg)
48
+ column = _mounter(:#{column}).serialization_column
49
+ send(:"\#{column}_will_change!")
50
+ end
49
51
  super
50
52
  end
51
53
 
@@ -1,5 +1,5 @@
1
1
  module Carrierwave
2
2
  module Mongoid
3
- VERSION = "0.7.1"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
@@ -238,11 +238,43 @@ describe CarrierWave::Mongoid do
238
238
 
239
239
  end
240
240
 
241
+ describe '#remove_image=' do
242
+ before do
243
+ mongo_user_klass = reset_mongo_class
244
+ @doc = mongo_user_klass.new
245
+ end
246
+
247
+ it "treats true argument such that attribute is marked as changed" do
248
+ @doc.remove_image = true
249
+ @doc.should be_image_changed
250
+ end
251
+
252
+ it "treats '1' argument such that attribute is marked as changed" do
253
+ @doc.remove_image = '1'
254
+ @doc.should be_image_changed
255
+ end
256
+
257
+ it "treats false argument such that attribute is not marked as changed" do
258
+ @doc.remove_image = false
259
+ @doc.should_not be_image_changed
260
+ end
261
+
262
+ it "treats nil argument such that attribute is not marked as changed" do
263
+ @doc.remove_image = nil
264
+ @doc.should_not be_image_changed
265
+ end
266
+
267
+ it "treats '0' argument such that attribute is not marked as changed" do
268
+ @doc.remove_image = '0'
269
+ @doc.should_not be_image_changed
270
+ end
271
+ end
272
+
241
273
  describe "#save" do
242
274
 
243
275
  it "after it was initialized with params" do
244
276
  doc = reset_mongo_class.new(:image => stub_file('test.jpg'))
245
- doc.save.should be_true
277
+ doc.save.should be_truthy
246
278
  doc.image.should be_an_instance_of(MongoUploader)
247
279
  doc.image.current_path.should == public_path('uploads/test.jpg')
248
280
  end
@@ -255,7 +287,7 @@ describe CarrierWave::Mongoid do
255
287
  context "when no file is assigned" do
256
288
 
257
289
  it "image is blank" do
258
- @doc.save.should be_true
290
+ @doc.save.should be_truthy
259
291
  @doc.image.should be_blank
260
292
  end
261
293
 
@@ -265,14 +297,14 @@ describe CarrierWave::Mongoid do
265
297
 
266
298
  it "copies the file to the upload directory" do
267
299
  @doc.image = stub_file('test.jpg')
268
- @doc.save.should be_true
300
+ @doc.save.should be_truthy
269
301
  @doc.image.should be_an_instance_of(MongoUploader)
270
302
  @doc.image.current_path.should == public_path('uploads/test.jpg')
271
303
  end
272
304
 
273
305
  it "saves the filename in the database" do
274
306
  @doc.image = stub_file('test.jpg')
275
- @doc.save.should be_true
307
+ @doc.save.should be_truthy
276
308
  @doc[:image].should == 'test.jpg'
277
309
  @doc.image_identifier.should == 'test.jpg'
278
310
  end
@@ -283,7 +315,7 @@ describe CarrierWave::Mongoid do
283
315
  @doc.image = stub_file('test.jpeg')
284
316
  @doc.save
285
317
  @doc.remove_image = true
286
- @doc.save.should be_true
318
+ @doc.save.should be_truthy
287
319
  @doc.reload
288
320
  @doc.image.should be_blank
289
321
  @doc.image_identifier.should be_blank
@@ -292,14 +324,14 @@ describe CarrierWave::Mongoid do
292
324
  end
293
325
 
294
326
  it "should mark image as changed when saving a new image" do
295
- @doc.image_changed?.should be_false
327
+ @doc.image_changed?.should be_falsey
296
328
  @doc.image = stub_file("test.jpeg")
297
- @doc.image_changed?.should be_true
329
+ @doc.image_changed?.should be_truthy
298
330
  @doc.save
299
331
  @doc.reload
300
- @doc.image_changed?.should be_false
332
+ @doc.image_changed?.should be_falsey
301
333
  @doc.image = stub_file("test.jpg")
302
- @doc.image_changed?.should be_true
334
+ @doc.image_changed?.should be_truthy
303
335
  end
304
336
 
305
337
  end
@@ -337,12 +369,12 @@ describe CarrierWave::Mongoid do
337
369
 
338
370
  it "removes the file from the filesystem" do
339
371
  @doc.image = stub_file('test.jpeg')
340
- @doc.save.should be_true
341
- File.exist?(public_path('uploads/test.jpeg')).should be_true
372
+ @doc.save.should be_truthy
373
+ File.exist?(public_path('uploads/test.jpeg')).should be_truthy
342
374
  @doc.image.should be_an_instance_of(MongoUploader)
343
375
  @doc.image.current_path.should == public_path('uploads/test.jpeg')
344
376
  @doc.destroy
345
- File.exist?(public_path('uploads/test.jpeg')).should be_false
377
+ File.exist?(public_path('uploads/test.jpeg')).should be_falsey
346
378
  end
347
379
 
348
380
  end
@@ -351,13 +383,13 @@ describe CarrierWave::Mongoid do
351
383
 
352
384
  it "deletes the instance of MongoUser after save" do
353
385
  @doc.save
354
- MongoUser.count.should eql(1)
386
+ MongoUser.count.should eq(1)
355
387
  @doc.destroy
356
388
  end
357
389
 
358
390
  it "deletes the instance of MongoUser after save and then re-looking up the instance" do
359
391
  @doc.save
360
- MongoUser.count.should eql(1)
392
+ MongoUser.count.should eq(1)
361
393
  @doc = MongoUser.first
362
394
  @doc.destroy
363
395
  end
@@ -374,8 +406,8 @@ describe CarrierWave::Mongoid do
374
406
  @class.field :foo
375
407
  @doc = @class.new
376
408
  @doc.image = stub_file('old.jpeg')
377
- @doc.save.should be_true
378
- File.exists?(public_path('uploads/old.jpeg')).should be_true
409
+ @doc.save.should be_truthy
410
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
379
411
  end
380
412
 
381
413
  after do
@@ -386,30 +418,30 @@ describe CarrierWave::Mongoid do
386
418
 
387
419
  it "should remove old file if old file had a different path" do
388
420
  @doc.image = stub_file('new.jpeg')
389
- @doc.save.should be_true
390
- File.exists?(public_path('uploads/new.jpeg')).should be_true
391
- File.exists?(public_path('uploads/old.jpeg')).should be_false
421
+ @doc.save.should be_truthy
422
+ File.exists?(public_path('uploads/new.jpeg')).should be_truthy
423
+ File.exists?(public_path('uploads/old.jpeg')).should be_falsey
392
424
  end
393
425
 
394
426
  it "should not remove old file if old file had a different path but config is false" do
395
427
  @uploader.stub(:remove_previously_stored_files_after_update).and_return(false)
396
428
  @doc.image = stub_file('new.jpeg')
397
- @doc.save.should be_true
398
- File.exists?(public_path('uploads/new.jpeg')).should be_true
399
- File.exists?(public_path('uploads/old.jpeg')).should be_true
429
+ @doc.save.should be_truthy
430
+ File.exists?(public_path('uploads/new.jpeg')).should be_truthy
431
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
400
432
  end
401
433
 
402
434
  it "should not remove file if old file had the same path" do
403
435
  @doc.image = stub_file('old.jpeg')
404
- @doc.save.should be_true
405
- File.exists?(public_path('uploads/old.jpeg')).should be_true
436
+ @doc.save.should be_truthy
437
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
406
438
  end
407
439
 
408
440
  it "should not remove file if validations fail on save" do
409
441
  @class.validate { |r| r.errors.add :textfile, "FAIL!" }
410
442
  @doc.image = stub_file('new.jpeg')
411
- @doc.save.should be_false
412
- File.exists?(public_path('uploads/old.jpeg')).should be_true
443
+ @doc.save.should be_falsey
444
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
413
445
  end
414
446
  end
415
447
 
@@ -423,60 +455,60 @@ describe CarrierWave::Mongoid do
423
455
 
424
456
  @doc.image = stub_file('old.jpeg')
425
457
  @doc.foo = "test"
426
- @doc.save.should be_true
427
- File.exists?(public_path('uploads/test.jpeg')).should be_true
458
+ @doc.save.should be_truthy
459
+ File.exists?(public_path('uploads/test.jpeg')).should be_truthy
428
460
  @doc.image.read.should == "this is stuff"
429
461
  end
430
462
 
431
463
  it "should not remove file if old file had the same dynamic path" do
432
464
  @doc.image = stub_file('test.jpeg')
433
- @doc.save.should be_true
434
- File.exists?(public_path('uploads/test.jpeg')).should be_true
465
+ @doc.save.should be_truthy
466
+ File.exists?(public_path('uploads/test.jpeg')).should be_truthy
435
467
  end
436
468
 
437
469
  it "should remove old file if old file had a different dynamic path" do
438
470
  @doc.foo = "new"
439
471
  @doc.image = stub_file('test.jpeg')
440
- @doc.save.should be_true
441
- File.exists?(public_path('uploads/new.jpeg')).should be_true
442
- File.exists?(public_path('uploads/test.jpeg')).should be_false
472
+ @doc.save.should be_truthy
473
+ File.exists?(public_path('uploads/new.jpeg')).should be_truthy
474
+ File.exists?(public_path('uploads/test.jpeg')).should be_falsey
443
475
  end
444
476
  end
445
477
 
446
478
  shared_examples "embedded documents" do
447
479
  it "should remove old file if old file had a different path" do
448
480
  @embedded_doc.image = stub_file('new.jpeg')
449
- @embedded_doc.save.should be_true
450
- File.exists?(public_path('uploads/new.jpeg')).should be_true
451
- File.exists?(public_path('uploads/old.jpeg')).should be_false
481
+ @embedded_doc.save.should be_truthy
482
+ File.exists?(public_path('uploads/new.jpeg')).should be_truthy
483
+ File.exists?(public_path('uploads/old.jpeg')).should be_falsey
452
484
  end
453
485
 
454
486
  it "should not remove old file if old file had a different path but config is false" do
455
487
  @embedded_doc.image.stub(:remove_previously_stored_files_after_update).and_return(false)
456
488
  @embedded_doc.image = stub_file('new.jpeg')
457
- @embedded_doc.save.should be_true
458
- File.exists?(public_path('uploads/new.jpeg')).should be_true
459
- File.exists?(public_path('uploads/old.jpeg')).should be_true
489
+ @embedded_doc.save.should be_truthy
490
+ File.exists?(public_path('uploads/new.jpeg')).should be_truthy
491
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
460
492
  end
461
493
 
462
494
  it "should not remove file if old file had the same path" do
463
495
  @embedded_doc.image = stub_file('old.jpeg')
464
- @embedded_doc.save.should be_true
465
- File.exists?(public_path('uploads/old.jpeg')).should be_true
496
+ @embedded_doc.save.should be_truthy
497
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
466
498
  end
467
499
 
468
500
  it "should not remove file if validations fail on save" do
469
501
  @embedded_doc_class.validate { |r| r.errors.add :textfile, "FAIL!" }
470
502
  @embedded_doc.image = stub_file('new.jpeg')
471
- @embedded_doc.save.should be_false
472
- File.exists?(public_path('uploads/old.jpeg')).should be_true
503
+ @embedded_doc.save.should be_falsey
504
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
473
505
  end
474
506
 
475
507
  it "should not touch parent's dirty attributes" do
476
508
  @class.field :title
477
509
  @doc.title = "Title"
478
510
  @embedded_doc.image = stub_file('new.jpeg')
479
- @embedded_doc.save.should be_true
511
+ @embedded_doc.save.should be_truthy
480
512
  @doc.title.should == "Title"
481
513
  end
482
514
  end
@@ -484,30 +516,30 @@ describe CarrierWave::Mongoid do
484
516
  shared_examples "double embedded documents" do
485
517
  it "should remove old file if old file had a different path" do
486
518
  @double_embedded_doc.image = stub_file('new.jpeg')
487
- @double_embedded_doc.save.should be_true
488
- File.exists?(public_path('uploads/new.jpeg')).should be_true
489
- File.exists?(public_path('uploads/old.jpeg')).should be_false
519
+ @double_embedded_doc.save.should be_truthy
520
+ File.exists?(public_path('uploads/new.jpeg')).should be_truthy
521
+ File.exists?(public_path('uploads/old.jpeg')).should be_falsey
490
522
  end
491
523
 
492
524
  it "should not remove old file if old file had a different path but config is false" do
493
525
  @double_embedded_doc.image.stub(:remove_previously_stored_files_after_update).and_return(false)
494
526
  @double_embedded_doc.image = stub_file('new.jpeg')
495
- @double_embedded_doc.save.should be_true
496
- File.exists?(public_path('uploads/new.jpeg')).should be_true
497
- File.exists?(public_path('uploads/old.jpeg')).should be_true
527
+ @double_embedded_doc.save.should be_truthy
528
+ File.exists?(public_path('uploads/new.jpeg')).should be_truthy
529
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
498
530
  end
499
531
 
500
532
  it "should not remove file if old file had the same path" do
501
533
  @double_embedded_doc.image = stub_file('old.jpeg')
502
- @double_embedded_doc.save.should be_true
503
- File.exists?(public_path('uploads/old.jpeg')).should be_true
534
+ @double_embedded_doc.save.should be_truthy
535
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
504
536
  end
505
537
 
506
538
  it "should not remove file if validations fail on save" do
507
539
  @double_embedded_doc_class.validate { |r| r.errors.add :textfile, "FAIL!" }
508
540
  @double_embedded_doc.image = stub_file('new.jpeg')
509
- @double_embedded_doc.save.should be_false
510
- File.exists?(public_path('uploads/old.jpeg')).should be_true
541
+ @double_embedded_doc.save.should be_falsey
542
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
511
543
  end
512
544
 
513
545
  end
@@ -527,7 +559,7 @@ describe CarrierWave::Mongoid do
527
559
  @doc = @class.new
528
560
  @embedded_doc = @doc.build_mongo_location
529
561
  @embedded_doc.image = stub_file('old.jpeg')
530
- @embedded_doc.save.should be_true
562
+ @embedded_doc.save.should be_truthy
531
563
  end
532
564
 
533
565
  include_examples "embedded documents"
@@ -549,7 +581,7 @@ describe CarrierWave::Mongoid do
549
581
  @doc = @class.new
550
582
  @embedded_doc = @doc.build_mongo_location
551
583
  @embedded_doc.image = stub_file('old.jpeg')
552
- @embedded_doc.save.should be_true
584
+ @embedded_doc.save.should be_truthy
553
585
  end
554
586
 
555
587
  include_examples "embedded documents"
@@ -571,7 +603,7 @@ describe CarrierWave::Mongoid do
571
603
  @doc = @class.new
572
604
  @embedded_doc = @doc.mongo_locations.build
573
605
  @embedded_doc.image = stub_file('old.jpeg')
574
- @embedded_doc.save.should be_true
606
+ @embedded_doc.save.should be_truthy
575
607
  end
576
608
 
577
609
  include_examples "embedded documents"
@@ -579,11 +611,11 @@ describe CarrierWave::Mongoid do
579
611
  it "attaches a new file to an existing document that had no file at first" do
580
612
  doc = @class.new
581
613
  doc.mongo_locations.build
582
- doc.save.should be_true
614
+ doc.save.should be_truthy
583
615
  doc.reload
584
616
 
585
617
  doc.mongo_locations.first.image = stub_file('test.jpeg')
586
- doc.save.should be_true
618
+ doc.save.should be_truthy
587
619
  doc.reload
588
620
 
589
621
  doc.mongo_locations.first[:image].should == 'test.jpeg'
@@ -617,11 +649,11 @@ describe CarrierWave::Mongoid do
617
649
  @doc = @class.new
618
650
  @embedded_doc = @doc.mongo_locations.build
619
651
  @embedded_doc.image = stub_file('old.jpeg')
620
- @embedded_doc.save.should be_true
652
+ @embedded_doc.save.should be_truthy
621
653
 
622
654
  @double_embedded_doc = @embedded_doc.mongo_items.build
623
655
  @double_embedded_doc.image = stub_file('old.jpeg')
624
- @double_embedded_doc.save.should be_true
656
+ @double_embedded_doc.save.should be_truthy
625
657
  end
626
658
 
627
659
  include_examples "double embedded documents"
@@ -644,7 +676,7 @@ describe CarrierWave::Mongoid do
644
676
  @doc = @class.new
645
677
  @embedded_doc = @doc.mongo_locations.build
646
678
  @embedded_doc.image = stub_file('old.jpeg')
647
- @embedded_doc.save.should be_true
679
+ @embedded_doc.save.should be_truthy
648
680
  end
649
681
 
650
682
  include_examples "embedded documents"
@@ -665,11 +697,11 @@ describe CarrierWave::Mongoid do
665
697
  @doc = @class.new
666
698
  @embedded_doc = @doc.mongo_locations.build
667
699
  @embedded_doc.image = stub_file('old.jpeg')
668
- @embedded_doc.save.should be_true
700
+ @embedded_doc.save.should be_truthy
669
701
 
670
702
  @double_embedded_doc = @embedded_doc.mongo_items.build
671
703
  @double_embedded_doc.image = stub_file('old.jpeg')
672
- @double_embedded_doc.save.should be_true
704
+ @double_embedded_doc.save.should be_truthy
673
705
  end
674
706
 
675
707
  include_examples "double embedded documents"
@@ -690,7 +722,7 @@ describe CarrierWave::Mongoid do
690
722
  end
691
723
 
692
724
  @doc = @class.new(mongo_locations_attributes: [{image: stub_file("old.jpeg")}])
693
- @doc.save.should be_true
725
+ @doc.save.should be_truthy
694
726
  @embedded_doc = @doc.mongo_locations.first
695
727
  end
696
728
 
@@ -701,7 +733,7 @@ describe CarrierWave::Mongoid do
701
733
  end
702
734
 
703
735
  it "should update the image on update_attributes" do
704
- @doc.update_attributes(mongo_locations_attributes: [{id: @embedded_doc.id, image: stub_file("new.jpeg")}]).should be_true
736
+ @doc.update_attributes(mongo_locations_attributes: [{id: @embedded_doc.id, image: stub_file("new.jpeg")}]).should be_truthy
705
737
  @doc.reload
706
738
  @doc.mongo_locations.first.image.path.should match(/new\.jpeg$/)
707
739
  @embedded_doc.image.path.should match(/new\.jpeg$/)
@@ -717,9 +749,9 @@ describe CarrierWave::Mongoid do
717
749
  @class = reset_mongo_class(@uploader)
718
750
  @doc = @class.new
719
751
  @doc.image = stub_file('old.jpeg')
720
- @doc.save.should be_true
721
- File.exists?(public_path('uploads/old.jpeg')).should be_true
722
- File.exists?(public_path('uploads/thumb_old.jpeg')).should be_true
752
+ @doc.save.should be_truthy
753
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
754
+ File.exists?(public_path('uploads/thumb_old.jpeg')).should be_truthy
723
755
  end
724
756
 
725
757
  after do
@@ -728,18 +760,18 @@ describe CarrierWave::Mongoid do
728
760
 
729
761
  it "should remove old file if old file had a different path" do
730
762
  @doc.image = stub_file('new.jpeg')
731
- @doc.save.should be_true
732
- File.exists?(public_path('uploads/new.jpeg')).should be_true
733
- File.exists?(public_path('uploads/thumb_new.jpeg')).should be_true
734
- File.exists?(public_path('uploads/old.jpeg')).should be_false
735
- File.exists?(public_path('uploads/thumb_old.jpeg')).should be_false
763
+ @doc.save.should be_truthy
764
+ File.exists?(public_path('uploads/new.jpeg')).should be_truthy
765
+ File.exists?(public_path('uploads/thumb_new.jpeg')).should be_truthy
766
+ File.exists?(public_path('uploads/old.jpeg')).should be_falsey
767
+ File.exists?(public_path('uploads/thumb_old.jpeg')).should be_falsey
736
768
  end
737
769
 
738
770
  it "should not remove file if old file had the same path" do
739
771
  @doc.image = stub_file('old.jpeg')
740
- @doc.save.should be_true
741
- File.exists?(public_path('uploads/old.jpeg')).should be_true
742
- File.exists?(public_path('uploads/thumb_old.jpeg')).should be_true
772
+ @doc.save.should be_truthy
773
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
774
+ File.exists?(public_path('uploads/thumb_old.jpeg')).should be_truthy
743
775
  end
744
776
  end
745
777
 
@@ -753,9 +785,9 @@ describe CarrierWave::Mongoid do
753
785
  @doc = @class.new
754
786
  @doc.image = stub_file('old.jpeg')
755
787
  @doc.textfile = stub_file('old.txt')
756
- @doc.save.should be_true
757
- File.exists?(public_path('uploads/old.jpeg')).should be_true
758
- File.exists?(public_path('uploads/old.txt')).should be_true
788
+ @doc.save.should be_truthy
789
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
790
+ File.exists?(public_path('uploads/old.txt')).should be_truthy
759
791
  end
760
792
 
761
793
  after do
@@ -765,32 +797,32 @@ describe CarrierWave::Mongoid do
765
797
  it "should remove old file1 and file2 if old file1 and file2 had a different paths" do
766
798
  @doc.image = stub_file('new.jpeg')
767
799
  @doc.textfile = stub_file('new.txt')
768
- @doc.save.should be_true
769
- File.exists?(public_path('uploads/new.jpeg')).should be_true
770
- File.exists?(public_path('uploads/old.jpeg')).should be_false
771
- File.exists?(public_path('uploads/new.txt')).should be_true
772
- File.exists?(public_path('uploads/old.txt')).should be_false
800
+ @doc.save.should be_truthy
801
+ File.exists?(public_path('uploads/new.jpeg')).should be_truthy
802
+ File.exists?(public_path('uploads/old.jpeg')).should be_falsey
803
+ File.exists?(public_path('uploads/new.txt')).should be_truthy
804
+ File.exists?(public_path('uploads/old.txt')).should be_falsey
773
805
  end
774
806
 
775
807
  it "should remove old file1 but not file2 if old file1 had a different path but old file2 has the same path" do
776
808
  @doc.image = stub_file('new.jpeg')
777
809
  @doc.textfile = stub_file('old.txt')
778
- @doc.save.should be_true
779
- File.exists?(public_path('uploads/new.jpeg')).should be_true
780
- File.exists?(public_path('uploads/old.jpeg')).should be_false
781
- File.exists?(public_path('uploads/old.txt')).should be_true
810
+ @doc.save.should be_truthy
811
+ File.exists?(public_path('uploads/new.jpeg')).should be_truthy
812
+ File.exists?(public_path('uploads/old.jpeg')).should be_falsey
813
+ File.exists?(public_path('uploads/old.txt')).should be_truthy
782
814
  end
783
815
 
784
816
  it "should not remove file1 or file2 if file1 and file2 have the same paths" do
785
817
  @doc.image = stub_file('old.jpeg')
786
818
  @doc.textfile = stub_file('old.txt')
787
- @doc.save.should be_true
788
- File.exists?(public_path('uploads/old.jpeg')).should be_true
789
- File.exists?(public_path('uploads/old.txt')).should be_true
819
+ @doc.save.should be_truthy
820
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
821
+ File.exists?(public_path('uploads/old.txt')).should be_truthy
790
822
  end
791
823
  end
792
824
 
793
- describe '#mount_uploader removing old files with with mount_on' do
825
+ describe '#mount_uploader removing old files with mount_on' do
794
826
 
795
827
  before do
796
828
  @class = reset_mongo_class
@@ -798,8 +830,8 @@ describe CarrierWave::Mongoid do
798
830
  @class.mount_uploader(:avatar, @uploader1, :mount_on => :another_image)
799
831
  @doc = @class.new
800
832
  @doc.avatar = stub_file('old.jpeg')
801
- @doc.save.should be_true
802
- File.exists?(public_path('uploads/old.jpeg')).should be_true
833
+ @doc.save.should be_truthy
834
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
803
835
  end
804
836
 
805
837
  after do
@@ -808,15 +840,15 @@ describe CarrierWave::Mongoid do
808
840
 
809
841
  it "should remove old file if old file had a different path" do
810
842
  @doc.avatar = stub_file('new.jpeg')
811
- @doc.save.should be_true
812
- File.exists?(public_path('uploads/new.jpeg')).should be_true
813
- File.exists?(public_path('uploads/old.jpeg')).should be_false
843
+ @doc.save.should be_truthy
844
+ File.exists?(public_path('uploads/new.jpeg')).should be_truthy
845
+ File.exists?(public_path('uploads/old.jpeg')).should be_falsey
814
846
  end
815
847
 
816
848
  it "should not remove file if old file had the same path" do
817
849
  @doc.avatar = stub_file('old.jpeg')
818
- @doc.save.should be_true
819
- File.exists?(public_path('uploads/old.jpeg')).should be_true
850
+ @doc.save.should be_truthy
851
+ File.exists?(public_path('uploads/old.jpeg')).should be_truthy
820
852
  end
821
853
  end
822
854
 
@@ -832,21 +864,21 @@ describe CarrierWave::Mongoid do
832
864
  end
833
865
 
834
866
  @doc = @class.new(image: stub_file("old.jpeg"))
835
- @doc.save.should be_true
867
+ @doc.save.should be_truthy
836
868
  end
837
869
 
838
870
  it "should not remove underlying image after #destroy" do
839
- @doc.destroy.should be_true
871
+ @doc.destroy.should be_truthy
840
872
  @class.count.should eql(0)
841
873
  @class.deleted.count.should eql(1)
842
- File.exist?(public_path('uploads/old.jpeg')).should be_true
874
+ File.exist?(public_path('uploads/old.jpeg')).should be_truthy
843
875
  end
844
876
 
845
877
  it "should remove underlying image after #destroy!" do
846
- @doc.destroy!.should be_true
878
+ @doc.destroy!.should be_truthy
847
879
  @class.count.should eql(0)
848
880
  @class.deleted.count.should eql(0)
849
- File.exist?(public_path('uploads/old.jpeg')).should be_false
881
+ File.exist?(public_path('uploads/old.jpeg')).should be_falsey
850
882
  end
851
883
  end
852
884
  end
@@ -44,6 +44,8 @@ module CarrierWave
44
44
  end
45
45
 
46
46
  module I18nHelpers
47
+ I18n.enforce_available_locales = false if I18n.respond_to? :enforce_available_locales=
48
+
47
49
  def change_locale_and_store_translations(locale, translations, &block)
48
50
  current_locale = I18n.locale
49
51
  begin
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.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-07 00:00:00.000000000 Z
12
+ date: 2015-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: carrierwave
@@ -38,9 +38,9 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.0'
41
- - - "<"
41
+ - - "<="
42
42
  - !ruby/object:Gem::Version
43
- version: '5.0'
43
+ version: '6.0'
44
44
  type: :runtime
45
45
  prerelease: false
46
46
  version_requirements: !ruby/object:Gem::Requirement
@@ -48,9 +48,9 @@ dependencies:
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
50
  version: '3.0'
51
- - - "<"
51
+ - - "<="
52
52
  - !ruby/object:Gem::Version
53
- version: '5.0'
53
+ version: '6.0'
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: mongoid-grid_fs
56
56
  requirement: !ruby/object:Gem::Requirement
@@ -141,12 +141,11 @@ files:
141
141
  - README.md
142
142
  - Rakefile
143
143
  - carrierwave-mongoid.gemspec
144
- - gemfiles/carrierwave-0.8.gemfile
145
144
  - gemfiles/carrierwave-0.9.gemfile
146
145
  - gemfiles/carrierwave-master.gemfile
147
- - gemfiles/mongoid-3.0.gemfile
148
146
  - gemfiles/mongoid-3.1.gemfile
149
147
  - gemfiles/mongoid-4.0.gemfile
148
+ - gemfiles/mongoid-5.0.gemfile
150
149
  - lib/carrierwave/mongoid.rb
151
150
  - lib/carrierwave/mongoid/version.rb
152
151
  - lib/carrierwave/storage/grid_fs.rb
@@ -181,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
180
  version: '0'
182
181
  requirements: []
183
182
  rubyforge_project: carrierwave-mongoid
184
- rubygems_version: 2.2.2
183
+ rubygems_version: 2.4.8
185
184
  signing_key:
186
185
  specification_version: 4
187
186
  summary: Mongoid support for CarrierWave
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "mongoid", github: "mongoid/mongoid", branch: "3.0.0-stable"
4
- gem "activemodel", "~> 3.2"
5
-
6
- gemspec path: "../"