Skip to content

Commit

Permalink
Support Mongoid 5.
Browse files Browse the repository at this point in the history
  • Loading branch information
simi committed Jan 6, 2016
1 parent b65c97e commit 9e5faf4
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
17 changes: 12 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/mongoid/support/mongoid.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
test:
clients:
default:
database: ransack_mongoid_test
hosts:
- localhost:27017
sessions:
default:
database: ransack_mongoid_test
Expand Down
2 changes: 2 additions & 0 deletions spec/mongoid/support/schema.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 8 additions & 3 deletions spec/mongoid_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@
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
Expand Down

0 comments on commit 9e5faf4

Please sign in to comment.