From 750736b0c105d8f0938748de5603aa8a19aae4df Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Wed, 21 Oct 2026 19:29:17 -0500 Subject: [PATCH 1/2] test: load logger before Rails test dependencies --- test/test_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 30d439dd..b51eeb6e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,4 @@ +require 'logger' require 'simplecov' require 'database_cleaner' From 0af8b25a9063e3bddedcf72330476edd9ffbaa92 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Wed, 21 Oct 2026 19:37:06 -0500 Subject: [PATCH 2/2] test: add routing regressions with configured paths --- test/unit/routing_compatibility_test.rb | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/unit/routing_compatibility_test.rb diff --git a/test/unit/routing_compatibility_test.rb b/test/unit/routing_compatibility_test.rb new file mode 100644 index 00000000..5e3fb1aa --- /dev/null +++ b/test/unit/routing_compatibility_test.rb @@ -0,0 +1,39 @@ +require 'logger' +require 'minitest/autorun' +require 'active_support/all' +require 'rails' +require 'action_controller' +require 'jsonapi-resources' + +class RoutingCompatibilityResource < JSONAPI::Resource +end + +class RoutingProfileResource < JSONAPI::Resource + singleton singleton_key: -> (context) { context[:current_user_id] } +end + +class RoutingCompatibilityTest < Minitest::Test + def test_plural_routes_preserve_keyword_options + routes = ActionDispatch::Routing::RouteSet.new + routes.draw do + jsonapi_resources :routing_compatibilities, controller: 'examples', only: [:index, :show] + end + + path = JSONAPI.configuration.route_formatter.format('routing_compatibilities') + assert_equal "/#{path}", routes.url_helpers.routing_compatibilities_path + assert_equal "/#{path}/42", routes.url_helpers.routing_compatibility_path(42) + assert_equal ['examples'], routes.routes.map { |route| route.defaults[:controller] }.uniq + refute_includes routes.routes.map(&:verb), 'DELETE' + end + + def test_singleton_routes_preserve_keyword_options + routes = ActionDispatch::Routing::RouteSet.new + routes.draw do + jsonapi_resource :routing_profile, controller: 'profiles', only: [:show] + end + + assert_equal "/#{JSONAPI.configuration.route_formatter.format('routing_profile')}", routes.url_helpers.routing_profile_path + assert_equal ['profiles'], routes.routes.map { |route| route.defaults[:controller] }.uniq + refute_includes routes.routes.map(&:verb), 'DELETE' + end +end