From 8e1c80cd27aab9814a31a71b2e389fd27100f647 Mon Sep 17 00:00:00 2001 From: Oleh Fedorenko Date: Thu, 28 Jul 2022 11:53:10 +0000 Subject: [PATCH] Refs #35274 - Fix tests, simplify finder --- app/controllers/concerns/application_shared.rb | 5 +---- app/controllers/hosts_controller.rb | 2 ++ app/helpers/selectable_columns_helper.rb | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/concerns/application_shared.rb b/app/controllers/concerns/application_shared.rb index 64c61de84c0..e6449bfa662 100644 --- a/app/controllers/concerns/application_shared.rb +++ b/app/controllers/concerns/application_shared.rb @@ -142,9 +142,6 @@ def find_session_taxonomy(taxonomy, user) end def find_selected_columns - instance_variable_set( - '@selected_columns', - Foreman::SelectableColumns::Storage.selected_by(User.current, controller_name) - ) + @selected_columns = Foreman::SelectableColumns::Storage.selected_by(User.current, controller_name) end end diff --git a/app/controllers/hosts_controller.rb b/app/controllers/hosts_controller.rb index 6e7b4206250..9af3fb72a1d 100644 --- a/app/controllers/hosts_controller.rb +++ b/app/controllers/hosts_controller.rb @@ -33,6 +33,8 @@ class HostsController < ApplicationController before_action :set_host_type, :only => [:update] before_action :find_multiple, :only => MULTIPLE_ACTIONS before_action :validate_power_action, :only => :update_multiple_power_state + # index action is already included in ApplicationController + before_action(:only => SEARCHABLE_ACTIONS.without('index')) { find_selected_columns } helper :hosts, :reports, :interfaces diff --git a/app/helpers/selectable_columns_helper.rb b/app/helpers/selectable_columns_helper.rb index 0266ec88008..d554cf2d025 100644 --- a/app/helpers/selectable_columns_helper.rb +++ b/app/helpers/selectable_columns_helper.rb @@ -29,7 +29,7 @@ def render_selected_column_tds(record) def attr_from_callbacks(callbacks, subject) return unless callbacks - callbacks.reduce([]) { |m, (k, v)| m << "#{k}=\"#{instance_exec(subject, &v)}\"" } + callbacks.map { |(k, v)| "#{k}=\"#{instance_exec(subject, &v)}\"" } .join(' ') .html_safe end