From 2f7d06d702725a90eeeb20c27e2ef5775d63a7fc Mon Sep 17 00:00:00 2001 From: Joost Verdoorn Date: Thu, 26 May 2016 15:04:34 +0200 Subject: [PATCH] Add mongoid 6 to travis test matrix --- .travis.yml | 8 ++++++++ gemfiles/mongoid6.gemfile | 18 ++++++++++++++++++ spec/support/models/game.rb | 7 ++++++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gemfiles/mongoid6.gemfile diff --git a/.travis.yml b/.travis.yml index 072c8a2..f33b578 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ rvm: 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/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