diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 86d8459aa5..05e4419841 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -552,6 +552,10 @@ axes: display_name: "Rails 5.2" variables: RAILS: "52" + - id: "60" + display_name: "Rails 6.0" + variables: + RAILS: "60" - id: "i18n" display_name: I18n version values: @@ -767,6 +771,18 @@ buildvariants: - rhel70-small tasks: - name: "test" +- matrix_name: "rails-60" + matrix_spec: + driver: "current" + ruby: "ruby-2.7" + mongodb-version: "4.4" + topology: "standalone" + rails: '60' + display_name: "${rails}, ${driver}, ${mongodb-version}" + run_on: + - rhel70-small + tasks: + - name: "test" #- matrix_name: "rails-master" # matrix_spec: { driver: "current", ruby: "ruby-2.6", mongodb-version: "4.0", topology: "standalone", rails: 'master' } # display_name: "${rails}, ${driver}, ${mongodb-version}" diff --git a/docs/tutorials/mongoid-installation.txt b/docs/tutorials/mongoid-installation.txt index 4c206ffa64..053d624337 100644 --- a/docs/tutorials/mongoid-installation.txt +++ b/docs/tutorials/mongoid-installation.txt @@ -227,13 +227,23 @@ are supported by Mongoid. :class: compatibility-large no-padding * - Mongoid + - Rails 6.1 - Rails 6.0 - Rails 5.2 - Rails 5.1 - Rails 5.0 - Rails 4.2 + * - 7.3 + - |checkmark| + - |checkmark| + - |checkmark| + - |checkmark| + - + - + * - 7.2 + - |checkmark| [#rails-6.1]_ - |checkmark| - |checkmark| - |checkmark| @@ -241,6 +251,7 @@ are supported by Mongoid. - * - 7.1 + - |checkmark| [#rails-6.1]_ - |checkmark| - |checkmark| - |checkmark| @@ -248,6 +259,7 @@ are supported by Mongoid. - * - 7.0 + - |checkmark| [#rails-6.1]_ - |checkmark| [#rails-6]_ - |checkmark| - |checkmark| @@ -255,6 +267,7 @@ are supported by Mongoid. - * - 6.4 + - - - |checkmark| - |checkmark| @@ -262,6 +275,7 @@ are supported by Mongoid. - * - 6.3 + - - - |checkmark| - |checkmark| @@ -269,6 +283,7 @@ are supported by Mongoid. - * - 6.2 + - - - |checkmark| - |checkmark| @@ -305,4 +320,7 @@ are supported by Mongoid. .. [#rails-6] Rails 6.0 requires Mongoid 7.0.5 or later. +.. [#rails-6.1] Rails 6.1 requires Mongoid 7.0.12, 7.1.7 or 7.2.1 in the + respective 7.0, 7.1 and 7.2 stable branches. + .. include:: /includes/unicode-checkmark.rst diff --git a/gemfiles/rails_60.gemfile b/gemfiles/rails_60.gemfile new file mode 100644 index 0000000000..efa6c23cd6 --- /dev/null +++ b/gemfiles/rails_60.gemfile @@ -0,0 +1,30 @@ +source 'https://rubygems.org' + +gem 'rake' +gem 'actionpack', '~> 6.0.0' +gem 'activemodel', '~> 6.0.0' + +group :development do + gem 'yard' +end + +group :development, :test do + gem 'rspec-core', '~> 3.7' +end + +group :test do + gem 'timecop' + gem 'rspec-retry' + gem 'benchmark-ips' + gem 'rspec-expectations', '~> 3.7', '>= 3.8.4' + gem 'rspec-mocks-diag', '~> 3.0' + gem 'fuubar' + gem 'rfc' + gem 'childprocess' + platforms :mri do + gem 'timeout-interrupt' + gem 'byebug' + end +end + +gemspec path: '..' diff --git a/lib/mongoid/document.rb b/lib/mongoid/document.rb index e02af6b102..fa8cdfb42e 100644 --- a/lib/mongoid/document.rb +++ b/lib/mongoid/document.rb @@ -229,8 +229,9 @@ def becomes(klass) became = klass.new(clone_document) became._id = _id became.instance_variable_set(:@changed_attributes, changed_attributes) - became.instance_variable_set(:@errors, ActiveModel::Errors.new(became)) - became.errors.instance_variable_set(:@messages, errors.instance_variable_get(:@messages)) + new_errors = ActiveModel::Errors.new(became) + new_errors.copy!(errors) + became.instance_variable_set(:@errors, new_errors) became.instance_variable_set(:@new_record, new_record?) became.instance_variable_set(:@destroyed, destroyed?) became.changed_attributes[klass.discriminator_key] = self.class.discriminator_value diff --git a/lib/mongoid/interceptable.rb b/lib/mongoid/interceptable.rb index b61b52e32b..79a6c8e3de 100644 --- a/lib/mongoid/interceptable.rb +++ b/lib/mongoid/interceptable.rb @@ -234,9 +234,11 @@ def child_callback_type(kind, child) # document.halted_callback_hook(filter) # # @param [ Symbol ] filter The callback that halted. + # @param [ Symbol ] name The name of the callback that was halted + # (requires Rails 6.1+) # # @since 3.0.3 - def halted_callback_hook(filter) + def halted_callback_hook(filter, name = nil) @before_callback_halted = true end diff --git a/mongoid.gemspec b/mongoid.gemspec index 93b58c7234..489afb44b6 100644 --- a/mongoid.gemspec +++ b/mongoid.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 2.3" s.required_rubygems_version = ">= 1.3.6" - s.add_dependency("activemodel", [">= 5.1", "<6.1"]) + s.add_dependency("activemodel", [">= 5.1", "<6.2"]) s.add_dependency("mongo", ['>=2.10.5', '<3.0.0']) s.add_development_dependency("bson", ['>=4.9.4', '<5.0.0']) diff --git a/spec/integration/app_spec.rb b/spec/integration/app_spec.rb index 1e7fc8236d..4d2f9c8944 100644 --- a/spec/integration/app_spec.rb +++ b/spec/integration/app_spec.rb @@ -150,7 +150,7 @@ end index.should be nil - Mrss::ChildProcessHelper.check_call(%w(rake db:mongoid:create_indexes), + Mrss::ChildProcessHelper.check_call(%w(bundle exec rake db:mongoid:create_indexes), cwd: APP_PATH, env: env) index = client['posts'].indexes.detect do |index|