From c98a3794e98586601772a756687405d7ecdd4f91 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 6 Sep 2017 09:56:43 +0200 Subject: [PATCH 1/2] Test against multiple rails versions. --- .travis.yml | 17 ++++++++++++----- Gemfile | 13 +++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index aa9bb36..66d5a3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,22 +6,29 @@ env: global: - CC_TEST_REPORTER_ID=98c9b3070ea9ac0e8f7afb6570f181506c3a06372b1db5c7deb8e46089fdf132 - GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi) + matrix: + - "RAILS_VERSION=5.0.7.1" + - "RAILS_VERSION=5.1.6.1" + - "RAILS_VERSION=5.2.2" + - "RAILS_VERSION=master" rvm: - - 2.2.2 - - 2.3.3 + - 2.2.9 + - 2.3.8 + - 2.6.1 - ruby-head matrix: allow_failures: - rvm: ruby-head + - env: "RAILS_VERSION=master" before_script: - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - chmod +x ./cc-test-reporter - ./cc-test-reporter before-build after_script: - # Preferably you will run test-reporter on branch update events. But - # if you setup travis to build PR updates only, you don't need to run + # Preferably you will run test-reporter on branch update events. But + # if you setup travis to build PR updates only, you don't need to run # the line below - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi - # In the case where travis is setup to build PR updates only, + # In the case where travis is setup to build PR updates only, # uncomment the line below # - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT diff --git a/Gemfile b/Gemfile index fa75df1..5061ccd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,16 @@ source 'https://rubygems.org' +rails_version = ENV['RAILS_VERSION'] || "default" +rails = + case rails_version + when 'master' + { github: 'rails/rails' } + when 'default' + '>= 5.0' + else + "~> #{ENV['RAILS_VERSION']}" + end + +gem 'rails', rails + gemspec From d8c80cf880e2a2f550d644b8f8574dab49bbf1e7 Mon Sep 17 00:00:00 2001 From: Dmytro Koval Date: Sun, 10 Mar 2019 12:37:45 +0100 Subject: [PATCH 2/2] Fix tests --- jsonapi-rails.gemspec | 2 +- spec/dummy/config/initializers/new_framework_defaults.rb | 4 +++- spec/dummy/config/initializers/sqlite3_fix.rb | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 spec/dummy/config/initializers/sqlite3_fix.rb diff --git a/jsonapi-rails.gemspec b/jsonapi-rails.gemspec index d0f8fdb..48387d4 100644 --- a/jsonapi-rails.gemspec +++ b/jsonapi-rails.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'jsonapi-parser', '~> 0.1.0' spec.add_development_dependency 'rails', '~> 5.0' - spec.add_development_dependency 'sqlite3' + spec.add_development_dependency 'sqlite3', '~> 1.3.6' spec.add_development_dependency 'rake', '~> 11.3' spec.add_development_dependency 'rspec-rails', '~> 3.5' spec.add_development_dependency 'with_model', '~> 2.0' diff --git a/spec/dummy/config/initializers/new_framework_defaults.rb b/spec/dummy/config/initializers/new_framework_defaults.rb index 0706caf..69c499f 100644 --- a/spec/dummy/config/initializers/new_framework_defaults.rb +++ b/spec/dummy/config/initializers/new_framework_defaults.rb @@ -18,7 +18,9 @@ Rails.application.config.active_record.belongs_to_required_by_default = true # Do not halt callback chains when a callback returns false. Previous versions had true. -ActiveSupport.halt_callback_chains_on_return_false = false +if Rails.version < '5.2' + ActiveSupport.halt_callback_chains_on_return_false = false +end # Configure SSL options to enable HSTS with subdomains. Previous versions had false. Rails.application.config.ssl_options = { hsts: { subdomains: true } } diff --git a/spec/dummy/config/initializers/sqlite3_fix.rb b/spec/dummy/config/initializers/sqlite3_fix.rb new file mode 100644 index 0000000..53f9423 --- /dev/null +++ b/spec/dummy/config/initializers/sqlite3_fix.rb @@ -0,0 +1,3 @@ +if Rails.version >= '5.1.0' && Rails.application.config.active_record.sqlite3.present? + Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true +end