diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..482aaa7 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: Tests +on: [push, pull_request] +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true +jobs: + test: + strategy: + fail-fast: false + matrix: + gemfile: ["mongoid_5", "mongoid_6", "mongoid_7_0", "mongoid_7_1", "mongoid_7_2", "mongoid_7_3", "mongoid_7_4", "mongoid_8", "mongoid_9", "rails_5", "rails_6_0", "rails_6_1", "rails_7"] + ruby: ["3.1", "3.2", "3.3"] + runs-on: ubuntu-latest + services: + mongodb: + image: mongo + ports: ["27017:27017"] + env: + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile + steps: + - uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - run: bundle exec rake diff --git a/.gitignore b/.gitignore index 0cb6eeb..095afd3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ /pkg/ /spec/reports/ /tmp/ + +/gemfiles/*.gemfile.lock diff --git a/.ruby-version b/.ruby-version index e70b452..a0891f5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.0 +3.3.4 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ff3db17..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: ruby -script: 'bundle exec rake' -sudo: false -rvm: - - 2.2.5 -services: - - mongodb - -notifications: - email: - recipients: - - joost@spacebabies.nl - - tomas.celizna@gmail.com - on_failure: change - on_success: never - -matrix: - include: - - rvm: 2.3.3 - env: MONGOID_VERSION=5 - - rvm: 2.3.3 - env: MONGOID_VERSION=6 - - rvm: 2.5.0 - env: MONGOID_VERSION=7 diff --git a/Appraisals b/Appraisals new file mode 100644 index 0000000..0e5657f --- /dev/null +++ b/Appraisals @@ -0,0 +1,55 @@ +appraise "mongoid-5" do + gem "mongoid", "5.4.1" + gem "bigdecimal", "1.4.2" +end + +appraise "mongoid-6" do + gem "mongoid", "6.4.8" +end + +appraise "mongoid-7-0" do + gem "mongoid", "7.0.13" +end + +appraise "mongoid-7-1" do + gem "mongoid", "7.1.11" +end + +appraise "mongoid-7-2" do + gem "mongoid", "7.2.6" +end + +appraise "mongoid-7-3" do + gem "mongoid", "7.3.4" +end + +appraise "mongoid-7-4" do + gem "mongoid", "7.4.0" +end + +appraise "mongoid-8" do + gem "mongoid", "~> 8.0" +end + +appraise "mongoid-9" do + gem "mongoid", "~> 9.0" +end + +appraise "rails-5" do + gem "rails", "~> 5.0" + gem "mongoid", "~> 7.0" +end + +appraise "rails-6-0" do + gem "rails", "~> 6.0.0" + gem "mongoid", "~> 7.0" +end + +appraise "rails-6-1" do + gem "rails", "~> 6.1.0" + gem "mongoid", "~> 7.0" +end + +appraise "rails-7" do + gem "rails", "~> 7.0" +end diff --git a/CHANGELOG.md b/CHANGELOG.md index 26de261..bed6127 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Next + +* Mongoid 8 support + # 1.7.1 * FIX: BSON 4+ returns BSON::Document instead of Hash, [#15](https://github.com/Sign2Pay/mongoid-archivable/pull/15) diff --git a/Gemfile b/Gemfile index 40f8b85..89dd83f 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,9 @@ source 'https://rubygems.org' # Specify your gem's dependencies in mongoid-archivable.gemspec gemspec -case version = ENV['MONGOID_VERSION'] || '~> 7.0' +case version = ENV['MONGOID_VERSION'] || '~> 9.0' +when /9/ then gem 'mongoid', '~> 9.0' +when /8/ then gem 'mongoid', '~> 8.0' when /7/ then gem 'mongoid', '~> 7.0' when /6/ then gem 'mongoid', '~> 6.0' when /5/ then gem 'mongoid', '~> 5.1' diff --git a/README.md b/README.md index f7ef1bb..cef8165 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mongoid::Archivable -[![Build Status](https://travis-ci.org/Sign2Pay/mongoid-archivable.svg)](https://travis-ci.org/Sign2Pay/mongoid-archivable) [![Gem Version](https://badge.fury.io/rb/mongoid-archivable.svg)](http://badge.fury.io/rb/mongoid-archivable) +[![Tests](https://github.com/asgerb/mongoid-archivable/actions/workflows/test.yml/badge.svg)](https://github.com/asgerb/mongoid-archivable/actions/workflows/test.yml) [![Gem Version](https://badge.fury.io/rb/mongoid-archivable.svg)](http://badge.fury.io/rb/mongoid-archivable) Moves Mongoid documents to an archive instead of destroying them. @@ -91,7 +91,6 @@ development: <<: *client_options ``` - ## Development Please report any issues to the [GitHub issue tracker](https://github.com/Sign2Pay/mongoid-archivable/issues). diff --git a/gemfiles/.bundle/config b/gemfiles/.bundle/config new file mode 100644 index 0000000..c127f80 --- /dev/null +++ b/gemfiles/.bundle/config @@ -0,0 +1,2 @@ +--- +BUNDLE_RETRY: "1" diff --git a/gemfiles/mongoid_5.gemfile b/gemfiles/mongoid_5.gemfile new file mode 100644 index 0000000..6bb78cc --- /dev/null +++ b/gemfiles/mongoid_5.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mongoid", "5.4.1" +gem "bigdecimal", "1.4.2" + +gemspec path: "../" diff --git a/gemfiles/mongoid_6.gemfile b/gemfiles/mongoid_6.gemfile new file mode 100644 index 0000000..eeaf5fc --- /dev/null +++ b/gemfiles/mongoid_6.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mongoid", "6.4.8" + +gemspec path: "../" diff --git a/gemfiles/mongoid_7_0.gemfile b/gemfiles/mongoid_7_0.gemfile new file mode 100644 index 0000000..4d6ccef --- /dev/null +++ b/gemfiles/mongoid_7_0.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mongoid", "7.0.13" + +gemspec path: "../" diff --git a/gemfiles/mongoid_7_1.gemfile b/gemfiles/mongoid_7_1.gemfile new file mode 100644 index 0000000..0ea830b --- /dev/null +++ b/gemfiles/mongoid_7_1.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mongoid", "7.1.11" + +gemspec path: "../" diff --git a/gemfiles/mongoid_7_2.gemfile b/gemfiles/mongoid_7_2.gemfile new file mode 100644 index 0000000..cc70833 --- /dev/null +++ b/gemfiles/mongoid_7_2.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mongoid", "7.2.6" + +gemspec path: "../" diff --git a/gemfiles/mongoid_7_3.gemfile b/gemfiles/mongoid_7_3.gemfile new file mode 100644 index 0000000..2e84f6e --- /dev/null +++ b/gemfiles/mongoid_7_3.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mongoid", "7.3.4" + +gemspec path: "../" diff --git a/gemfiles/mongoid_7_4.gemfile b/gemfiles/mongoid_7_4.gemfile new file mode 100644 index 0000000..2eba2af --- /dev/null +++ b/gemfiles/mongoid_7_4.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mongoid", "7.4.0" + +gemspec path: "../" diff --git a/gemfiles/mongoid_8.gemfile b/gemfiles/mongoid_8.gemfile new file mode 100644 index 0000000..24e0e00 --- /dev/null +++ b/gemfiles/mongoid_8.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mongoid", "~> 8.0" + +gemspec path: "../" diff --git a/gemfiles/mongoid_9.gemfile b/gemfiles/mongoid_9.gemfile new file mode 100644 index 0000000..3ac8ba3 --- /dev/null +++ b/gemfiles/mongoid_9.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mongoid", "~> 9.0" + +gemspec path: "../" diff --git a/gemfiles/rails_5.gemfile b/gemfiles/rails_5.gemfile new file mode 100644 index 0000000..039c297 --- /dev/null +++ b/gemfiles/rails_5.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mongoid", "~> 7.0" +gem "rails", "~> 5.0" + +gemspec path: "../" diff --git a/gemfiles/rails_6_0.gemfile b/gemfiles/rails_6_0.gemfile new file mode 100644 index 0000000..b361f87 --- /dev/null +++ b/gemfiles/rails_6_0.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mongoid", "~> 7.0" +gem "rails", "~> 6.0.0" + +gemspec path: "../" diff --git a/gemfiles/rails_6_1.gemfile b/gemfiles/rails_6_1.gemfile new file mode 100644 index 0000000..c58acef --- /dev/null +++ b/gemfiles/rails_6_1.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mongoid", "~> 7.0" +gem "rails", "~> 6.1.0" + +gemspec path: "../" diff --git a/gemfiles/rails_7.gemfile b/gemfiles/rails_7.gemfile new file mode 100644 index 0000000..95f65ba --- /dev/null +++ b/gemfiles/rails_7.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mongoid", "~> 9.0" +gem "rails", "~> 7.0" + +gemspec path: "../" diff --git a/lib/mongoid/archivable.rb b/lib/mongoid/archivable.rb index 9064fcf..c09a332 100644 --- a/lib/mongoid/archivable.rb +++ b/lib/mongoid/archivable.rb @@ -21,7 +21,7 @@ def configure(&proc) end included do - mattr_accessor :archive_storage + class_attribute :archive_storage include Mongoid::Archivable::Gluten const_set('Archive', Class.new) @@ -35,7 +35,7 @@ def configure(&proc) field :archived_at, type: Time field :original_id, type: String field :original_type, type: String - + end before_destroy :archive diff --git a/lib/mongoid/archivable/config.rb b/lib/mongoid/archivable/config.rb index e64abff..7cdac97 100644 --- a/lib/mongoid/archivable/config.rb +++ b/lib/mongoid/archivable/config.rb @@ -13,4 +13,4 @@ def get_client end end end -end \ No newline at end of file +end diff --git a/lib/mongoid/archivable/depot.rb b/lib/mongoid/archivable/depot.rb index bc3906c..942802f 100644 --- a/lib/mongoid/archivable/depot.rb +++ b/lib/mongoid/archivable/depot.rb @@ -2,26 +2,27 @@ module Mongoid module Archivable module Depot extend ActiveSupport::Concern + included do include ClassMethods end module ClassMethods def has_archive_storage? - !parent.archive_storage.nil? + !parent_class.archive_storage.nil? end def has_archive_client? - has_archive_storage? && !parent.archive_storage[:client].nil? + has_archive_storage? && !parent_class.archive_storage[:client].nil? end def has_archive_database? - has_archive_storage? && !parent.archive_storage[:client].nil? + has_archive_storage? && !parent_class.archive_storage[:client].nil? end def archive_database_name if has_archive_database? - parent.archive_storage[:database] + parent_class.archive_storage[:database] else Mongoid::Archivable.config.get_database end @@ -29,12 +30,22 @@ def archive_database_name def archive_client_name if has_archive_client? - parent.archive_storage[:client] + parent_class.archive_storage[:client] else Mongoid::Archivable.config.get_client end end + + private + + def parent_class + if ActiveSupport::VERSION::MAJOR >= 6 + module_parent + else + parent + end + end end end end -end \ No newline at end of file +end diff --git a/mongoid-archivable.gemspec b/mongoid-archivable.gemspec index 4eff57d..f231472 100644 --- a/mongoid-archivable.gemspec +++ b/mongoid-archivable.gemspec @@ -22,6 +22,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'mongoid', '>= 5.0' spec.add_dependency 'activesupport', '>= 4.0.0' + spec.add_development_dependency 'appraisal' spec.add_development_dependency 'bundler' spec.add_development_dependency 'rake' spec.add_development_dependency 'rspec'