From 3c27f6084a160e561069dbab2b88a86fc14e7ec4 Mon Sep 17 00:00:00 2001 From: Vincent Rolea <3525369+virolea@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:26:15 +0200 Subject: [PATCH] Add configurable parent class --- app/controllers/rosetta/application_controller.rb | 2 +- lib/rosetta/configuration.rb | 2 ++ test/integration/translations_test.rb | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/rosetta/application_controller.rb b/app/controllers/rosetta/application_controller.rb index 54ca887..0381cfb 100644 --- a/app/controllers/rosetta/application_controller.rb +++ b/app/controllers/rosetta/application_controller.rb @@ -1,5 +1,5 @@ module Rosetta - class ApplicationController < ActionController::Base + class ApplicationController < Rosetta.config.parent_controller_class.constantize include Pagy::Backend end end diff --git a/lib/rosetta/configuration.rb b/lib/rosetta/configuration.rb index 02ff449..d2fcfea 100644 --- a/lib/rosetta/configuration.rb +++ b/lib/rosetta/configuration.rb @@ -1,11 +1,13 @@ module Rosetta class Configuration attr_reader :default_locale + attr_accessor :parent_controller_class DefaultLocale = Struct.new(:name, :code) def initialize set_default_locale(name: "English", code: "en") + @parent_controller_class = "ActionController::Base" end def set_default_locale(name:, code:) diff --git a/test/integration/translations_test.rb b/test/integration/translations_test.rb index 55b1d68..c5a9350 100644 --- a/test/integration/translations_test.rb +++ b/test/integration/translations_test.rb @@ -23,6 +23,7 @@ class TranslationsTest < ActionDispatch::IntegrationTest # Load up the keys get root_path(locale: locale.code) + sleep 1 key = Rosetta::TranslationKey.find_by(value: "Available locales") # Create the translation