Skip to content

Commit 95a25a7

Browse files
authored
Merge pull request #4427 from estolfo/MONGOID-4440-rails-5-1
MONGOID-4440 Support Rails 5.1
2 parents 19d51f9 + 26e6368 commit 95a25a7

File tree

6 files changed

+28
-16
lines changed

6 files changed

+28
-16
lines changed

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ source 'https://rubygems.org'
22
gemspec
33

44
gem 'rake'
5-
gem 'actionpack', '~> 5.0.0'
6-
gem 'activemodel', '~> 5.0.0'
5+
gem 'actionpack', '~> 5.1'
6+
gem 'activemodel', '~> 5.1'
77

88

99
group :test do

gemfiles/driver_master.gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ gem 'bson', github: "mongodb/bson-ruby"
55
gem 'mongo', github: "mongodb/mongo-ruby-driver"
66

77
gem 'rake'
8-
gem 'actionpack', '~> 5.0.0'
9-
gem 'activemodel', '~> 5.0.0'
8+
gem 'actionpack', '~> 5.1'
9+
gem 'activemodel', '~> 5.1'
1010

1111
group :test do
1212
gem 'rspec', '~> 3.4.0'

lib/mongoid/interceptable.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,12 @@ def run_targeted_callbacks(place, kind)
254254
chain.append(callback) if callback.kind == place
255255
end
256256
self.class.send :define_method, name do
257-
runner = ActiveSupport::Callbacks::Filters::Environment.new(self, false, nil)
258-
chain.compile.call(runner).value
257+
env = ActiveSupport::Callbacks::Filters::Environment.new(self, false, nil)
258+
sequence = chain.compile
259+
sequence.invoke_before(env)
260+
env.value = !env.halted
261+
sequence.invoke_after(env)
262+
env.value
259263
end
260264
self.class.send :protected, name
261265
end

lib/mongoid/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# encoding: utf-8
22
module Mongoid
3-
VERSION = "6.1.1"
3+
VERSION = "6.2.0"
44
end

mongoid.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
2626
s.required_rubygems_version = ">= 1.3.6"
2727
s.rubyforge_project = "mongoid"
2828

29-
s.add_dependency("activemodel", ["~> 5.0"])
29+
s.add_dependency("activemodel", ["~> 5.1"])
3030
s.add_dependency("mongo", ['>=2.4.1', '<3.0.0'])
3131

3232
s.files = Dir.glob("lib/**/*") + %w(CHANGELOG.md LICENSE README.md Rakefile)

spec/mongoid/interceptable_spec.rb

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -484,32 +484,40 @@ class TestClass
484484

485485
context "when the child does not have the same callback defined" do
486486

487-
let(:band) do
488-
Band.new
487+
let(:exhibition) do
488+
Exhibition.new
489489
end
490490

491-
let!(:record) do
492-
band.records.build
491+
let!(:exhibitor) do
492+
exhibition.exhibitors.build
493493
end
494494

495495
context "when running the callbacks directly" do
496496

497497
before(:all) do
498-
Band.define_model_callbacks(:rearrange)
499-
Band.after_rearrange { }
498+
Exhibition.define_model_callbacks(:rearrange)
499+
Exhibition.after_rearrange { }
500500
end
501501

502502
after(:all) do
503-
Band.reset_callbacks(:rearrange)
503+
Exhibition.reset_callbacks(:rearrange)
504504
end
505505

506506
it "does not cascade to the child" do
507-
expect(band.run_callbacks(:rearrange)).to be true
507+
expect(exhibition.run_callbacks(:rearrange)).to be true
508508
end
509509
end
510510

511511
context "when the callbacks get triggered by a destroy" do
512512

513+
let(:band) do
514+
Band.new
515+
end
516+
517+
let!(:record) do
518+
band.records.build
519+
end
520+
513521
before(:all) do
514522
Band.define_model_callbacks(:rearrange)
515523
Band.set_callback(:validation, :before) do

0 commit comments

Comments
 (0)