diff --git a/.travis.yml b/.travis.yml index 9aff1edc..4fd90fdf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,55 +1,47 @@ language: ruby - sudo: false -rvm: - - 2.1 - - 2.2.6 - - 2.3.3 - - ruby-head - - jruby-9.1.5.0 # is precompiled per http://rubies.travis-ci.org/ - - jruby-head - -jdk: - - oraclejdk8 - -before_install: - - gem update --system - - rvm @global do gem uninstall bundler -a -x - - rvm @global do gem install bundler -v 1.13.7 -install: bundle install --path=vendor/bundle --retry=3 --jobs=3 cache: directories: - vendor/bundle +before_install: + - "travis_retry gem update --system" + - "travis_retry gem update bundler" +install: bundle install --path=vendor/bundle --retry=3 --jobs=3 + script: - bundle exec rake ci after_success: - codeclimate-test-reporter + env: - global: - - "JRUBY_OPTS='--dev -J-Xmx1024M --debug'" matrix: - "RAILS_VERSION=4.1" - "RAILS_VERSION=4.2" - "RAILS_VERSION=5.0" - "RAILS_VERSION=master" +rvm: + - 2.1 + - 2.2.6 + - 2.3.3 + - ruby-head + matrix: + include: + - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } + - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.2 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } + - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } + # See JRuby currently failing on Rails 5+ https://github.com/jruby/activerecord-jdbc-adapter/issues/708 + # - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.0 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } + # - { rvm: jruby-head, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } exclude: - - rvm: 2.1 - env: RAILS_VERSION=master - - rvm: jruby-9.1.5.0 - env: RAILS_VERSION=master - - rvm: jruby-head - env: RAILS_VERSION=master - - rvm: 2.1 - env: RAILS_VERSION=5.0 - - rvm: jruby-9.1.5.0 - env: RAILS_VERSION=5.0 - - rvm: jruby-head - env: RAILS_VERSION=5.0 + - { rvm: 2.1, env: RAILS_VERSION=master } + - { rvm: 2.1, env: RAILS_VERSION=5.0 } allow_failures: - rvm: ruby-head - rvm: jruby-head + # See JRuby currently failing on Rails 5+ https://github.com/jruby/activerecord-jdbc-adapter/issues/708 + - { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=5.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" } fast_finish: true diff --git a/Gemfile b/Gemfile index e854a204..63918d29 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,7 @@ version = ENV['RAILS_VERSION'] || '4.2' if version == 'master' gem 'rack', github: 'rack/rack' gem 'arel', github: 'rails/arel' + gem 'rails', github: 'rails/rails' git 'https://github.com/rails/rails.git' do gem 'railties' gem 'activesupport' @@ -23,6 +24,7 @@ if version == 'master' end else gem_version = "~> #{version}.0" + gem 'rails', gem_version gem 'railties', gem_version gem 'activesupport', gem_version gem 'activemodel', gem_version @@ -36,18 +38,32 @@ end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: (@windows_platforms + [:jruby]) +if ENV['CI'] + if RUBY_VERSION < '2.4' + # Windows: An error occurred while installing nokogiri (1.8.0) + gem 'nokogiri', '< 1.7', platforms: @windows_platforms + end +end + group :bench do # https://github.com/rails-api/active_model_serializers/commit/cb4459580a6f4f37f629bf3185a5224c8624ca76 gem 'benchmark-ips', '>= 2.7.2', require: false, group: :development end group :test do - gem 'sqlite3', platform: (@windows_platforms + [:ruby]) - gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby + gem 'sqlite3', platform: (@windows_platforms + [:ruby]) + platforms :jruby do + if version == 'master' || version >= '5' + gem 'activerecord-jdbcsqlite3-adapter', github: 'jruby/activerecord-jdbc-adapter', branch: 'rails-5' + else + gem 'activerecord-jdbcsqlite3-adapter' + end + end gem 'codeclimate-test-reporter', require: false gem 'm', '~> 1.5' - gem 'pry', '~> 0.10' - gem 'pry-byebug', '~> 3.4', platform: :ruby + gem 'pry', '>= 0.10' + gem 'byebug', '~> 8.2' if RUBY_VERSION < '2.2' + gem 'pry-byebug', platform: :ruby end group :development, :test do diff --git a/appveyor.yml b/appveyor.yml index 7ecfa13a..1da91102 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,8 +5,8 @@ skip_tags: true environment: JRUBY_OPTS: "--dev -J-Xmx1024M --debug" matrix: - - ruby_version: "Ruby21" - - ruby_version: "Ruby21-x64" + - ruby_version: "Ruby23" + - ruby_version: "Ruby23-x64" cache: - vendor/bundle diff --git a/lib/active_model_serializers.rb b/lib/active_model_serializers.rb index 18cdd9f7..6e5c5962 100644 --- a/lib/active_model_serializers.rb +++ b/lib/active_model_serializers.rb @@ -49,5 +49,5 @@ module ActiveModelSerializers require 'active_model/serializer/version' require 'active_model/serializer' require 'active_model/serializable_resource' - require 'active_model_serializers/railtie' if defined?(::Rails) + require 'active_model_serializers/railtie' if defined?(::Rails::Railtie) end diff --git a/test/support/isolated_unit.rb b/test/support/isolated_unit.rb index 26948d4a..abb66951 100644 --- a/test/support/isolated_unit.rb +++ b/test/support/isolated_unit.rb @@ -54,7 +54,7 @@ module TestHelpers require 'rails' require 'action_controller/railtie' - @app = Class.new(Rails::Application) do + app = Class.new(Rails::Application) do config.eager_load = false config.session_store :cookie_store, key: '_myapp_session' config.active_support.deprecation = :log @@ -67,8 +67,10 @@ module TestHelpers config.logger = fake_logger Rails.application.routes.default_url_options = { host: 'example.com' } end - @app.respond_to?(:secrets) && @app.secrets.secret_key_base = '3b7cd727ee24e8444053437c36cc66c4' + def app.name; 'IsolatedRailsApp'; end # rubocop:disable Style/SingleLineMethods + app.respond_to?(:secrets) && app.secrets.secret_key_base = '3b7cd727ee24e8444053437c36cc66c4' + @app = app yield @app if block_given? @app.initialize! end