From 8f9c257ddea963e04ea76e265532215560386ee4 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 11:23:00 +0100 Subject: [PATCH 01/30] style: lint ci --- .github/workflows/ruby.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 8fd0da3c..30973df9 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [ 'master' ] + branches: ["master"] pull_request: - branches: ['**'] + branches: ["**"] jobs: tests: @@ -13,13 +13,13 @@ jobs: fail-fast: false matrix: ruby: - - '3.4' - - '3.3' - - '3.2' + - "3.2" + - "3.3" + - "3.4" rails: - - '7.1' - - '7.0' - - '8.0.2' + - "7.0" + - "7.1" + - "8.0.2" database_url: - sqlite3:test_db env: From b284212e4d66537e7997bc837eef00275d8d8cdf Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 11:20:19 +0100 Subject: [PATCH 02/30] ci: actions/checkout version --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 30973df9..5c1718d9 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -27,7 +27,7 @@ jobs: DATABASE_URL: ${{ matrix.database_url }} name: Ruby ${{ matrix.ruby }} Rails ${{ matrix.rails }} DB ${{ matrix.database_url }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: From 6e868d4fba6c3709c97fba491320b97b8fcce53f Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 11:21:43 +0100 Subject: [PATCH 03/30] ci: update Rails versions in test matrix --- .github/workflows/ruby.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 5c1718d9..7ec8df04 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -17,9 +17,9 @@ jobs: - "3.3" - "3.4" rails: - - "7.0" - - "7.1" - - "8.0.2" + - "7.2" + - "8.0" + - "8.1" database_url: - sqlite3:test_db env: From f802996fa35864330f8735ccf6b3c4cbf24a271e Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 3 Jul 2026 13:34:19 +0100 Subject: [PATCH 04/30] build: update min versions --- Gemfile | 2 +- jsonapi-resources.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index f022a438..92e20820 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ when 'master' gem 'railties', { git: 'https://github.com/rails/rails.git' } gem 'arel', { git: 'https://github.com/rails/arel.git' } when 'default' - gem 'railties', '>= 6.0' + gem 'railties', '~> 8.0.0' else gem 'railties', "~> #{version}" end diff --git a/jsonapi-resources.gemspec b/jsonapi-resources.gemspec index 22745c81..17581fc9 100644 --- a/jsonapi-resources.gemspec +++ b/jsonapi-resources.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.3' + spec.required_ruby_version = '>= 3.2' spec.add_development_dependency 'bundler', '>= 1.17' spec.add_development_dependency 'rake' From 9cee43cbb5024c8e966a2c5390f123cdaa6c9b66 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 11:05:56 +0100 Subject: [PATCH 05/30] build: limit rails versions to 7.2, 8.0+, not including 9+ --- jsonapi-resources.gemspec | 4 ++-- test/test_helper.rb | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/jsonapi-resources.gemspec b/jsonapi-resources.gemspec index 17581fc9..c8cec473 100644 --- a/jsonapi-resources.gemspec +++ b/jsonapi-resources.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry' spec.add_development_dependency 'concurrent-ruby-ext' spec.add_development_dependency 'database_cleaner' - spec.add_dependency 'activerecord', '>= 5.1' - spec.add_dependency 'railties', '>= 5.1' + spec.add_dependency 'activerecord', '>= 7.2', '< 9.0' # versions 7.2, 8.0, 8.1, and above, but not 9.0 + spec.add_dependency 'railties', '>= 7.2', '< 9.0' # versions 7.2, 8.0, 8.1, and above, but not 9.0 spec.add_dependency 'concurrent-ruby' end diff --git a/test/test_helper.rb b/test/test_helper.rb index f6f9c1b7..9329a505 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -65,9 +65,8 @@ class TestApp < Rails::Application config.active_support.halt_callback_chains_on_return_false = false config.active_record.time_zone_aware_types = [:time, :datetime] config.active_record.belongs_to_required_by_default = false - if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 2 - config.active_record.sqlite3.represent_boolean_as_integer = true - end + config.active_support.cache_format_version = 7.1 + config.active_support.to_time_preserves_timezone = :zone end DatabaseCleaner.allow_remote_database_url = true From 88487bbd5a00522acbbd29369aa3038518b88ac2 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 10:39:53 +0100 Subject: [PATCH 06/30] build: add rack 2 as a dependency --- jsonapi-resources.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/jsonapi-resources.gemspec b/jsonapi-resources.gemspec index c8cec473..69780736 100644 --- a/jsonapi-resources.gemspec +++ b/jsonapi-resources.gemspec @@ -29,5 +29,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'database_cleaner' spec.add_dependency 'activerecord', '>= 7.2', '< 9.0' # versions 7.2, 8.0, 8.1, and above, but not 9.0 spec.add_dependency 'railties', '>= 7.2', '< 9.0' # versions 7.2, 8.0, 8.1, and above, but not 9.0 + spec.add_dependency 'rack', '~> 2.0' spec.add_dependency 'concurrent-ruby' end From 41c6eaa72756f41f9255518633eec4d4b2ca35f7 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Tue, 11 Aug 2026 11:57:26 +0100 Subject: [PATCH 07/30] release: bump version --- lib/jsonapi/resources/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jsonapi/resources/version.rb b/lib/jsonapi/resources/version.rb index b25e5b70..f54a58b9 100644 --- a/lib/jsonapi/resources/version.rb +++ b/lib/jsonapi/resources/version.rb @@ -1,5 +1,5 @@ module JSONAPI module Resources - VERSION = '0.3.0' + VERSION = '0.4.0' end end From 8dbb96698709a2808e2549f8e2d112b4711d9ff7 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Tue, 11 Aug 2026 14:09:43 +0100 Subject: [PATCH 08/30] test: repair old ruby 2 -> 3 errors --- test/test_helper.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 9329a505..17bd46b7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -86,9 +86,9 @@ class Engine < ::Rails::Engine # Monkeypatch ActionController::TestCase to delete the RAW_POST_DATA on subsequent calls in the same test. module ClearRawPostHeader - def process(action, **args) + def process(action, *args, **kwargs) @request.delete_header 'RAW_POST_DATA' - super action, **args + super(action, *args, **kwargs) end end @@ -523,13 +523,13 @@ def assert_cacheable_jsonapi_get(url, cached_classes = :all) end class ActionController::TestCase - def assert_cacheable_get(action, **args) + def assert_cacheable_get(action, **request_options) assert_nil JSONAPI.configuration.resource_cache normal_queries = [] normal_query_callback = lambda {|_, _, _, _, payload| normal_queries.push payload[:sql] } ActiveSupport::Notifications.subscribed(normal_query_callback, 'sql.active_record') do - get action, **args + get action, **request_options end non_caching_response = json_response_sans_all_backtraces non_caching_status = response.status @@ -565,7 +565,7 @@ def assert_cacheable_get(action, **args) @controller = nil setup_controller_request_and_response @request.headers.merge!(orig_request_headers.dup) - get action, **args + get action, **request_options end end rescue Exception From 917c37cf98d80eae78a17585d0e04e099f35fac8 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 3 Jul 2026 13:58:51 +0100 Subject: [PATCH 09/30] build: add minitest-mock as a development dependency cannot load such file -- minitest/mock (LoadError) --- jsonapi-resources.gemspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsonapi-resources.gemspec b/jsonapi-resources.gemspec index 69780736..2883a48d 100644 --- a/jsonapi-resources.gemspec +++ b/jsonapi-resources.gemspec @@ -21,7 +21,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '>= 1.17' spec.add_development_dependency 'rake' - spec.add_development_dependency 'minitest', '~> 5.10', '!= 5.10.2' + spec.add_development_dependency 'minitest' + spec.add_development_dependency 'minitest-mock' spec.add_development_dependency 'minitest-spec-rails' spec.add_development_dependency 'simplecov' spec.add_development_dependency 'pry' From d5afb854bd8c4b77f78633c1d65a3832c17c071e Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Tue, 11 Aug 2026 14:02:43 +0100 Subject: [PATCH 10/30] test: repair test runner not being invoked --- test/test_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 17bd46b7..53565dfa 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -24,6 +24,7 @@ require 'active_record/railtie' require 'minitest/mock' +require 'minitest/autorun' require 'jsonapi-resources' require 'pry' From ed2929eacceb5a70419b10c838cf969ee78021d9 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Tue, 11 Aug 2026 14:19:15 +0100 Subject: [PATCH 11/30] build: add minitest reporters for better test feedback --- jsonapi-resources.gemspec | 1 + test/test_helper.rb | 3 +++ 2 files changed, 4 insertions(+) diff --git a/jsonapi-resources.gemspec b/jsonapi-resources.gemspec index 2883a48d..643be2e4 100644 --- a/jsonapi-resources.gemspec +++ b/jsonapi-resources.gemspec @@ -24,6 +24,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest' spec.add_development_dependency 'minitest-mock' spec.add_development_dependency 'minitest-spec-rails' + spec.add_development_dependency 'minitest-reporters' spec.add_development_dependency 'simplecov' spec.add_development_dependency 'pry' spec.add_development_dependency 'concurrent-ruby-ext' diff --git a/test/test_helper.rb b/test/test_helper.rb index 53565dfa..b6e5d3c5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -25,6 +25,7 @@ require 'active_record/railtie' require 'minitest/mock' require 'minitest/autorun' +require 'minitest/reporters' require 'jsonapi-resources' require 'pry' @@ -33,6 +34,8 @@ require File.expand_path('../helpers/functional_helpers', __FILE__) require File.expand_path('../helpers/configuration_helpers', __FILE__) +Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new + Rails.env = 'test' I18n.load_path += Dir[File.expand_path("../../locales/*.yml", __FILE__)] From 20f32ecbb1520327db478753964200d47521d4d4 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Tue, 11 Aug 2026 14:19:15 +0100 Subject: [PATCH 12/30] test: reduce verbosity of minitest output --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 01619ed8..791c5171 100644 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,7 @@ require 'bundler/gem_tasks' require 'rake/testtask' Rake::TestTask.new do |t| - t.verbose = true + t.verbose = false t.warning = false t.test_files = FileList['test/**/*_test.rb'] end From 5ec8202789fe0ec5680acd0cf6cc87315aa6c24d Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 17 Aug 2026 15:22:50 +0100 Subject: [PATCH 13/30] test: separate rails version text --- test/test_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index b6e5d3c5..04960d61 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -51,7 +51,9 @@ ActiveSupport::Deprecation.silenced = true end +puts "-" * 32 puts "Testing With RAILS VERSION #{Rails.version}" +puts "-" * 32 class TestApp < Rails::Application config.eager_load = false From 1154079565a9aec43b63d507613c0607858151a7 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Wed, 12 Aug 2026 14:33:44 +0100 Subject: [PATCH 14/30] test: ignore temporary test files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 800c71c6..ba614b62 100644 --- a/.gitignore +++ b/.gitignore @@ -21,5 +21,6 @@ coverage test/log test_db test_db-journal +test/test_db-* .idea *.iml From 8ace43f1e26149581a2b68a333937ca01523b088 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 17 Aug 2026 14:10:21 +0100 Subject: [PATCH 15/30] test: update deprecation warning test --- test/unit/resource/resource_test.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/unit/resource/resource_test.rb b/test/unit/resource/resource_test.rb index df2df173..1a2ba6c8 100644 --- a/test/unit/resource/resource_test.rb +++ b/test/unit/resource/resource_test.rb @@ -442,7 +442,9 @@ class ProblemResource < JSONAPI::Resource end CODE end - assert_match /DEPRECATION WARNING: Id without format is no longer supported. Please remove ids from attributes, or specify a format./, err + err_msg = /DEPRECATION WARNING: Id without format is no longer supported. Please remove ids from attributes, or specify a format./ + err_msg_rails_8 = /\[DUPLICATE ATTRIBUTE\] `id` has already been defined in ProblemResource\./ + assert(err.match?(err_msg) || err.match?(err_msg_rails_8), "Expected either deprecation or duplicate-attribute warning, got: #{err}") ensure ActiveSupport::Deprecation.silenced = true end From de41a932ab13ab77aa6e0f759e6c0d18c5225eac Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 17 Aug 2026 14:11:59 +0100 Subject: [PATCH 16/30] fix: use Rails 8 style deprecation warning messages --- lib/jsonapi/compatibility_helper.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/jsonapi/compatibility_helper.rb b/lib/jsonapi/compatibility_helper.rb index 51660934..b1d5266c 100644 --- a/lib/jsonapi/compatibility_helper.rb +++ b/lib/jsonapi/compatibility_helper.rb @@ -9,8 +9,7 @@ # JSONAPI::CompatibilityHelper.deprecation_warn("Your deprecation message") # # The method will use the public `warn` method if available, otherwise it will -# use `send(:warn, ...)` to maintain compatibility with Rails 8+ where `warn` -# is private. +# use Rails 8+ style deprecation warnings. # # Example: # JSONAPI::CompatibilityHelper.deprecation_warn("This feature is deprecated.") @@ -21,7 +20,7 @@ def deprecation_warn(message) if ActiveSupport::Deprecation.respond_to?(:warn) && ActiveSupport::Deprecation.public_method_defined?(:warn) ActiveSupport::Deprecation.warn(message) else - ActiveSupport::Deprecation.send(:warn, message) + ActiveSupport::Deprecation.new(nil, 'JSONAPI').warn(message) end end module_function :deprecation_warn From 1dab6ce026ac480adadda71b20272af864183bae Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 17 Aug 2026 15:31:30 +0100 Subject: [PATCH 17/30] fix: improve handling of deprecation warnings --- lib/jsonapi/compatibility_helper.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/jsonapi/compatibility_helper.rb b/lib/jsonapi/compatibility_helper.rb index b1d5266c..be637991 100644 --- a/lib/jsonapi/compatibility_helper.rb +++ b/lib/jsonapi/compatibility_helper.rb @@ -17,11 +17,7 @@ module JSONAPI module CompatibilityHelper def deprecation_warn(message) - if ActiveSupport::Deprecation.respond_to?(:warn) && ActiveSupport::Deprecation.public_method_defined?(:warn) - ActiveSupport::Deprecation.warn(message) - else ActiveSupport::Deprecation.new(nil, 'JSONAPI').warn(message) - end end module_function :deprecation_warn end From fd893eafc2b3efc90d2fa9f9d04a08d4a714a693 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 17 Aug 2026 15:44:51 +0100 Subject: [PATCH 18/30] fix: repair deprecated code --- test/fixtures/active_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixtures/active_record.rb b/test/fixtures/active_record.rb index e6866785..67fd4436 100644 --- a/test/fixtures/active_record.rb +++ b/test/fixtures/active_record.rb @@ -1679,7 +1679,7 @@ class PlanetResource < JSONAPI::Resource attribute :description has_many :moons - belongs_to :planet_type + has_one :planet_type has_many :tags, acts_as_set: true end From 49b976e8dc1eadc06c1c9c33a4cd7a70f5270860 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 11:45:53 +0100 Subject: [PATCH 19/30] test: remove test-db as part of the rake task run --- Rakefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Rakefile b/Rakefile index 791c5171..699237f4 100644 --- a/Rakefile +++ b/Rakefile @@ -1,13 +1,20 @@ #!/usr/bin/env rake require 'bundler/gem_tasks' +require 'fileutils' require 'rake/testtask' +task :remove_test_db do + FileUtils.rm_f(File.expand_path('test/test_db', __dir__)) +end + Rake::TestTask.new do |t| t.verbose = false t.warning = false t.test_files = FileList['test/**/*_test.rb'] end +Rake::Task[:test].enhance([:remove_test_db]) + task default: [:test] desc 'Run benchmarks' From 3d5dabb9063dee201723e7e5a268131dcfb8c935 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 11:53:52 +0100 Subject: [PATCH 20/30] build: add test support for Rails 7.1 for overlap with previous release --- .github/workflows/ruby.yml | 1 + jsonapi-resources.gemspec | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 7ec8df04..f159e5cb 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -17,6 +17,7 @@ jobs: - "3.3" - "3.4" rails: + - "7.1" - "7.2" - "8.0" - "8.1" diff --git a/jsonapi-resources.gemspec b/jsonapi-resources.gemspec index 643be2e4..7be374b3 100644 --- a/jsonapi-resources.gemspec +++ b/jsonapi-resources.gemspec @@ -29,8 +29,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry' spec.add_development_dependency 'concurrent-ruby-ext' spec.add_development_dependency 'database_cleaner' - spec.add_dependency 'activerecord', '>= 7.2', '< 9.0' # versions 7.2, 8.0, 8.1, and above, but not 9.0 - spec.add_dependency 'railties', '>= 7.2', '< 9.0' # versions 7.2, 8.0, 8.1, and above, but not 9.0 + spec.add_dependency 'activerecord', '>= 7.1', '< 9.0' # versions 7.1, 7.2, 8.0, 8.1, and above, but not 9.0 + spec.add_dependency 'railties', '>= 7.1', '< 9.0' # versions 7.1, 7.2, 8.0, 8.1, and above, but not 9.0 spec.add_dependency 'rack', '~> 2.0' spec.add_dependency 'concurrent-ruby' end From 105fb138e22c6734ba27ab32e2ba4cbd10f54ca8 Mon Sep 17 00:00:00 2001 From: Stephen Hulme <135011085+StephenHulme@users.noreply.github.com> Date: Mon, 17 Aug 2026 11:42:28 +0100 Subject: [PATCH 21/30] docs: update README with Sanger release process See #21 --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b7f2f18f..5f476d52 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ -# JSONAPI::Resources [![Gem Version](https://badge.fury.io/rb/jsonapi-resources.svg)](https://badge.fury.io/rb/jsonapi-resources) [![Build Status](https://secure.travis-ci.org/cerebris/jsonapi-resources.svg?branch=master)](http://travis-ci.org/cerebris/jsonapi-resources) [![Code Climate](https://codeclimate.com/github/cerebris/jsonapi-resources/badges/gpa.svg)](https://codeclimate.com/github/cerebris/jsonapi-resources) - -[![Join the chat at https://gitter.im/cerebris/jsonapi-resources](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cerebris/jsonapi-resources?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +# JSONAPI::Resources (Sanger fork) `JSONAPI::Resources`, or "JR", provides a framework for developing an API server that complies with the [JSON:API](http://jsonapi.org/) specification. @@ -13,7 +11,7 @@ backed by ActiveRecord models or by custom objects. ## Documentation -Full documentation can be found at [http://jsonapi-resources.com](http://jsonapi-resources.com), including the [v0.10 alpha Guide](http://jsonapi-resources.com/v0.10/guide/) specific to this version. +Full documentation can be found at [http://jsonapi-resources.com](http://jsonapi-resources.com), including the [v0.10 alpha Guide](http://jsonapi-resources.com/v0.10/guide/) specific to this version. ## Demo App @@ -22,31 +20,71 @@ We have a simple demo app, called [Peeps](https://github.com/cerebris/peeps), av ## Client Libraries JSON:API maintains a (non-verified) listing of [client libraries](http://jsonapi.org/implementations/#client-libraries) -which *should* be compatible with JSON:API compliant server implementations such as JR. +which _should_ be compatible with JSON:API compliant server implementations such as JR. ## Installation Add JR to your application's `Gemfile`: -``` +``` gem 'jsonapi-resources' ``` And then execute: -```bash +```bash bundle ``` Or install it yourself as: -```bash +```bash gem install jsonapi-resources ``` **For further usage see the [v0.10 alpha Guide](http://jsonapi-resources.com/v0.10/guide/)** +## Sanger-specific release process + +There are two versions of the gem which we use for production. The version 1 series has unique customisations and is used by Sequencescape. The version 2 series is a more generic version which is used by Traction. + +Check which versions we have published at https://rubygems.org/gems/sanger-jsonapi-resources + +### For version 1 series + +- Create a branch from **develop**, apply fixes. +- Change version number in `lib/jsonapi/resources/version.rb` . This file is read by the gemspec during publication. +- Test Sequencescape with the gem from the branch. +- Merge the branch into develop. +- Create a release from the develop branch with the new version number as the tag. Set Release label to _None_. + +- Checkout the newly-created tag on develop. +- Execute `bundle install` to ensure the gemspec is up to date. +- Execute `gem build jsonapi-resources.gemspec` which builds sanger-jsonapi-resources-0.1.x.gem in this case. +- Execute `gem push sanger-jsonapi-resources-0.1.x.gem` which publishes the gem. + +### For version 2 series + +- Create a branch from **master**, apply fixes. +- Change version number in `lib/jsonapi/resources/version.rb` . This file is read by the gemspec during publication. +- Test Traction with the gem from the branch. +- Merge the branch into master. +- Create a release from the master branch with the new version number as the tag. Set Release label to _Latest_. + +- Checkout the newly-created tag on master. +- Execute `bundle install` to ensure the gemspec is up to date. +- Execute `gem build jsonapi-resources.gemspec` which builds sanger-jsonapi-resources-0.2.x.gem in this case. +- Execute `gem push sanger-jsonapi-resources-0.2.x.gem` which publishes the gem. + +### Publication + +You will be notified by email for each. You will also receive one email for API key setup. The first push will ask email and password for the account, which are in KeePass (search for "gem"). + +> [!NOTE] +> The email and password for gem publication is a recent addition to the credentials database. Pull latest changes in the credentials repo. + ## Contributing + See CONTRIBUTING.md for details. ## License From 805e1772a85756bcac0d09fd513d9316cff36a7b Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 11:57:02 +0100 Subject: [PATCH 22/30] docs: update Rails versions aim --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5f476d52..6c0b80af 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ gem install jsonapi-resources There are two versions of the gem which we use for production. The version 1 series has unique customisations and is used by Sequencescape. The version 2 series is a more generic version which is used by Traction. +The aim is to support the 3 most recent Rails versions for each series to allow for seamless upgrades between releases. + Check which versions we have published at https://rubygems.org/gems/sanger-jsonapi-resources ### For version 1 series From 6017814ef43c4838154282b6440f48b36bd82949 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 12:02:10 +0100 Subject: [PATCH 23/30] test: use the best reporter for each test environment --- test/test_helper.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 04960d61..eb8bffc4 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -34,7 +34,12 @@ require File.expand_path('../helpers/functional_helpers', __FILE__) require File.expand_path('../helpers/configuration_helpers', __FILE__) -Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new +if ENV['CI'] == 'true' + # The SpecReporter is easier to read on GitHub + Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new +else + Minitest::Reporters.use! +end Rails.env = 'test' From 346378634f82f8eeade25e82ecdb9dd3e61ab29b Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 12:10:19 +0100 Subject: [PATCH 24/30] test: add patch to Rails version specifier for correct resolution --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 92e20820..9a10e270 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,8 @@ platforms :jruby do end version = ENV['RAILS_VERSION'] || 'default' +# If version is like 'x.y' add a '.0' to make it 'x.y.0' for correct resolution +version = "#{version}.0" if version =~ /^\d+\.\d+$/ platforms :ruby do gem 'pg' From 315d19c057f6e5645b647fb5b98b8fbc69d3d6d9 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 12:47:37 +0100 Subject: [PATCH 25/30] test: file deprecation behaviour silencing for Rails 7.2 --- test/integration/requests/request_test.rb | 4 ++-- test/test_helper.rb | 12 ++++++++---- test/unit/resource/resource_test.rb | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/test/integration/requests/request_test.rb b/test/integration/requests/request_test.rb index 1863b5c7..165d31e9 100644 --- a/test/integration/requests/request_test.rb +++ b/test/integration/requests/request_test.rb @@ -1367,7 +1367,7 @@ def test_deprecated_include_parameter_not_allowed end def test_deprecated_include_message - ActiveSupport::Deprecation.silenced = false + set_deprecation_behavior(:report) original_config = JSONAPI.configuration.dup _out, err = capture_io do eval <<-CODE @@ -1377,7 +1377,7 @@ def test_deprecated_include_message assert_match /DEPRECATION WARNING: `allow_include` has been replaced by `default_allow_include_to_one` and `default_allow_include_to_many` options./, err ensure JSONAPI.configuration = original_config - ActiveSupport::Deprecation.silenced = true + set_deprecation_behavior(:silence) end diff --git a/test/test_helper.rb b/test/test_helper.rb index eb8bffc4..8bd1bc23 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -50,12 +50,16 @@ config.json_key_format = :camelized_key end -if ActiveSupport::Deprecation.respond_to?(:behavior=) - ActiveSupport::Deprecation.behavior = :silence -elsif ActiveSupport::Deprecation.respond_to?(:silenced=) - ActiveSupport::Deprecation.silenced = true +def set_deprecation_behavior(mode) + if ActiveSupport::Deprecation.respond_to?(:behavior=) + ActiveSupport::Deprecation.behavior = mode + elsif ActiveSupport::Deprecation.respond_to?(:silenced=) + ActiveSupport::Deprecation.silenced = (mode == :silence) + end end +set_deprecation_behavior(:silence) + puts "-" * 32 puts "Testing With RAILS VERSION #{Rails.version}" puts "-" * 32 diff --git a/test/unit/resource/resource_test.rb b/test/unit/resource/resource_test.rb index 1a2ba6c8..464b9049 100644 --- a/test/unit/resource/resource_test.rb +++ b/test/unit/resource/resource_test.rb @@ -434,7 +434,7 @@ def test_key_type_proc def test_id_attr_deprecation - ActiveSupport::Deprecation.silenced = false + set_deprecation_behavior(:report) _out, err = capture_io do eval <<-CODE class ProblemResource < JSONAPI::Resource @@ -446,7 +446,7 @@ class ProblemResource < JSONAPI::Resource err_msg_rails_8 = /\[DUPLICATE ATTRIBUTE\] `id` has already been defined in ProblemResource\./ assert(err.match?(err_msg) || err.match?(err_msg_rails_8), "Expected either deprecation or duplicate-attribute warning, got: #{err}") ensure - ActiveSupport::Deprecation.silenced = true + set_deprecation_behavior(:silence) end def test_id_attr_with_format From 5bc93eb4083c18a00c253b0e6f663d14241c5dad Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 13:00:16 +0100 Subject: [PATCH 26/30] fix: remove Rails 4 routing --- lib/jsonapi/routing_ext.rb | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/lib/jsonapi/routing_ext.rb b/lib/jsonapi/routing_ext.rb index 2bc480fe..daa13d3d 100644 --- a/lib/jsonapi/routing_ext.rb +++ b/lib/jsonapi/routing_ext.rb @@ -47,27 +47,13 @@ def jsonapi_resource(*resources, &_block) end resource @resource_type, options do - # :nocov: - if @scope.respond_to? :[]= - # Rails 4 - @scope[:jsonapi_resource] = @resource_type - + jsonapi_resource_scope(SingletonResource.new(@resource_type, api_only?, @scope[:shallow], **options), @resource_type) do if block_given? yield else jsonapi_relationships end - else - # Rails 5 - jsonapi_resource_scope(SingletonResource.new(@resource_type, api_only?, @scope[:shallow], **options), @resource_type) do - if block_given? - yield - else - jsonapi_relationships - end - end end - # :nocov: end end @@ -122,26 +108,13 @@ def jsonapi_resources(*resources, &_block) end resources @resource_type, options do - # :nocov: - if @scope.respond_to? :[]= - # Rails 4 - @scope[:jsonapi_resource] = @resource_type + jsonapi_resource_scope(Resource.new(@resource_type, api_only?, @scope[:shallow], **options), @resource_type) do if block_given? yield else jsonapi_relationships end - else - # Rails 5 - jsonapi_resource_scope(Resource.new(@resource_type, api_only?, @scope[:shallow], **options), @resource_type) do - if block_given? - yield - else - jsonapi_relationships - end - end end - # :nocov: end end From 6c55de13739cc5114f8040b24013c76c46930be7 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 13:04:38 +0100 Subject: [PATCH 27/30] fix: add support for keyword options in resources --- lib/jsonapi/routing_ext.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jsonapi/routing_ext.rb b/lib/jsonapi/routing_ext.rb index daa13d3d..8a37b824 100644 --- a/lib/jsonapi/routing_ext.rb +++ b/lib/jsonapi/routing_ext.rb @@ -46,7 +46,7 @@ def jsonapi_resource(*resources, &_block) options[:except] << :destroy unless options[:except].include?(:destroy) || options[:except].include?('destroy') end - resource @resource_type, options do + resource @resource_type, **options do jsonapi_resource_scope(SingletonResource.new(@resource_type, api_only?, @scope[:shallow], **options), @resource_type) do if block_given? yield @@ -107,7 +107,7 @@ def jsonapi_resources(*resources, &_block) options[:except] << :destroy unless options[:except].include?(:destroy) || options[:except].include?('destroy') end - resources @resource_type, options do + resources @resource_type, **options do jsonapi_resource_scope(Resource.new(@resource_type, api_only?, @scope[:shallow], **options), @resource_type) do if block_given? yield From ad1a4484460c1613458976d82e6297a153df3db7 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 17 Aug 2026 12:13:06 +0100 Subject: [PATCH 28/30] test: update error message for Rails 8.1 --- test/integration/requests/request_test.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/integration/requests/request_test.rb b/test/integration/requests/request_test.rb index 165d31e9..6ce002c7 100644 --- a/test/integration/requests/request_test.rb +++ b/test/integration/requests/request_test.rb @@ -578,7 +578,9 @@ def test_put_invalid_json assert_equal 400, status assert_equal 'Bad Request', json_response['errors'][0]['title'] - assert_match 'unexpected token at', json_response['errors'][0]['detail'] + rails_old_msg = 'unexpected token at' + rails_8_1_msg = "expected ',' or '}' after object value, got: '\"attributes\":'" + assert_match (/(#{rails_old_msg}|#{rails_8_1_msg})/), json_response['errors'][0]['detail'] end def test_put_valid_json_but_array From 042816e744701f55bae7b445dc177a7629538ee6 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 13:48:09 +0100 Subject: [PATCH 29/30] test: handle different database True when on SQLite 8.1 --- .../join_manager_test.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/unit/active_relation_resource_finder/join_manager_test.rb b/test/unit/active_relation_resource_finder/join_manager_test.rb index 840c90ee..e76f1e3c 100644 --- a/test/unit/active_relation_resource_finder/join_manager_test.rb +++ b/test/unit/active_relation_resource_finder/join_manager_test.rb @@ -4,12 +4,16 @@ class JoinTreeTest < ActiveSupport::TestCase def db_true + rails_major = 8 + rails_minor = 1 + case ActiveRecord::Base.connection.adapter_name when 'SQLite' - if Rails::VERSION::MAJOR >= 6 || (Rails::VERSION::MAJOR >= 5 && ActiveRecord::VERSION::MINOR >= 2) - "1" + if Rails::VERSION::MAJOR >= rails_major + 1 || + (Rails::VERSION::MAJOR >= rails_major && ActiveRecord::VERSION::MINOR >= rails_minor) + "TRUE" else - "'t'" + "1" end when 'PostgreSQL' 'TRUE' From ff5107f7725399377b39b883056ee2513eedc8f2 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 20 Aug 2026 13:48:43 +0100 Subject: [PATCH 30/30] build: set development rails to 8.1 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 9a10e270..1b438ec5 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,7 @@ when 'master' gem 'railties', { git: 'https://github.com/rails/rails.git' } gem 'arel', { git: 'https://github.com/rails/arel.git' } when 'default' - gem 'railties', '~> 8.0.0' + gem 'railties', '~> 8.1.0' else gem 'railties', "~> #{version}" end