From 1302f88038e61e0474e16c6d3cb8f8782b6f43a3 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Wed, 6 Jan 2021 15:55:30 -0500 Subject: [PATCH 1/5] Split Log submenu to it's own controller to simplify Policy Controller Pre work for https://github.com/ManageIQ/manageiq-ui-classic/pull/7401 --- app/controllers/miq_policy_controller.rb | 44 --------- app/controllers/miq_policy_log_controller.rb | 98 ++++++++++++++++++++ app/presenters/menu/default_menu.rb | 2 +- app/views/miq_policy/show.html.haml | 3 - config/routes.rb | 11 +++ 5 files changed, 110 insertions(+), 48 deletions(-) create mode 100644 app/controllers/miq_policy_log_controller.rb delete mode 100644 app/views/miq_policy/show.html.haml diff --git a/app/controllers/miq_policy_controller.rb b/app/controllers/miq_policy_controller.rb index 6f6f4409de5..c589a341957 100644 --- a/app/controllers/miq_policy_controller.rb +++ b/app/controllers/miq_policy_controller.rb @@ -26,10 +26,6 @@ def index def button @edit = session[:edit] # Restore @edit for adv search box @refresh_div = "main_div" # Default div for button.rjs to refresh - if params[:pressed] == "refresh_log" - refresh_log - return - end unless @refresh_partial # if no button handler ran, show not implemented msg add_flash(_("Button not yet implemented"), :error) @@ -105,41 +101,6 @@ def search end end - def log - assert_privileges('policy_log') - @breadcrumbs = [] - @log = $policy_log.contents(nil, 1000) - add_flash(_("Logs for this %{product} Server are not available for viewing") % {:product => Vmdb::Appliance.PRODUCT_NAME}, :warning) if @log.blank? - @lastaction = "policy_logs" - @layout = "miq_policy_logs" - @msg_title = "Policy" - @download_action = "fetch_log" - @server_options ||= {} - @server_options[:server_id] ||= MiqServer.my_server.id - @server = MiqServer.my_server - drop_breadcrumb(:name => _("Log"), :url => "/miq_ae_policy/log") - render :action => "show" - end - - def refresh_log - assert_privileges('policy_log') - @log = $policy_log.contents(nil, 1000) - @server = MiqServer.my_server - add_flash(_("Logs for this %{product} Server are not available for viewing") % {:product => Vmdb::Appliance.PRODUCT_NAME}, :warning) if @log.blank? - replace_main_div(:partial => "layouts/log_viewer") - end - - # Send the log in text format - def fetch_log - assert_privileges('policy_log') - disable_client_cache - send_data($policy_log.contents(nil, nil), - :filename => "policy.log") - AuditEvent.success(:userid => session[:userid], - :event => "download_policy_log", - :message => "Policy log downloaded") - end - private # Get all info for the node about to be displayed @@ -398,14 +359,12 @@ def get_session_data @lastaction = session[:miq_policy_lastaction] @display = session[:miq_policy_display] @current_page = session[:miq_policy_current_page] - @server_options = session[:server_options] if session[:server_options] end def set_session_data super session[:layout] = @layout session[:miq_policy_current_page] = @current_page - session[:server_options] = @server_options end def features @@ -425,14 +384,11 @@ def breadcrumbs_options {:title => _("Control")}, menu_breadcrumb, ].compact, - :not_tree => %w[log].include?(action_name), :record_title => :description, } end def menu_breadcrumb - return nil if %w[log].include?(action_name) - {:title => _('Explorer')} end diff --git a/app/controllers/miq_policy_log_controller.rb b/app/controllers/miq_policy_log_controller.rb new file mode 100644 index 00000000000..9b85be02266 --- /dev/null +++ b/app/controllers/miq_policy_log_controller.rb @@ -0,0 +1,98 @@ +class MiqPolicyLogController < ApplicationController + before_action :check_privileges + before_action :get_session_data + after_action :cleanup_action + after_action :set_session_data + + include Mixins::GenericSessionMixin + include Mixins::BreadcrumbsMixin + + def index + flash_to_session + redirect_to(:action => 'show') + end + + # handle buttons pressed on the button bar + def button + @edit = session[:edit] # Restore @edit for adv search box + @refresh_div = "main_div" # Default div for button.rjs to refresh + if params[:pressed] == "refresh_log" + refresh_log + return + end + + unless @refresh_partial # if no button handler ran, show not implemented msg + add_flash(_("Button not yet implemented"), :error) + @refresh_partial = "layouts/flash_msg" + @refresh_div = "flash_msg_div" + end + end + + def log + assert_privileges('policy_log') + @breadcrumbs = [] + @log = $policy_log.contents(nil, 1000) + add_flash(_("Logs for this %{product} Server are not available for viewing") % {:product => Vmdb::Appliance.PRODUCT_NAME}, :warning) if @log.blank? + @lastaction = "policy_logs" + @layout = "miq_policy_logs" + @msg_title = "Policy" + @download_action = "fetch_log" + @server_options ||= {} + @server_options[:server_id] ||= MiqServer.my_server.id + @server = MiqServer.my_server + drop_breadcrumb(:name => _("Log"), :url => "/miq_ae_policy/log") + end + + def refresh_log + assert_privileges('policy_log') + @log = $policy_log.contents(nil, 1000) + @server = MiqServer.my_server + add_flash(_("Logs for this %{product} Server are not available for viewing") % {:product => Vmdb::Appliance.PRODUCT_NAME}, :warning) if @log.blank? + replace_main_div(:partial => "layouts/log_viewer") + end + + # Send the log in text format + def fetch_log + assert_privileges('policy_log') + disable_client_cache + send_data($policy_log.contents(nil, nil), + :filename => "policy.log") + AuditEvent.success(:userid => session[:userid], + :event => "download_policy_log", + :message => "Policy log downloaded") + end + + def self.table_name + @table_name = "log" + end + + private + + def get_session_data + @title = _("Policies") + @layout = "miq_policy_log" + @lastaction = session[:miq_policy_log_lastaction] + @server_options = session[:server_options] if session[:server_options] + end + + def set_session_data + super + session[:layout] = @layout + session[:server_options] = @server_options + end + + def breadcrumbs_options + { + :breadcrumbs => [ + {:title => _("Control")}, + menu_breadcrumb, + ].compact, + } + end + + def menu_breadcrumb + {:title => _('Log')} + end + + menu_section :con +end diff --git a/app/presenters/menu/default_menu.rb b/app/presenters/menu/default_menu.rb index 332656f5518..fd5b134a2f0 100644 --- a/app/presenters/menu/default_menu.rb +++ b/app/presenters/menu/default_menu.rb @@ -230,7 +230,7 @@ def control_menu_section Menu::Item.new('miq_alert', N_('Alerts'), 'miq_alert', {:feature => 'miq_alert', :any => true}, '/miq_alert/explorer'), Menu::Item.new('miq_policy_rsop', N_('Simulation'), 'policy_simulation', {:feature => 'policy_simulation'}, '/miq_policy_rsop'), Menu::Item.new('miq_policy_export', N_('Import / Export'), 'policy_import_export', {:feature => 'policy_import_export'}, '/miq_policy/export'), - Menu::Item.new('miq_policy_logs', N_('Log'), 'policy_log', {:feature => 'policy_log'}, '/miq_policy/log') + Menu::Item.new('miq_policy_logs', N_('Log'), 'policy_log', {:feature => 'policy_log'}, '/miq_policy_log') ]) end diff --git a/app/views/miq_policy/show.html.haml b/app/views/miq_policy/show.html.haml deleted file mode 100644 index 29693c622cf..00000000000 --- a/app/views/miq_policy/show.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -#main_div - - if @lastaction == "policy_logs" - = render :partial => "layouts/log_viewer" diff --git a/config/routes.rb b/config/routes.rb index 998dbe44055..5e3df24b4f5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2091,6 +2091,7 @@ explorer fetch_log log + rsop ), :post => %w( button @@ -2109,6 +2110,16 @@ x_post }, + :miq_policy_log => { + :get => %w( + fetch_log + log + ), + :post => %w( + button + ) + }, + :miq_policy_rsop => { :post => %w( rsop From 482cd7dcd2f39d7d2b7ab3090cf427672a2c0eb4 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Wed, 6 Jan 2021 16:38:11 -0500 Subject: [PATCH 2/5] Fixed/Adjusted spec tests. - And made changes to make `/miq_policy/log` url working Pre work for https://github.com/ManageIQ/manageiq-ui-classic/pull/7401 --- app/controllers/miq_policy_log_controller.rb | 31 ++++++------ app/views/miq_policy_log/index.html.haml | 3 ++ config/routes.rb | 7 +-- .../controllers/miq_policy_controller_spec.rb | 33 +------------ .../miq_policy_log_controller_spec.rb | 48 +++++++++++++++++++ spec/routing/miq_policy_log_routing_spec.rb | 23 +++++++++ spec/routing/miq_policy_routing_spec.rb | 12 ----- 7 files changed, 93 insertions(+), 64 deletions(-) create mode 100644 app/views/miq_policy_log/index.html.haml create mode 100644 spec/controllers/miq_policy_log_controller_spec.rb create mode 100644 spec/routing/miq_policy_log_routing_spec.rb diff --git a/app/controllers/miq_policy_log_controller.rb b/app/controllers/miq_policy_log_controller.rb index 9b85be02266..73c0d03020b 100644 --- a/app/controllers/miq_policy_log_controller.rb +++ b/app/controllers/miq_policy_log_controller.rb @@ -9,7 +9,18 @@ class MiqPolicyLogController < ApplicationController def index flash_to_session - redirect_to(:action => 'show') + assert_privileges('policy_log') + @breadcrumbs = [] + @log = $policy_log.contents(nil, 1000) + add_flash(_("Logs for this %{product} Server are not available for viewing") % {:product => Vmdb::Appliance.PRODUCT_NAME}, :warning) if @log.blank? + @lastaction = "policy_logs" + @layout = "miq_policy_logs" + @msg_title = "Policy" + @download_action = "fetch_log" + @server_options ||= {} + @server_options[:server_id] ||= MiqServer.my_server.id + @server = MiqServer.my_server + drop_breadcrumb(:name => _("Log"), :url => "/miq_ae_policy/log") end # handle buttons pressed on the button bar @@ -28,21 +39,6 @@ def button end end - def log - assert_privileges('policy_log') - @breadcrumbs = [] - @log = $policy_log.contents(nil, 1000) - add_flash(_("Logs for this %{product} Server are not available for viewing") % {:product => Vmdb::Appliance.PRODUCT_NAME}, :warning) if @log.blank? - @lastaction = "policy_logs" - @layout = "miq_policy_logs" - @msg_title = "Policy" - @download_action = "fetch_log" - @server_options ||= {} - @server_options[:server_id] ||= MiqServer.my_server.id - @server = MiqServer.my_server - drop_breadcrumb(:name => _("Log"), :url => "/miq_ae_policy/log") - end - def refresh_log assert_privileges('policy_log') @log = $policy_log.contents(nil, 1000) @@ -69,7 +65,7 @@ def self.table_name private def get_session_data - @title = _("Policies") + @title = _("Log") @layout = "miq_policy_log" @lastaction = session[:miq_policy_log_lastaction] @server_options = session[:server_options] if session[:server_options] @@ -79,6 +75,7 @@ def set_session_data super session[:layout] = @layout session[:server_options] = @server_options + session[:miq_policy_log_lastaction] = @lastaction end def breadcrumbs_options diff --git a/app/views/miq_policy_log/index.html.haml b/app/views/miq_policy_log/index.html.haml new file mode 100644 index 00000000000..29693c622cf --- /dev/null +++ b/app/views/miq_policy_log/index.html.haml @@ -0,0 +1,3 @@ +#main_div + - if @lastaction == "policy_logs" + = render :partial => "layouts/log_viewer" diff --git a/config/routes.rb b/config/routes.rb index 5e3df24b4f5..38b8356f8ae 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2089,8 +2089,6 @@ :miq_policy => { :get => %w( explorer - fetch_log - log rsop ), :post => %w( @@ -2101,6 +2099,10 @@ policy_field_changed quick_search reload + rsop + rsop_option_changed + rsop_show_options + rsop_toggle tree_autoload tree_select wait_for_task @@ -2113,7 +2115,6 @@ :miq_policy_log => { :get => %w( fetch_log - log ), :post => %w( button diff --git a/spec/controllers/miq_policy_controller_spec.rb b/spec/controllers/miq_policy_controller_spec.rb index 81d320e6221..b7eb3cbe432 100644 --- a/spec/controllers/miq_policy_controller_spec.rb +++ b/spec/controllers/miq_policy_controller_spec.rb @@ -129,15 +129,13 @@ let(:lastaction) { 'lastaction' } let(:display) { 'display' } let(:current_page) { 'current_page' } - let(:server_options) { 'server options' } - let(:layout) { 'miq_policy' } + let(:layout) { 'layout' } describe '#get_session_data' do it "Sets variables correctly" do allow(controller).to receive(:session).and_return(:miq_policy_lastaction => lastaction, :miq_policy_display => display, :miq_policy_current_page => current_page, - :server_options => server_options, :layout => layout) allow(controller).to receive(:alert_build_pulldowns).and_return(nil) controller.send(:get_session_data) @@ -147,7 +145,6 @@ expect(controller.instance_variable_get(:@lastaction)).to eq(lastaction) expect(controller.instance_variable_get(:@display)).to eq(display) expect(controller.instance_variable_get(:@current_page)).to eq(current_page) - expect(controller.instance_variable_get(:@server_options)).to eq(server_options) end end @@ -157,38 +154,16 @@ controller.instance_variable_set(:@display, display) controller.instance_variable_set(:@current_page, current_page) controller.instance_variable_set(:@layout, layout) - controller.instance_variable_set(:@server_options, server_options) controller.send(:set_session_data) expect(controller.session[:miq_policy_lastaction]).to eq(lastaction) expect(controller.session[:miq_policy_display]).to eq(display) expect(controller.session[:miq_policy_current_page]).to eq(current_page) expect(controller.session[:layout]).to eq(layout) - expect(controller.session[:server_options]).to eq(server_options) end end end - # context 'removing conditions' do - # let(:condition) { FactoryBot.create(:condition) } - # let(:policy) { FactoryBot.create(:miq_policy, :name => "test_policy", :conditions => [condition]) } - # - # before do - # login_as FactoryBot.create(:user, :features => 'condition_remove') - # controller.params = {:policy_id => policy.id, :id => condition.id} - # controller.instance_variable_set(:@sb, {}) - # allow(controller).to receive(:x_node).and_return("pp_pp-1r36_p-#{policy.id}_co-#{condition.id}") - # end - # - # it 'removes condition successfully' do - # expect(controller).to receive(:replace_right_cell) - # controller.send(:condition_remove) - # policy.reload - # expect(assigns(:flash_array).first[:message]).to include("has been removed from Policy") - # expect(policy.conditions).to eq([]) - # end - # end - describe "breadcrumbs" do before { EvmSpecHelper.local_miq_server } @@ -197,11 +172,5 @@ expect(controller.data_for_breadcrumbs.pluck(:title)[1]).to eq("Explorer") end - - it "shows 'log' on log screen" do - get :log - - expect(controller.data_for_breadcrumbs.pluck(:title)[1]).to eq("Log") - end end end diff --git a/spec/controllers/miq_policy_log_controller_spec.rb b/spec/controllers/miq_policy_log_controller_spec.rb new file mode 100644 index 00000000000..540cb62902e --- /dev/null +++ b/spec/controllers/miq_policy_log_controller_spec.rb @@ -0,0 +1,48 @@ +describe MiqPolicyLogController do + before do + stub_user(:features => :all) + end + + context "GenericSessionMixin" do + let(:lastaction) { 'lastaction' } + let(:server_options) { 'server options' } + let(:layout) { 'miq_policy_log' } + + describe '#get_session_data' do + it "Sets variables correctly" do + allow(controller).to receive(:session).and_return(:miq_policy_log_lastaction => lastaction, + :server_options => server_options, + :layout => layout) + controller.send(:get_session_data) + + expect(controller.instance_variable_get(:@title)).to eq("Log") + expect(controller.instance_variable_get(:@layout)).to eq(layout) + expect(controller.instance_variable_get(:@lastaction)).to eq(lastaction) + expect(controller.instance_variable_get(:@server_options)).to eq(server_options) + end + end + + describe '#set_session_data' do + it "Sets session correctly" do + controller.instance_variable_set(:@lastaction, lastaction) + controller.instance_variable_set(:@layout, layout) + controller.instance_variable_set(:@server_options, server_options) + controller.send(:set_session_data) + + expect(controller.session[:miq_policy_log_lastaction]).to eq(lastaction) + expect(controller.session[:layout]).to eq(layout) + expect(controller.session[:server_options]).to eq(server_options) + end + end + end + + describe "breadcrumbs" do + before { EvmSpecHelper.local_miq_server } + + it "shows 'log' on log screen" do + get :index + + expect(controller.data_for_breadcrumbs.pluck(:title)[1]).to eq("Log") + end + end +end diff --git a/spec/routing/miq_policy_log_routing_spec.rb b/spec/routing/miq_policy_log_routing_spec.rb new file mode 100644 index 00000000000..e721cfafbad --- /dev/null +++ b/spec/routing/miq_policy_log_routing_spec.rb @@ -0,0 +1,23 @@ +require 'routing/shared_examples' + +describe 'routes for MiqPolicyLogController' do + let(:controller_name) { 'miq_policy_log' } + + describe '#button' do + it 'routes with POST' do + expect(post("/#{controller_name}/button")).to route_to("#{controller_name}#button") + end + end + + describe '#fetch_log' do + it 'routes with GET' do + expect(get("/#{controller_name}/fetch_log")).to route_to("#{controller_name}#fetch_log") + end + end + + describe '#index' do + it 'routes with GET' do + expect(get("/#{controller_name}")).to route_to("#{controller_name}#index") + end + end +end diff --git a/spec/routing/miq_policy_routing_spec.rb b/spec/routing/miq_policy_routing_spec.rb index fa0a84ebb2d..6a0ea7c480e 100644 --- a/spec/routing/miq_policy_routing_spec.rb +++ b/spec/routing/miq_policy_routing_spec.rb @@ -11,24 +11,12 @@ end end - describe '#fetch_log' do - it 'routes with GET' do - expect(get("/#{controller_name}/fetch_log")).to route_to("#{controller_name}#fetch_log") - end - end - describe '#index' do it 'routes with GET' do expect(get("/#{controller_name}")).to route_to("#{controller_name}#index") end end - describe '#log' do - it 'routes with GET' do - expect(get("/#{controller_name}/log")).to route_to("#{controller_name}#log") - end - end - describe '#miq_policy_edit' do it 'routes with POST' do expect(post("/#{controller_name}/miq_policy_edit")).to route_to("#{controller_name}#miq_policy_edit") From 82dff6b9c1b85cf19f958b1ad6f7e2c71a89e906 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Thu, 7 Jan 2021 10:49:07 -0500 Subject: [PATCH 3/5] Deleted redundant and unnecessary setting of instance variables. Pre work for https://github.com/ManageIQ/manageiq-ui-classic/pull/7401 --- app/controllers/application_controller.rb | 6 ------ app/controllers/dashboard_controller.rb | 2 +- app/controllers/miq_policy_log_controller.rb | 6 ------ app/views/layouts/_log_viewer.html.haml | 3 ++- spec/controllers/miq_policy_log_controller_spec.rb | 5 ----- 5 files changed, 3 insertions(+), 19 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6c2436cd0e4..c303737314a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1614,9 +1614,6 @@ def get_global_session_data # Set @edit key default for the expression editor to use @expkey = session[:expkey] || :expression - # Get server hash, if it is in the session for supported controllers - @server_options = session[:server_options] if %w[configuration support].include?(controller_name) - # Get timelines hash, if it is in the session for the running controller @tl_options = tl_session_data @@ -1668,9 +1665,6 @@ def set_global_session_data session[:miq_exists_mode] = @exists_mode unless @exists_mode.nil? session[:last_trans_time] = Time.now - # Set server hash, if @server_options is present - session[:server_options] = @server_options - # Set timelines hash, if it is in the session for the running controller set_tl_session_data diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 4636fd36791..8f9c8541830 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -626,7 +626,7 @@ def session_reset # Clear instance vars that end up in the session @sb = @edit = @view = @settings = @lastaction = @perf_options = @assign = nil - @server_options = @pp_choices = @panels = @breadcrumbs = nil + @pp_choices = @panels = @breadcrumbs = nil end # Initialize session hash variables for the logged in user diff --git a/app/controllers/miq_policy_log_controller.rb b/app/controllers/miq_policy_log_controller.rb index 73c0d03020b..f552d53940f 100644 --- a/app/controllers/miq_policy_log_controller.rb +++ b/app/controllers/miq_policy_log_controller.rb @@ -16,10 +16,6 @@ def index @lastaction = "policy_logs" @layout = "miq_policy_logs" @msg_title = "Policy" - @download_action = "fetch_log" - @server_options ||= {} - @server_options[:server_id] ||= MiqServer.my_server.id - @server = MiqServer.my_server drop_breadcrumb(:name => _("Log"), :url => "/miq_ae_policy/log") end @@ -68,13 +64,11 @@ def get_session_data @title = _("Log") @layout = "miq_policy_log" @lastaction = session[:miq_policy_log_lastaction] - @server_options = session[:server_options] if session[:server_options] end def set_session_data super session[:layout] = @layout - session[:server_options] = @server_options session[:miq_policy_log_lastaction] = @lastaction end diff --git a/app/views/layouts/_log_viewer.html.haml b/app/views/layouts/_log_viewer.html.haml index 5c1d211b31e..32ba69c0e96 100644 --- a/app/views/layouts/_log_viewer.html.haml +++ b/app/views/layouts/_log_viewer.html.haml @@ -1,4 +1,5 @@ -- legend_text ||= _("Last 1000 lines from server %{server_name} [%{server_id}] in zone %{zone_name}") % {:server_name => @server.name, :server_id => @server_options[:server_id], :zone_name => @server.my_zone} +- server = MiqServer.my_server +- legend_text ||= _("Last 1000 lines from server %{server_name} [%{server_id}] in zone %{zone_name}") % {:server_name => server.name, :server_id => MiqServer.my_server.id, :zone_name => server.my_zone} = render :partial => "layouts/flash_msg" %h3= legend_text diff --git a/spec/controllers/miq_policy_log_controller_spec.rb b/spec/controllers/miq_policy_log_controller_spec.rb index 540cb62902e..f6694fde40e 100644 --- a/spec/controllers/miq_policy_log_controller_spec.rb +++ b/spec/controllers/miq_policy_log_controller_spec.rb @@ -5,20 +5,17 @@ context "GenericSessionMixin" do let(:lastaction) { 'lastaction' } - let(:server_options) { 'server options' } let(:layout) { 'miq_policy_log' } describe '#get_session_data' do it "Sets variables correctly" do allow(controller).to receive(:session).and_return(:miq_policy_log_lastaction => lastaction, - :server_options => server_options, :layout => layout) controller.send(:get_session_data) expect(controller.instance_variable_get(:@title)).to eq("Log") expect(controller.instance_variable_get(:@layout)).to eq(layout) expect(controller.instance_variable_get(:@lastaction)).to eq(lastaction) - expect(controller.instance_variable_get(:@server_options)).to eq(server_options) end end @@ -26,12 +23,10 @@ it "Sets session correctly" do controller.instance_variable_set(:@lastaction, lastaction) controller.instance_variable_set(:@layout, layout) - controller.instance_variable_set(:@server_options, server_options) controller.send(:set_session_data) expect(controller.session[:miq_policy_log_lastaction]).to eq(lastaction) expect(controller.session[:layout]).to eq(layout) - expect(controller.session[:server_options]).to eq(server_options) end end end From e30e3170cfae47d681c45cfc8c6da765e5d190b5 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Mon, 11 Jan 2021 17:30:35 -0500 Subject: [PATCH 4/5] Added RBAC check in index method to fix routes_spec error - Added `report_data` and `wait_to_task` routes to pending routes list Pre work for https://github.com/ManageIQ/manageiq-ui-classic/pull/7401 --- app/controllers/miq_policy_log_controller.rb | 1 + spec/config/routes.pending.yml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/app/controllers/miq_policy_log_controller.rb b/app/controllers/miq_policy_log_controller.rb index f552d53940f..c16d74e47b5 100644 --- a/app/controllers/miq_policy_log_controller.rb +++ b/app/controllers/miq_policy_log_controller.rb @@ -8,6 +8,7 @@ class MiqPolicyLogController < ApplicationController include Mixins::BreadcrumbsMixin def index + assert_privileges('policy_log') flash_to_session assert_privileges('policy_log') @breadcrumbs = [] diff --git a/spec/config/routes.pending.yml b/spec/config/routes.pending.yml index a4e01fa5f3e..39f66288bcf 100644 --- a/spec/config/routes.pending.yml +++ b/spec/config/routes.pending.yml @@ -847,6 +847,9 @@ MiqPolicyExportController: MiqPolicyRsopController: - report_data - wait_for_task +MiqPolicyLogController: +- report_data +- wait_for_task MiqPolicySetController: - form_field_changed - index From 3f18a60a8bf33241e4948bce95b314b5a48cf0ee Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Thu, 14 Jan 2021 19:03:10 -0500 Subject: [PATCH 5/5] Resolved issues caused during merge conflict Pre work for https://github.com/ManageIQ/manageiq-ui-classic/pull/7401 --- config/routes.rb | 6 ------ spec/controllers/miq_policy_controller_spec.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 38b8356f8ae..c8d817b47a5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2089,7 +2089,6 @@ :miq_policy => { :get => %w( explorer - rsop ), :post => %w( button @@ -2099,13 +2098,8 @@ policy_field_changed quick_search reload - rsop - rsop_option_changed - rsop_show_options - rsop_toggle tree_autoload tree_select - wait_for_task ) + adv_search_post + exp_post + diff --git a/spec/controllers/miq_policy_controller_spec.rb b/spec/controllers/miq_policy_controller_spec.rb index b7eb3cbe432..878612d855f 100644 --- a/spec/controllers/miq_policy_controller_spec.rb +++ b/spec/controllers/miq_policy_controller_spec.rb @@ -129,7 +129,7 @@ let(:lastaction) { 'lastaction' } let(:display) { 'display' } let(:current_page) { 'current_page' } - let(:layout) { 'layout' } + let(:layout) { 'miq_policy' } describe '#get_session_data' do it "Sets variables correctly" do