From c497a0d815deacf2a9b17362d26da69e0a451472 Mon Sep 17 00:00:00 2001 From: Carl Eqladios Date: Fri, 27 Sep 2024 17:42:04 +0300 Subject: [PATCH 1/6] support mongoid 9 --- .github/workflows/ci.yml | 1 + carrierwave-mongoid.gemspec | 2 +- gemfiles/mongoid-9.gemfile | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 gemfiles/mongoid-9.gemfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 008398d..4cca428 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,7 @@ jobs: - carrierwave-2.2 - mongoid-7 - mongoid-8 + - mongoid-9 include: - { mongodb: "4.4", ruby: "2.6", gemfile: "carrierwave-0.10" } - { mongodb: "4.4", ruby: "2.6", gemfile: "carrierwave-0.11" } diff --git a/carrierwave-mongoid.gemspec b/carrierwave-mongoid.gemspec index 998abf2..d923ec9 100644 --- a/carrierwave-mongoid.gemspec +++ b/carrierwave-mongoid.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.add_dependency "carrierwave", [">= 0.8", "< 3"] - s.add_dependency "mongoid", [">= 3.0", "< 9.0"] + s.add_dependency "mongoid", [">= 3.0", "< 10.0"] s.add_dependency "mongoid-grid_fs", [">= 1.3", "< 3.0"] s.add_dependency "mime-types", "< 3" if RUBY_VERSION < "2.0" # mime-types 3+ doesn't support ruby 1.9 s.add_development_dependency "rspec", "~> 3.4" diff --git a/gemfiles/mongoid-9.gemfile b/gemfiles/mongoid-9.gemfile new file mode 100644 index 0000000..b7549b1 --- /dev/null +++ b/gemfiles/mongoid-9.gemfile @@ -0,0 +1,6 @@ +source "https://rubygems.org" + +gem "mongoid", "~> 9.0" +gem "carrierwave", "~> 2.2" + +gemspec path: "../" From 0168df87010777de0dc451f18ccdd1c9ca389a89 Mon Sep 17 00:00:00 2001 From: Carl Eqladios Date: Fri, 27 Sep 2024 17:42:38 +0300 Subject: [PATCH 2/6] add ruby 3.3 to build matrix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cca428..875de73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ jobs: strategy: matrix: mongodb: [4.4] - ruby: [2.7, "3.0", 3.1, 3.2] + ruby: [2.7, "3.0", 3.1, 3.2, 3.3] gemfile: - carrierwave-2.1 - carrierwave-2.2 From 116e521afd5751f4a68255edcc091cfa8ed6e03b Mon Sep 17 00:00:00 2001 From: Carl Eqladios Date: Fri, 27 Sep 2024 18:25:31 +0300 Subject: [PATCH 3/6] require dev dependency mini_magick < 5 - mini_magick > 4 fails with carrierwave with calls to imagemagick `run_command` --- carrierwave-mongoid.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/carrierwave-mongoid.gemspec b/carrierwave-mongoid.gemspec index d923ec9..e761198 100644 --- a/carrierwave-mongoid.gemspec +++ b/carrierwave-mongoid.gemspec @@ -26,6 +26,6 @@ Gem::Specification.new do |s| s.add_dependency "mime-types", "< 3" if RUBY_VERSION < "2.0" # mime-types 3+ doesn't support ruby 1.9 s.add_development_dependency "rspec", "~> 3.4" s.add_development_dependency "rake", ">= 12.3.3" - s.add_development_dependency "mini_magick" + s.add_development_dependency "mini_magick", "< 5" s.add_development_dependency "pry" end From 5dc4c33eea59d87d9bde831fc49708052d1899f4 Mon Sep 17 00:00:00 2001 From: Carl Eqladios Date: Fri, 27 Sep 2024 19:42:33 +0300 Subject: [PATCH 4/6] update ci workflow checkout action - this was producing a warning about using node 12 which deprecated https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/ --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 875de73..1f41e74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: uses: supercharge/mongodb-github-action@1.3.0 with: mongodb-version: ${{ matrix.mongodb }} - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: From e74a4b5ecc5b027e4d920fc4041e526f0b3baee6 Mon Sep 17 00:00:00 2001 From: Carl Eqladios Date: Fri, 27 Sep 2024 19:44:09 +0300 Subject: [PATCH 5/6] log out error using ruby version defined in the running matrix --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f41e74..ac7e4a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,9 +38,9 @@ jobs: with: ruby-version: ${{ matrix.ruby }} bundler-cache: true - - run: cat /home/runner/work/carrierwave-mongoid/carrierwave-mongoid/vendor/bundle/ruby/3.0.0/extensions/x86_64-linux/3.0.0/mimemagic-0.4.3/gem_make.out + - run: cat /home/runner/work/carrierwave-mongoid/carrierwave-mongoid/vendor/bundle/ruby/${{ matrix.ruby }}/extensions/x86_64-linux/${{ matrix.ruby }}/mimemagic-0.4.3/gem_make.out if: ${{ failure() }} - - run: cat /home/runner/work/carrierwave-mongoid/carrierwave-mongoid/vendor/bundle/ruby/3.0.0/gems/mimemagic-0.4.3/ext/mimemagic/Rakefile + - run: cat /home/runner/work/carrierwave-mongoid/carrierwave-mongoid/vendor/bundle/ruby/${{ matrix.ruby }}/gems/mimemagic-0.4.3/ext/mimemagic/Rakefile if: ${{ failure() }} - name: Run tests run: bundle exec rake From ccb44b55ccd8d1ad7bd12d0e45722436fe77e2a8 Mon Sep 17 00:00:00 2001 From: Carl Eqladios Date: Fri, 22 Nov 2024 19:20:24 +0200 Subject: [PATCH 6/6] save embedded document before parent document Passed the test by ensuring that the embedded `mongo_location` document is saved first before saving and checking the parent document. --- spec/mongoid_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/mongoid_spec.rb b/spec/mongoid_spec.rb index 4de3289..34a5d37 100644 --- a/spec/mongoid_spec.rb +++ b/spec/mongoid_spec.rb @@ -623,11 +623,13 @@ def filename it "attaches a new file to an existing document that had no file at first" do doc = @class.new - doc.mongo_locations.build + new_file = doc.mongo_locations.build + expect(new_file.save).to be_truthy expect(doc.save).to be_truthy doc.reload - doc.mongo_locations.first.image = stub_file('test.jpeg') + new_file.image = stub_file('test.jpeg') + expect(new_file.save).to be_truthy expect(doc.save).to be_truthy doc.reload