Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## Changelog

### 2.1.1 (Next)
### 2.2.0 (Next)

* Your contribution here.
Comment thread
dblock marked this conversation as resolved.
* [#107](https://github.com/mongoid/mongoid-locker/pull/107): Revert introduction of `forwardable` to ensure compatibility with mongoid-history - [@scpike](https://github.com/scpike).

### 2.1.0 (2024-05-07)

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ group :development, :test do

gem 'mongoid-compatibility'
gem 'mongoid-danger', '~> 0.2.0'
gem 'mongoid-history'
gem 'rspec', '~> 3.9'
gem 'rubocop', '0.81.0'
gem 'rubocop-rspec', '1.38.1'
Expand Down
5 changes: 1 addition & 4 deletions lib/mongoid/locker.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require 'forwardable'
require 'securerandom'

module Mongoid
Expand Down Expand Up @@ -104,8 +103,6 @@ def reset!

# @api private
def included(klass)
klass.extend(Forwardable) unless klass.ancestors.include?(Forwardable)

klass.extend ClassMethods
klass.singleton_class.instance_eval { attr_accessor(*MODULE_METHODS) }

Expand All @@ -117,7 +114,7 @@ def included(klass)
klass.backoff_algorithm = backoff_algorithm
klass.locking_name_generator = locking_name_generator

klass.def_delegators(klass, *MODULE_METHODS)
klass.delegate(*MODULE_METHODS, to: :class)
klass.singleton_class.delegate(*(methods(false) - MODULE_METHODS.flat_map { |method| [method, "#{method}=".to_sym] } - %i[included reset! configure]), to: self)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mongoid/locker/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Mongoid
module Locker
VERSION = '2.1.1'
VERSION = '2.2.0'
end
end
24 changes: 24 additions & 0 deletions spec/integration/mongoid-history/mongoid_history_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

require 'mongoid-history'

# This replicates the exception reported at https://github.com/mongoid/mongoid-history/issues/238#issuecomment-1063155193
# when mongoid-locker required 'forwardable' instead of relying on the
# active support-provided delegation method
RSpec.describe 'MongoidHistory' do # rubocop:disable RSpec/DescribeClass
# rubocop:disable RSpec/ExampleLength
it 'does not raise an exception' do
expect do
Class.new do
include Mongoid::Document
include Mongoid::Locker
include Mongoid::History::Trackable

field :title

track_history on: [:title]
end
end.not_to raise_exception
end
# rubocop:enable RSpec/ExampleLength
end
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

ENV['RACK_ENV'] = 'test'

require 'logger' # Required for compatibility with activesupport 7

if ENV['COVERAGE']
require 'simplecov'
require 'simplecov_json_formatter'
Expand Down
Loading