Skip to content

Commit

Permalink
Fixes #37849 - Support Rails 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ofedoren authored and adamruzicka committed Nov 6, 2024
1 parent 9343b99 commit 244fd5e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
11 changes: 6 additions & 5 deletions app/services/foreman_openscap/lookup_key_overrider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ def override

def handle_config_not_available(config)
return true if config.available?
@policy.errors[:deploy_by] <<
@policy.errors.add(:deploy_by,
_("%{type} was selected to deploy policy to clients, but %{type} is not available. Are you missing a plugin?") %
{ :type => config.type.to_s.camelize }
)
false
end

def handle_config_item_not_available(config, item)
return true if item
err = _("Required %{msg_name} %{class} was not found, please ensure it is imported first.") %
{ :class => config.config_item_name, :msg_name => config.msg_name }
@policy.errors[:base] << err
@policy.errors.add(:base, err)
false
end

Expand All @@ -34,7 +35,7 @@ def handle_missing_lookup_keys(config, key_names)
err = _("The following %{key_name} were missing for %{item_name}: %{key_names}. Make sure they are imported before proceeding.") %
{ :key_name => config.lookup_key_plural_name, :key_names => key_names, :item_name => config.config_item_name }

@policy.errors[:base] << err
@policy.errors.add(:base, err)
false
end

Expand All @@ -52,9 +53,9 @@ def handle_policies_param_override(config, param)

def handle_param_override(config, param)
if param.changed? && !param.save
@policy.errors[:base] <<
@policy.errors.add(:base,
_('Failed to save when overriding parameters for %{config_tool}, cause: %{errors}') %
{ :config_tool => config.type, :errors => param.errors.full_messages.join(', ') }
{ :config_tool => config.type, :errors => param.errors.full_messages.join(', ') })
return false
end
true
Expand Down
25 changes: 9 additions & 16 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

namespace :api, :defaults => { :format => 'json' } do
scope "(:apiv)", :module => :v2, :defaults => { :apiv => 'v2' },
:apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
:apiv => /v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
namespace :compliance do
resources :scap_contents, :except => %i[new edit] do
member do
Expand Down Expand Up @@ -95,6 +95,14 @@
post 'arf_reports/:cname/:policy_id/:date', \
:constraints => { :cname => /[^\/]+/ }, :to => 'arf_reports#create'
end

constraints(:id => %r{[^\/]+}) do
resources :hosts, :except => [:new, :edit] do
member do
get :policies_enc
end
end
end
end
end
end
Expand All @@ -113,19 +121,4 @@
post 'openscap_proxy_changed'
end
end

namespace :api do
scope "(:api_version)", :module => :v2,
:defaults => { :api_version => 'v2' },
:api_version => /v2/,
:constraints => ApiConstraints.new(:version => 2, :default => true) do
constraints(:id => %r{[^\/]+}) do
resources :hosts, :only => [] do
member do
get :policies_enc
end
end
end
end
end
end
1 change: 0 additions & 1 deletion test/functional/openscap_proxies_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'test_plugin_helper'
require 'application_helper'

class OpenscapProxiesControllerTest < ActionController::TestCase
include ActionView::Helpers::DateHelper
Expand Down

0 comments on commit 244fd5e

Please sign in to comment.