diff --git a/lib/dynflow/serializers/abstract.rb b/lib/dynflow/serializers/abstract.rb index 8960c276..81d4af1f 100644 --- a/lib/dynflow/serializers/abstract.rb +++ b/lib/dynflow/serializers/abstract.rb @@ -7,7 +7,7 @@ module Serializers # the {Dynflow::Action}'s #plan method when the plan is executed. class Abstract - attr_reader :args, :serialized_args, :serialized_kwargs + attr_reader :args, :kwargs, :serialized_args, :serialized_kwargs # @param args [Array] arguments to be serialized # @param serialized_args [nil, Array] arguments in their serialized form diff --git a/lib/dynflow/world.rb b/lib/dynflow/world.rb index 50cac937..7f3e54cb 100644 --- a/lib/dynflow/world.rb +++ b/lib/dynflow/world.rb @@ -193,7 +193,7 @@ def delay(action_class, delay_options, *args, **kwargs) delay_with_options(action_class: action_class, args: args, kwargs: kwargs, delay_options: delay_options) end - def delay_with_options(action_class:, args:, kwargs:, delay_options:, id: nil, caller_action: nil) + def delay_with_options(action_class:, args:, kwargs: {}, delay_options:, id: nil, caller_action: nil) raise 'No action_class given' if action_class.nil? execution_plan = ExecutionPlan.new(self, id) execution_plan.delay(caller_action, action_class, delay_options, *args, **kwargs) diff --git a/test/future_execution_test.rb b/test/future_execution_test.rb index bea1c1b6..1d5bb9be 100644 --- a/test/future_execution_test.rb +++ b/test/future_execution_test.rb @@ -134,26 +134,29 @@ module FutureExecutionTest describe 'serializers' do let(:args) { %w(arg1 arg2) } - let(:serialized_serializer) { Dynflow::Serializers::Noop.new(nil, args) } - let(:deserialized_serializer) { Dynflow::Serializers::Noop.new(args, nil) } + let(:kwargs) { { foo: 'bar' } } + let(:serialized_serializer) { Dynflow::Serializers::Noop.new(nil, args, nil, [['foo', 'bar']]) } + let(:deserialized_serializer) { Dynflow::Serializers::Noop.new(args, nil, kwargs, nil) } let(:save_and_load) do ->(thing) { MultiJson.load(MultiJson.dump(thing)) } end let(:simulated_use) do - lambda do |serializer_class, input| - serializer = serializer_class.new(input) + lambda do |serializer_class, input, kwargs| + serializer = serializer_class.new(input, nil, kwargs) serializer.perform_serialization! serialized_args = save_and_load.call(serializer.serialized_args) - serializer = serializer_class.new(nil, serialized_args) + serialized_kwargs = save_and_load.call(serializer.serialized_kwargs) + serializer = serializer_class.new(nil, serialized_args, nil, serialized_kwargs) serializer.perform_deserialization! - serializer.args + [serializer.args, serializer.kwargs] end end it 'noop serializer [de]serializes correctly for simple types' do input = [1, 2.0, 'three', ['four-1', 'four-2'], { 'five' => 5 }] - _(simulated_use.call(Dynflow::Serializers::Noop, input)).must_equal input + kwargs = { foo: 'bar' } + _(simulated_use.call(Dynflow::Serializers::Noop, input, kwargs)).must_equal [input, kwargs] end it 'args! raises if not deserialized' do @@ -179,7 +182,7 @@ module FutureExecutionTest describe 'delayed plan' do let(:args) { %w(arg1 arg2) } - let(:serializer) { Dynflow::Serializers::Noop.new(nil, args) } + let(:serializer) { Dynflow::Serializers::Noop.new(nil, args, nil, []) } let(:delayed_plan) do Dynflow::DelayedPlan.new(Dynflow::World.allocate, 'an uuid', nil, nil, serializer, false) end