From 3cc93de6ad58ee306b906a3d979b46276900711a Mon Sep 17 00:00:00 2001 From: Yuji Yaginuma Date: Thu, 15 Feb 2018 15:46:42 +0900 Subject: Fix custome serializer setting The serializer should be set up in `after_initialize` so that it work properly even if the user specifies serializer with initializers. Also, since `custom_serializers` is `Array`, it needs to be flattened before setting the value. --- railties/test/application/configuration_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'railties/test/application') diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 236d73d5fd..caadae3136 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -1940,6 +1940,18 @@ module ApplicationTests assert_equal Digest::SHA1, ActiveSupport::Digest.hash_digest_class end + test "custom serializers should be able to set via config.active_job.custom_serializers in an initializer" do + class ::DummySerializer < ActiveJob::Serializers::ObjectSerializer; end + + app_file "config/initializers/custom_serializers.rb", <<-RUBY + Rails.application.config.active_job.custom_serializers << DummySerializer + RUBY + + app "development" + + assert_includes ActiveJob::Serializers.serializers, DummySerializer + end + private def force_lazy_load_hooks yield # Tasty clarifying sugar, homie! We only need to reference a constant to load it. -- cgit v1.2.3