Skip to content

Commit

Permalink
fixes error during settings rendering because method is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
laugmanuel committed May 17, 2024
1 parent 0973c3e commit 350d757
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module ForemanRescue
module ProvisioningTemplateExtensions
def self.templates_by_kind(kind)
def templates_by_kind(kind)
template_kind = TemplateKind.find_by(name: kind)
ProvisioningTemplate.where(:template_kind => template_kind).pluck(:name, :name).to_h
end
Expand Down
2 changes: 1 addition & 1 deletion lib/foreman_rescue/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Engine < ::Rails::Engine
Host::Managed.prepend ForemanRescue::HostExtensions
HostsHelper.prepend ForemanRescue::HostsHelperExtensions
Nic::Managed.prepend ForemanRescue::Orchestration::TFTP
ProvisioningTemplate.prepend ForemanRescue::ProvisioningTemplateExtensions
ProvisioningTemplate.singleton_class.prepend ForemanRescue::ProvisioningTemplateExtensions
rescue StandardError => e
Rails.logger.warn "ForemanRescue: skipping engine hook (#{e})"
end
Expand Down
26 changes: 26 additions & 0 deletions test/models/provisioning_template_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

require 'test_plugin_helper'

class ProvisioningHostTest < ActiveSupport::TestCase
setup do
User.current = FactoryBot.build(:user, :admin)
disable_orchestration
end

context 'provisioning template query' do
context 'with type PXELinux' do
let(:type) do
'PXELinux'
end

test 'should return templates' do
templates = ProvisioningTemplate.templates_by_kind(type)

assert_includes templates, "PXE Default Menu"

Check failure on line 20 in test/models/provisioning_template_test.rb

View workflow job for this annotation

GitHub Actions / rubocop / Rubocop

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
assert_includes templates, "PXELinux default local boot"

Check failure on line 21 in test/models/provisioning_template_test.rb

View workflow job for this annotation

GitHub Actions / rubocop / Rubocop

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
assert_includes templates, "PXELinux global default"

Check failure on line 22 in test/models/provisioning_template_test.rb

View workflow job for this annotation

GitHub Actions / rubocop / Rubocop

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
end
end
end
end

0 comments on commit 350d757

Please sign in to comment.