From 53c95a97076ff68b27b4a7e4e5087605d4b93d7f Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Wed, 2 Oct 2024 21:12:08 +0200 Subject: [PATCH 1/5] Drop Rails 5 support Closes https://github.com/jsonapi-rb/jsonapi-rails/issues/147 --- .github/workflows/ci.yml | 12 +----------- Gemfile | 2 +- jsonapi-rails.gemspec | 2 +- .../config/initializers/new_framework_defaults.rb | 5 ----- spec/dummy/config/initializers/sqlite3_fix.rb | 2 +- 5 files changed, 4 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd8af93..00bc3f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,32 +11,22 @@ jobs: fail-fast: false matrix: ruby: [3.2, 3.1, '3.0', 2.7, 2.6, ruby-head] - rails: ['7.0.0', '6.1.0', '6.0.0', '5.2.0', main] + rails: ['7.0.0', '6.1.0', '6.0.0', main] exclude: - ruby: ruby-head rails: '6.1.0' - ruby: ruby-head rails: '6.0.0' - - ruby: ruby-head - rails: '5.2.0' - ruby: 3.2 rails: '6.0.0' - - ruby: 3.2 - rails: '5.2.0' - ruby: 3.1 rails: '6.0.0' - - ruby: 3.1 - rails: '5.2.0' - ruby: 3.0 rails: main - ruby: 3.0 rails: '6.0.0' - - ruby: 3.0 - rails: '5.2.0' - ruby: 2.7 rails: main - - ruby: 2.7 - rails: '5.2.0' - ruby: 2.6 rails: main - ruby: 2.6 diff --git a/Gemfile b/Gemfile index fe1f9bc..2739fe4 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ rails = when 'main' { github: 'rails/rails' } when 'default' - '>= 5.0' + '>= 6.0' else "~> #{ENV['RAILS_VERSION']}" end diff --git a/jsonapi-rails.gemspec b/jsonapi-rails.gemspec index 24c4a45..84bbd7e 100644 --- a/jsonapi-rails.gemspec +++ b/jsonapi-rails.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'jsonapi-rb', '~> 0.5.0' spec.add_dependency 'jsonapi-parser', '~> 0.1.0' - spec.add_development_dependency 'rails', '>= 5.0' + spec.add_development_dependency 'rails', '>= 6.0' spec.add_development_dependency 'sqlite3', '>= 1.3' spec.add_development_dependency 'rake', '>= 11.3' spec.add_development_dependency 'rspec-rails', '>= 4.0' diff --git a/spec/dummy/config/initializers/new_framework_defaults.rb b/spec/dummy/config/initializers/new_framework_defaults.rb index 69c499f..9359584 100644 --- a/spec/dummy/config/initializers/new_framework_defaults.rb +++ b/spec/dummy/config/initializers/new_framework_defaults.rb @@ -17,10 +17,5 @@ # Require `belongs_to` associations by default. Previous versions had false. 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. -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 index 53f9423..a09345e 100644 --- a/spec/dummy/config/initializers/sqlite3_fix.rb +++ b/spec/dummy/config/initializers/sqlite3_fix.rb @@ -1,3 +1,3 @@ -if Rails.version >= '5.1.0' && Rails.application.config.active_record.sqlite3.present? +if Rails.application.config.active_record.sqlite3.present? Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true end From c825afde674c38b0f59961a094a36a940780c470 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sun, 15 Sep 2024 17:25:00 +0200 Subject: [PATCH 2/5] Test against Ruby 3.3, Rails 7.2, and Rails 7.1 Also: - Update checkout action - Load correct sqlite3 version - Set minimum required ruby version (according to Rails 6.0) --- .github/workflows/ci.yml | 20 +++++++++++++++++--- Gemfile | 3 +++ jsonapi-rails.gemspec | 2 ++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00bc3f6..1d2382b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,25 +10,39 @@ jobs: strategy: fail-fast: false matrix: - ruby: [3.2, 3.1, '3.0', 2.7, 2.6, ruby-head] - rails: ['7.0.0', '6.1.0', '6.0.0', main] + ruby: [3.3, 3.2, 3.1, '3.0', 2.7, 2.6, ruby-head] + rails: ['7.2.0', '7.1.0', '7.0.0', '6.1.0', '6.0.0', main] exclude: + - ruby: ruby-head + rails: '7.0.0' - ruby: ruby-head rails: '6.1.0' - ruby: ruby-head rails: '6.0.0' + - ruby: 3.3 + rails: '6.1.0' + - ruby: 3.3 + rails: '6.0.0' - ruby: 3.2 rails: '6.0.0' - ruby: 3.1 rails: '6.0.0' - ruby: 3.0 rails: main + - ruby: 3.0 + rails: '7.2.0' - ruby: 3.0 rails: '6.0.0' - ruby: 2.7 rails: main + - ruby: 2.7 + rails: '7.2.0' - ruby: 2.6 rails: main + - ruby: 2.6 + rails: '7.2.0' + - ruby: 2.6 + rails: '7.1.0' - ruby: 2.6 rails: '7.0.0' - ruby: 2.6 @@ -40,7 +54,7 @@ jobs: RAILS_VERSION: ${{ matrix.rails }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Ruby ${{ matrix.ruby }} uses: ruby/setup-ruby@v1 with: diff --git a/Gemfile b/Gemfile index 2739fe4..ef6bb84 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,8 @@ source 'https://rubygems.org' rails_version = ENV['RAILS_VERSION'] || "default" +require_sqlite3_1x = %w[7.0.0 6.1.0 6.0.0].include?(rails_version) + rails = case rails_version when 'main' @@ -12,5 +14,6 @@ rails = end gem 'rails', rails +gem 'sqlite3', '~> 1.3' if require_sqlite3_1x gemspec diff --git a/jsonapi-rails.gemspec b/jsonapi-rails.gemspec index 84bbd7e..b8d74d1 100644 --- a/jsonapi-rails.gemspec +++ b/jsonapi-rails.gemspec @@ -16,6 +16,8 @@ Gem::Specification.new do |spec| spec.files = Dir['README.md', 'lib/**/*'] spec.require_path = 'lib' + spec.required_ruby_version = '>= 2.5.0' + spec.add_dependency 'jsonapi-rb', '~> 0.5.0' spec.add_dependency 'jsonapi-parser', '~> 0.1.0' From edd47d83458e68169fdc885b3f9813363a7aed7d Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sun, 15 Sep 2024 17:34:34 +0200 Subject: [PATCH 3/5] Fix Ruby-head compatibility Replace OpenStruct with Struct to allow spec passing against ruby-head without requiring openstruct in development dependencies --- spec/render_jsonapi_spec.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/render_jsonapi_spec.rb b/spec/render_jsonapi_spec.rb index a02c10b..eb42a51 100644 --- a/spec/render_jsonapi_spec.rb +++ b/spec/render_jsonapi_spec.rb @@ -20,6 +20,8 @@ def index context 'when using a cache' do controller do + User = Struct.new(:id, :name, :dob) + def serializer Class.new(JSONAPI::Serializable::Resource) do type 'users' @@ -32,17 +34,17 @@ def jsonapi_cache_key(*) end def user - OpenStruct.new(id: 1, name: 'Johnny Cache', dob: Time.utc(2021,1,1)) + User.new(1, 'Johnny Cache', Time.utc(2021,1,1)) end def index render jsonapi: [user], - class: { OpenStruct: serializer } + class: { User: serializer } end def index_with_caching render jsonapi: [user], - class: { OpenStruct: serializer }, + class: { User: serializer }, cache: Rails.cache end end From c3b6eeca598361888019be52ff3b5b0f0aaea210 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Wed, 2 Oct 2024 09:25:51 +0200 Subject: [PATCH 4/5] Drop legacy Rails and Ruby support - Drop Ruby < 3.1.0 - Drop Rails < 7.0.0 --- .github/workflows/ci.yml | 36 ++---------------------------------- Gemfile | 4 ++-- jsonapi-rails.gemspec | 4 ++-- spec/parsed_body_spec.rb | 2 +- 4 files changed, 7 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d2382b..1c671d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,45 +10,13 @@ jobs: strategy: fail-fast: false matrix: - ruby: [3.3, 3.2, 3.1, '3.0', 2.7, 2.6, ruby-head] - rails: ['7.2.0', '7.1.0', '7.0.0', '6.1.0', '6.0.0', main] + ruby: [3.3, 3.2, 3.1, ruby-head] + rails: ['7.2.0', '7.1.0', '7.0.0', main] exclude: - ruby: ruby-head rails: '7.0.0' - - ruby: ruby-head - rails: '6.1.0' - - ruby: ruby-head - rails: '6.0.0' - - ruby: 3.3 - rails: '6.1.0' - - ruby: 3.3 - rails: '6.0.0' - - ruby: 3.2 - rails: '6.0.0' - ruby: 3.1 - rails: '6.0.0' - - ruby: 3.0 - rails: main - - ruby: 3.0 - rails: '7.2.0' - - ruby: 3.0 - rails: '6.0.0' - - ruby: 2.7 rails: main - - ruby: 2.7 - rails: '7.2.0' - - ruby: 2.6 - rails: main - - ruby: 2.6 - rails: '7.2.0' - - ruby: 2.6 - rails: '7.1.0' - - ruby: 2.6 - rails: '7.0.0' - - ruby: 2.6 - rails: '6.1.0' - - ruby: 2.6 - rails: '6.0.0' env: RAILS_VERSION: ${{ matrix.rails }} diff --git a/Gemfile b/Gemfile index ef6bb84..ac62360 100644 --- a/Gemfile +++ b/Gemfile @@ -1,14 +1,14 @@ source 'https://rubygems.org' rails_version = ENV['RAILS_VERSION'] || "default" -require_sqlite3_1x = %w[7.0.0 6.1.0 6.0.0].include?(rails_version) +require_sqlite3_1x = %w[7.0.0].include?(rails_version) rails = case rails_version when 'main' { github: 'rails/rails' } when 'default' - '>= 6.0' + '>= 7.0' else "~> #{ENV['RAILS_VERSION']}" end diff --git a/jsonapi-rails.gemspec b/jsonapi-rails.gemspec index b8d74d1..95a510b 100644 --- a/jsonapi-rails.gemspec +++ b/jsonapi-rails.gemspec @@ -16,12 +16,12 @@ Gem::Specification.new do |spec| spec.files = Dir['README.md', 'lib/**/*'] spec.require_path = 'lib' - spec.required_ruby_version = '>= 2.5.0' + spec.required_ruby_version = '>= 3.1.0' spec.add_dependency 'jsonapi-rb', '~> 0.5.0' spec.add_dependency 'jsonapi-parser', '~> 0.1.0' - spec.add_development_dependency 'rails', '>= 6.0' + spec.add_development_dependency 'rails', '>= 7.0' spec.add_development_dependency 'sqlite3', '>= 1.3' spec.add_development_dependency 'rake', '>= 11.3' spec.add_development_dependency 'rspec-rails', '>= 4.0' diff --git a/spec/parsed_body_spec.rb b/spec/parsed_body_spec.rb index 985d582..4ea968b 100644 --- a/spec/parsed_body_spec.rb +++ b/spec/parsed_body_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe ActionController::Base, type: :controller, if: Rails.version >= '6.0' do +describe ActionController::Base, type: :controller do controller do def index render jsonapi: nil From 87246b76288eaf3fcd55d776892d9c393f22329d Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Wed, 2 Oct 2024 21:12:47 +0200 Subject: [PATCH 5/5] Fix badge link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 376d036..0ec1ff8 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Rails integration for [jsonapi-rb](http://jsonapi-rb.org). ## Status [![Gem Version](https://badge.fury.io/rb/jsonapi-rails.svg)](https://badge.fury.io/rb/jsonapi-rails) -[![Build Status](https://github.com/jsonapi-rb/jsonapi-rails/actions/workflows/ci.yml/badge.svg)](https://github.com/jsonapi-rb/jsonapi-rails/actions/workflows/ci.yml/badge.svg) +[![Build Status](https://github.com/jsonapi-rb/jsonapi-rails/actions/workflows/ci.yml/badge.svg)](https://github.com/jsonapi-rb/jsonapi-rails/actions/workflows/ci.yml) [![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.svg)](https://gitter.im/jsonapi-rb/Lobby) ## Resources