From eadf4b6e73dec8ae18df337563d2aa2834ce9483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20Bagu=C3=A9?= Date: Fri, 21 Oct 2022 09:49:32 +0000 Subject: [PATCH] enable usage in API-only applications --- lib/geared_pagination/engine.rb | 1 + test/controller_test.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/geared_pagination/engine.rb b/lib/geared_pagination/engine.rb index 19fc249..384bb59 100644 --- a/lib/geared_pagination/engine.rb +++ b/lib/geared_pagination/engine.rb @@ -5,6 +5,7 @@ class GearedPagination::Engine < ::Rails::Engine initializer :geared_pagination do |app| ActiveSupport.on_load :action_controller do ActionController::Base.send :include, GearedPagination::Controller + ActionController::API.send :include, GearedPagination::Controller end end end diff --git a/test/controller_test.rb b/test/controller_test.rb index debdfc1..ca2b1b5 100644 --- a/test/controller_test.rb +++ b/test/controller_test.rb @@ -40,6 +40,11 @@ class GearedPagination::ControllerTest < ActionController::TestCase assert_nil response.headers["Link"] end + test "works in both full and api only applications" do + assert_includes ActionController::Base.ancestors, GearedPagination::Controller + assert_includes ActionController::API.ancestors, GearedPagination::Controller + end + private def etag_for(*keys) %(W/"#{ActiveSupport::Digest.hexdigest(ActiveSupport::Cache.expand_cache_key(keys))}")