Skip to content

Commit

Permalink
Fixes #37629 - Support zeitwerk loader
Browse files Browse the repository at this point in the history
  • Loading branch information
ShimShtein authored and ekohl committed Sep 11, 2024
1 parent 542d163 commit 798f642
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def self.subscribe
end

def plan(job_invocation, host, *_args)
return unless ::Helpers::JobHelper.correct_feature?(job_invocation, 'leapp_preupgrade') ||
::Helpers::JobHelper.correct_feature?(job_invocation, 'leapp_remediation_plan')
return unless ::JobHelper.correct_feature?(job_invocation, 'leapp_preupgrade') ||
::JobHelper.correct_feature?(job_invocation, 'leapp_remediation_plan')

plan_self(host_id: host.id, job_invocation_id: job_invocation.id)
end
Expand Down
14 changes: 6 additions & 8 deletions app/lib/helpers/job_helper.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# frozen_string_literal: true

module Helpers
module JobHelper
class << self
def correct_feature?(job_invocation, feature)
RemoteExecutionFeature.where(job_template_id: job_invocation.pattern_template_invocations
.first
.template_id, label: feature).any?
end
module JobHelper
class << self
def correct_feature?(job_invocation, feature)
RemoteExecutionFeature.where(job_template_id: job_invocation.pattern_template_invocations
.first
.template_id, label: feature).any?
end
end
end
7 changes: 5 additions & 2 deletions lib/foreman_leapp/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ module ForemanLeapp
class Engine < ::Rails::Engine
engine_name 'foreman_leapp'

config.eager_load_paths += Dir["#{config.root}/app/controllers/api/v2/concerns"]
config.eager_load_paths += Dir["#{config.root}/app/lib/helpers"]

config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
config.autoload_paths += Dir["#{config.root}/app/controllers/api/v2/concerns"]
config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
Expand Down Expand Up @@ -36,8 +39,8 @@ class Engine < ::Rails::Engine
name: _('Leapp preupgrade report'),
id: 'leapp_preupgrade_report',
onlyif: proc { |subject|
::Helpers::JobHelper.correct_feature?(subject, 'leapp_preupgrade') ||
::Helpers::JobHelper.correct_feature?(subject, 'leapp_remediation_plan')
::JobHelper.correct_feature?(subject, 'leapp_preupgrade') ||
::JobHelper.correct_feature?(subject, 'leapp_remediation_plan')
}
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/helpers/job_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Helpers
class JobHelperTest < ActionView::TestCase
let(:helper) { ::Helpers::JobHelper }
let(:helper) { ::JobHelper }

let(:job_template) do
FactoryBot.create(:job_template, template: 'echo "1"', job_category: 'leapp',
Expand Down

0 comments on commit 798f642

Please sign in to comment.