You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LightService::LocalizationAdapter methods success and failure are called with wrong number of arguments
light-service-0.19.0/lib/light-service/localization_adapter.rb:3:in `failure': wrong number of arguments (given 3, expected 2) (ArgumentError)
Code to reproduce this issue
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'light-service'
end
######################################################
# Patch Array and String to support .blank? and .underscore methods
######################################################
class Array
def blank?
empty?
end
end
class String
def underscore
self.gsub(/::/, '/')
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.tr("-", "_")
.downcase
end
end
###############################################
###########
# Actual code
##########
class TestOrganizer
extend LightService::Organizer
def self.call(order)
with(:order => order).reduce(
TestAction,
)
end
end
class TestAction
extend LightService::Action
expects :order
promises :result
executed do |context|
raise 'Exception'
rescue => e
context.fail_and_return!("Error: #{e.message}")
end
end
TestOrganizer.call(1)
What's wrong in code
localization_adapter method is calling localization adapter based on condition
Module.const_defined?('I18n') is always true when we include activesupport and never use LocalizationAdapter.new. If we don't use activesupport then LocalizationAdapter.new is called.
Code is calling success and failure methods with three arguements
Problem
LightService::LocalizationAdapter
methodssuccess
andfailure
are called with wrong number of argumentsCode to reproduce this issue
What's wrong in code
localization_adapter
method is calling localization adapter based on conditionlight-service/lib/light-service/configuration.rb
Lines 11 to 17 in bc5dcc0
Module.const_defined?('I18n')
is always true when we includeactivesupport
and never useLocalizationAdapter.new
. If we don't useactivesupport
thenLocalizationAdapter.new
is called.Code is calling
success
andfailure
methods with three arguementslight-service/lib/light-service/context.rb
Lines 67 to 69 in 7326b3b
light-service/lib/light-service/context.rb
Lines 84 to 86 in 7326b3b
However,
LocalizationAdapter.new
has methods with two argumentslight-service/lib/light-service/localization_adapter.rb
Lines 2 to 6 in bc5dcc0
light-service/lib/light-service/localization_adapter.rb
Lines 8 to 12 in bc5dcc0
Error brought in by #238
The text was updated successfully, but these errors were encountered: