diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-02-09 14:24:55 -0500 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-02-14 13:10:07 -0500 |
commit | ec686a471e0a54194fc9ec72e639785606597704 (patch) | |
tree | 51cdf085e1346e11ef2ae5b47f989dd751da7ff3 /activejob/test | |
parent | 3785a5729959a838bb13f2d298a59e12e1844f74 (diff) | |
download | rails-ec686a471e0a54194fc9ec72e639785606597704.tar.gz rails-ec686a471e0a54194fc9ec72e639785606597704.tar.bz2 rails-ec686a471e0a54194fc9ec72e639785606597704.zip |
Simplify the implementation of custom serialziers
Right now it is only possible to define serializers globally so we don't
need to use a class attribute in the job class.
Diffstat (limited to 'activejob/test')
-rw-r--r-- | activejob/test/cases/serializers_test.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/activejob/test/cases/serializers_test.rb b/activejob/test/cases/serializers_test.rb index 90d4155b3b..3b526c932b 100644 --- a/activejob/test/cases/serializers_test.rb +++ b/activejob/test/cases/serializers_test.rb @@ -36,7 +36,11 @@ class SerializersTest < ActiveSupport::TestCase setup do @value_object = DummyValueObject.new 123 - ActiveJob::Base._additional_serializers = [] + @original_serializers = ActiveJob::Serializers.serializers + end + + teardown do + ActiveJob::Serializers._additional_serializers = @original_serializers end test "can't serialize unknown object" do @@ -51,14 +55,14 @@ class SerializersTest < ActiveSupport::TestCase end test "adds new serializer" do - ActiveJob::Base.add_serializers DummySerializer - assert ActiveJob::Base.serializers.include?(DummySerializer) + ActiveJob::Serializers.add_serializers DummySerializer + assert ActiveJob::Serializers.serializers.include?(DummySerializer) end test "can't add serializer with the same key twice" do - ActiveJob::Base.add_serializers DummySerializer + ActiveJob::Serializers.add_serializers DummySerializer assert_raises ArgumentError do - ActiveJob::Base.add_serializers DummySerializer + ActiveJob::Serializers.add_serializers DummySerializer end end end |