Skip to content

Commit 711d9ac

Browse files
committed
Add support for Mongoid 7, 8, and 9
1 parent edb7cb1 commit 711d9ac

9 files changed

Lines changed: 26 additions & 13 deletions

File tree

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
- { ruby: '2.7', mongoid: '4' }
2323
- { ruby: '2.7', mongoid: '5' }
2424
- { ruby: '3.3', mongoid: '6' }
25+
- { ruby: '2.7', mongoid: '7' }
26+
- { ruby: '3.2', mongoid: '8' }
27+
- { ruby: '3.3', mongoid: '9' }
2528

2629
name: test (ruby=${{ matrix.entry.ruby }}, mongoid=${{ matrix.entry.mongoid }})
2730

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
### 0.4.7 (Next)
1+
### 0.5.0 (Next)
22

33
* Your contribution here.
4+
* [#2](https://github.com/dblock/mongoid-shell/pull/2): Added compatibility with Mongoid 7, 8, 9 - [@dblock](https://github.com/dblock).
45
* Migrated CI from Travis CI to GitHub Actions - [@dblock](https://github.com/dblock).
56

67
### 0.4.6 (12/29/2017)

Gemfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@ source 'http://rubygems.org'
44

55
gemspec
66

7-
case version = ENV['MONGOID_VERSION'] || '6.0'
7+
case version = ENV['MONGOID_VERSION'] || '9.0'
8+
when /^9/
9+
gem 'bigdecimal'
10+
gem 'mongoid', '~> 9.0'
11+
when /^8/
12+
gem 'bigdecimal'
13+
gem 'mongoid', '~> 8.0'
14+
when /^7/
15+
gem 'bigdecimal'
16+
gem 'mongoid', '~> 7.0'
817
when /^6/
918
gem 'bigdecimal'
1019
gem 'mongoid', '~> 6.0'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ To use output in logs, pass the `mask_sensitive` option to `to_s`.
5656
Compatibility
5757
-------------
5858

59-
This gem supports Mongoid 3, 4, 5 and 6.
59+
This gem supports Mongoid 3, 4, 5, 6, 7, 8 and 9.
6060

6161
Supported Commands
6262
------------------

lib/mongoid/shell/commands/base.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ def to_s(options = {})
7878

7979
private
8080

81-
if ::Mongoid::Compatibility::Version.mongoid3? || ::Mongoid::Compatibility::Version.mongoid4?
81+
if ::Mongoid::Compatibility::Version.mongoid5_or_newer?
8282
def default_client_or_session
83-
Mongoid.default_session
83+
Mongoid.default_client
8484
end
8585
else
8686
def default_client_or_session
87-
Mongoid.default_client
87+
Mongoid.default_session
8888
end
8989
end
9090
end

lib/mongoid/shell/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Mongoid
44
module Shell
5-
VERSION = '0.4.7'
5+
VERSION = '0.5.0'
66
end
77
end

spec/mongoid/commands/base_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
context 'without a default session' do
99
before do
10-
default_function = Mongoid::Compatibility::Version.mongoid3? || Mongoid::Compatibility::Version.mongoid4? ? :default_session : :default_client
10+
default_function = Mongoid::Compatibility::Version.mongoid5_or_newer? ? :default_client : :default_session
1111
allow(Mongoid).to receive(default_function).and_return(nil)
1212
end
1313

@@ -24,7 +24,7 @@
2424
end
2525
end
2626

27-
if Mongoid::Compatibility::Version.mongoid5? || Mongoid::Compatibility::Version.mongoid6?
27+
if Mongoid::Compatibility::Version.mongoid5_or_newer?
2828
it 'creates a command using the default session' do
2929
command = Mongoid::Shell::Commands::Base.new
3030
expect(command.session).to eq Mongoid.default_client

spec/mongoid/properties/host_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def session
1616
end
1717

1818
it 'raises an exception when the session is not connected' do
19-
if Mongoid::Compatibility::Version.mongoid5? || Mongoid::Compatibility::Version.mongoid6?
19+
if Mongoid::Compatibility::Version.mongoid5_or_newer?
2020
allow(Mongoid.default_client.cluster).to receive(:servers).and_return([])
2121
else
2222
allow(Mongoid.default_session.cluster).to receive(:nodes).and_return([])
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# frozen_string_literal: true
22

33
module MongoidSessionHelper
4-
if ::Mongoid::Compatibility::Version.mongoid3? || ::Mongoid::Compatibility::Version.mongoid4?
4+
if ::Mongoid::Compatibility::Version.mongoid5_or_newer?
55
def default_client_or_session
6-
Mongoid.default_session
6+
Mongoid.default_client
77
end
88
else
99
def default_client_or_session
10-
Mongoid.default_client
10+
Mongoid.default_session
1111
end
1212
end
1313
end

0 commit comments

Comments
 (0)