From 21fe2b7c02453ce569325d5aa8e29c5c4f98bc22 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Fri, 18 Oct 2019 18:44:49 -0300 Subject: [PATCH] 15716: Don't include modules on .rake files The file symbols.rake used to include CurrentApiClient, making its methods available to the entire app as Object class methods. This made several tests to pass successfully while the code they exercised really fail on production and development environments. The solution is to make a helper class that works as a namespace of those methods. This commit exposes 41 failing tests. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- services/api/lib/tasks/symbols.rake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/api/lib/tasks/symbols.rake b/services/api/lib/tasks/symbols.rake index a2e6df8b58..dc9ed461dd 100644 --- a/services/api/lib/tasks/symbols.rake +++ b/services/api/lib/tasks/symbols.rake @@ -4,7 +4,12 @@ require 'current_api_client' -include CurrentApiClient +# This is needed instead of just including CurrentApiClient so that its +# methods don't get imported as Object's class methods; this is a problem because +# the methods would be imported only on test environment. See #15716 for more info. +class CurrentApiClientHelper + extend CurrentApiClient +end def has_symbols? x if x.is_a? Hash @@ -83,7 +88,7 @@ namespace :symbols do Node, PipelineInstance, PipelineTemplate, Repository, Specimen, Trait, User, VirtualMachine, Workflow].each do |klass| - act_as_system_user do + CurrentApiClientHelper.act_as_system_user do klass.all.each do |c| check_for_serialized_symbols c end @@ -99,7 +104,7 @@ namespace :symbols do Node, PipelineInstance, PipelineTemplate, Repository, Specimen, Trait, User, VirtualMachine, Workflow].each do |klass| - act_as_system_user do + CurrentApiClientHelper.act_as_system_user do klass.all.each do |c| stringify_serialized_symbols c end -- 2.30.2