Support Mongoid 5.

This commit is contained in:
Josef Šimánek 2016-01-06 21:30:08 +01:00
parent b65c97e49e
commit 9e5faf4ab9
6 changed files with 33 additions and 10 deletions

View File

@ -12,12 +12,14 @@ rvm:
- 1.9
env:
- RAILS=4-2-stable DB=mongodb
- RAILS=4-2-stable DB=mongoid4
- RAILS=4-2-stable DB=mongoid5
- RAILS=4-2-stable DB=sqlite3
- RAILS=4-2-stable DB=mysql
- RAILS=4-2-stable DB=postgres
- RAILS=4-1-stable DB=mongodb
- RAILS=4-1-stable DB=mongoid4
- RAILS=4-1-stable DB=mongoid5
- RAILS=4-1-stable DB=sqlite3
- RAILS=4-1-stable DB=mysql
- RAILS=4-1-stable DB=postgres
@ -37,7 +39,9 @@ env:
matrix:
include:
- rvm: 2.3.0
env: RAILS=master DB=mongodb
env: RAILS=master DB=mongoid5
- rvm: 2.3.0
env: RAILS=master DB=mongoid4
- rvm: 2.3.0
env: RAILS=master DB=sqlite3
- rvm: 2.3.0
@ -46,7 +50,9 @@ matrix:
env: RAILS=master DB=postgres
- rvm: 2.2.4
env: RAILS=master DB=mongodb
env: RAILS=master DB=mongoid5
- rvm: 2.2.4
env: RAILS=master DB=mongoid4
- rvm: 2.2.4
env: RAILS=master DB=sqlite3
- rvm: 2.2.4
@ -55,7 +61,8 @@ matrix:
env: RAILS=master DB=postgres
allow_failures:
- env: RAILS=master DB=mongodb
- env: RAILS=master DB=mongoid5
- env: RAILS=master DB=mongoid4
- env: RAILS=master DB=sqlite3
- env: RAILS=master DB=mysql
- env: RAILS=master DB=postgres

View File

@ -42,10 +42,14 @@ else
end
end
if ENV['DB'] =~ /mongodb/
if ENV['DB'] =~ /mongoid4/
gem 'mongoid', '~> 4.0.0', require: false
end
if ENV['DB'] =~ /mongoid5/
gem 'mongoid', '~> 5.0.0', require: false
end
# Removed from Ruby 2.2 but needed for testing Rails 3.x.
group :test do
gem 'test-unit', '~> 3.0' if RUBY_VERSION >= '2.2'

View File

@ -17,7 +17,7 @@ RSpec::Core::RakeTask.new(:mongoid) do |rspec|
end
task :default do
if ENV['DB'] =~ /mongodb/
if ENV['DB'] =~ /mongoid/
Rake::Task["mongoid"].invoke
else
Rake::Task["spec"].invoke

View File

@ -1,4 +1,9 @@
test:
clients:
default:
database: ransack_mongoid_test
hosts:
- localhost:27017
sessions:
default:
database: ransack_mongoid_test

View File

@ -1,6 +1,8 @@
require 'mongoid'
Mongoid.load!(File.expand_path("../mongoid.yml", __FILE__), :test)
Mongo::Logger.logger.level = Logger::WARN if defined?(Mongo)
Mongoid.purge!
class Person
include Mongoid::Document

View File

@ -30,9 +30,14 @@ RSpec.configure do |config|
config.alias_it_should_behave_like_to :it_has_behavior, 'has behavior'
config.before(:suite) do
message = "Running Ransack specs with #{Mongoid.default_session.inspect
}, Mongoid #{Mongoid::VERSION}, Moped #{Moped::VERSION
}, Origin #{Origin::VERSION} and Ruby #{RUBY_VERSION}"
if ENV['DB'] == 'mongoid4'
message = "Running Ransack specs with #{Mongoid.default_session.inspect
}, Mongoid #{Mongoid::VERSION}, Moped #{Moped::VERSION
}, Origin #{Origin::VERSION} and Ruby #{RUBY_VERSION}"
else
message = "Running Ransack specs with #{Mongoid.default_client.inspect
}, Mongoid #{Mongoid::VERSION}, Mongo driver #{Mongo::VERSION}"
end
line = '=' * message.length
puts line, message, line
Schema.create