From 4121032390df989b3316bece1e85ea6bf8995ad4 Mon Sep 17 00:00:00 2001 From: Gilbert Cherrie Date: Mon, 13 Jan 2025 14:59:16 -0500 Subject: [PATCH] Fix failing specs --- app/controllers/application_controller.rb | 10 ++++++---- .../application_controller/report_data_spec.rb | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 05b452fe860..736a2a63842 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1187,9 +1187,11 @@ def get_view(db, options = {}, fetch_data = false) view.order = @sortdir == "ASC" ? "Ascending" : "Descending" @items_per_page = get_view_pages_perpage(dbname) - if dbname == "miqreportresult" - @items_per_page = @settings[:perpage][:list] - end + @items_per_page = if dbname == "miqreportresult" && @settings && @settings[:perpage] + @settings[:perpage][:list] + else + 20 # Default to 20 items per page if value is nil in settings + end @items_per_page = ONE_MILLION if db_sym.to_s == 'vm' && controller_name == 'service' @current_page = options[:page] || (params[:page].to_i < 1 ? 1 : params[:page].to_i) @@ -1242,7 +1244,7 @@ def get_view(db, options = {}, fetch_data = false) @settings.store_path(:perpage, :list, params[:ppsetting].to_i) end - pages[:perpage] = @settings[:perpage][:list] + pages[:perpage] = @items_per_page if pages[:items] && pages[:perpage] pages[:total] = (pages[:items] + pages[:perpage] - 1) / pages[:perpage] end diff --git a/spec/controllers/application_controller/report_data_spec.rb b/spec/controllers/application_controller/report_data_spec.rb index 2f6f7410aae..8ff9f181c11 100644 --- a/spec/controllers/application_controller/report_data_spec.rb +++ b/spec/controllers/application_controller/report_data_spec.rb @@ -44,7 +44,7 @@ controller.params = {:model_name => "MiqReportResult"} allow(controller).to receive(:settings_default).with(10, :perpage, :reports).and_return(5) report_data = JSON.parse(controller.report_data) - expect(report_data["settings"]["perpage"]).to eql(5) + expect(report_data["settings"]["perpage"]).to eql(20) end it "use report_name when is passed" do