From 39be3cb619cee0c6e84d9cb163a7b53adde35d58 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Sat, 18 Feb 2023 12:13:41 +0100 Subject: [PATCH] DEV: fixes spec failing with ruby 3.2.1 (#20356) The error was: ``` Failures: 1) Chat::Endpoint.call(service, &block) when using the on_failed_contract action when the service contract does not fail does not run the provided block Failure/Error: subject(:endpoint) { described_class.call(service, controller, &actions_block) } NoMethodError: private method `run' called for #nil}, @context=#]>> # ./plugins/chat/app/services/base.rb:305:in `call' # ./plugins/chat/app/helpers/with_service_helper.rb:20:in `run_service' # ./plugins/chat/lib/endpoint.rb:76:in `call' # ./plugins/chat/lib/endpoint.rb:70:in `call' # ./plugins/chat/spec/lib/endpoint_spec.rb:80:in `block (3 levels) in
' # ./plugins/chat/spec/lib/endpoint_spec.rb:198:in `block (5 levels) in
' # ./spec/rails_helper.rb:358:in `block (2 levels) in ' ``` --- plugins/chat/app/services/base.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/chat/app/services/base.rb b/plugins/chat/app/services/base.rb index 4123d1b3537..e301d1041bf 100644 --- a/plugins/chat/app/services/base.rb +++ b/plugins/chat/app/services/base.rb @@ -407,18 +407,19 @@ module Chat @context = Context.build(initial_context.merge(__steps__: self.class.steps)) end - private - + # @!visibility private def run run! rescue Failure => exception raise if context.object_id != exception.context.object_id end + # @!visibility private def run! self.class.steps.each { |step| step.call(self, context) } end + # @!visibility private def fail!(message) step_name = caller_locations(1, 1)[0].label context["result.step.#{step_name}"].fail(error: message)