diff --git a/.travis.yml b/.travis.yml index 072c8a2..c692f01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,11 +5,12 @@ bundler_args: --without development rvm: - 2.0.0 - 2.1.1 - - 2.2 + - 2.2.2 gemfile: - Gemfile - gemfiles/mongoid4.gemfile + - gemfiles/mongoid6.gemfile env: global: @@ -19,6 +20,13 @@ env: - MONGODB=2.4.14 - MONGODB=2.6.10 +matrix: + exclude: + - rvm: 2.0.0 + gemfile: gemfiles/mongoid6.gemfile + - rvm: 2.1.1 + gemfile: gemfiles/mongoid6.gemfile + before_script: - wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${MONGODB}.tgz -O /tmp/mongodb.tgz - tar -xvf /tmp/mongodb.tgz diff --git a/gemfiles/mongoid6.gemfile b/gemfiles/mongoid6.gemfile new file mode 100644 index 0000000..5fcc3d7 --- /dev/null +++ b/gemfiles/mongoid6.gemfile @@ -0,0 +1,18 @@ +source 'https://rubygems.org' + +gemspec path: '..' + +gem 'bundler' +gem 'rake' +gem 'pry' +gem 'mongoid', github: 'mongodb/mongoid', ref: '7c2ff52a0c5292b8e6bf3a9a29bbb19abae3dd5f' + +group :test do + gem 'rspec-given', '~> 3.5' + gem 'codeclimate-test-reporter', require: nil +end + +group :doc do + gem 'yard' + gem 'yard-tomdoc' +end diff --git a/mongoid_includes.gemspec b/mongoid_includes.gemspec index 0ac3646..f648d35 100644 --- a/mongoid_includes.gemspec +++ b/mongoid_includes.gemspec @@ -22,5 +22,5 @@ Gem::Specification.new do |s| s.files = Dir.glob('lib/**/*') + %w(CHANGELOG.md LICENSE.txt README.md Rakefile) s.test_files = Dir.glob('spec/**/*') - s.add_runtime_dependency 'mongoid', ['>= 4.0.0', '< 6.0.0'] + s.add_runtime_dependency 'mongoid', ['>= 4.0.0', '< 7.0.0'] end diff --git a/spec/support/models/game.rb b/spec/support/models/game.rb index b9a3c9c..b26bc55 100644 --- a/spec/support/models/game.rb +++ b/spec/support/models/game.rb @@ -6,7 +6,12 @@ class Game field :name belongs_to :person, index: true, validate: true - belongs_to :parent, class_name: "Game", foreign_key: "parent-id" + + if Mongoid::VERSION >= "6.0.0" + belongs_to :parent, class_name: "Game", foreign_key: "parent-id", optional: true + else + belongs_to :parent, class_name: "Game", foreign_key: "parent-id" + end accepts_nested_attributes_for :person