diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7aa5fdd6dad..e4810ea21aa 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -297,7 +297,7 @@ def saved_report_paging @sb[:pages][:perpage] = settings(:perpage, :reports) rr = MiqReportResult.find(@sb[:pages][:rr_id]) - @html = report_build_html_table(rr.report_results, + @html = report_build_html_table(rr.report, rr.html_rows(:page => @sb[:pages][:current], :per_page => @sb[:pages][:perpage]).join) diff --git a/app/controllers/chargeback_controller.rb b/app/controllers/chargeback_controller.rb index 8e7575b9cc3..c8bea713c01 100644 --- a/app/controllers/chargeback_controller.rb +++ b/app/controllers/chargeback_controller.rb @@ -349,9 +349,8 @@ def cb_rpts_fetch_saved_report(id) @report_result_id = session[:report_result_id] = rr.id session[:report_result_runtime] = rr.last_run_on if rr.status.downcase == "complete" - @report = rr.report_results session[:rpt_task_id] = nil - if @report.blank? + unless rr.valid_report_column? @saved_reports = cb_rpts_get_all_reps(rr.miq_report_id.to_s) rep = MiqReport.find_by_id(rr.miq_report_id) if x_active_tree == :cb_reports_tree @@ -359,7 +358,7 @@ def cb_rpts_fetch_saved_report(id) end return else - if @report.contains_records? + if rr.contains_records? @html = report_first_page(rr) # Get the first page of the results unless @report.graph.blank? @zgraph = true diff --git a/app/controllers/report_controller/saved_reports.rb b/app/controllers/report_controller/saved_reports.rb index 955a27b3250..13f1fb1b1d4 100644 --- a/app/controllers/report_controller/saved_reports.rb +++ b/app/controllers/report_controller/saved_reports.rb @@ -26,9 +26,8 @@ def fetch_saved_report(id) @report_result_id = session[:report_result_id] = rr.id session[:report_result_runtime] = rr.last_run_on if rr.status.downcase == "complete" - @report = rr.report_results session[:rpt_task_id] = nil - if @report.blank? + unless rr.valid_report_column? add_flash(_("Saved Report \"%{time}\" not found, Schedule may have failed") % {:time => format_timezone(rr.created_on, Time.zone, "gtl")}, :error) @@ -48,7 +47,7 @@ def fetch_saved_report(id) end return else - if @report.contains_records? + if rr.contains_records? @html = report_first_page(rr) # Get the first page of the results if params[:type] @zgraph = nil diff --git a/app/helpers/application_helper/button/report_download_choice.rb b/app/helpers/application_helper/button/report_download_choice.rb index 3ab104bbfdc..21985221b3c 100644 --- a/app/helpers/application_helper/button/report_download_choice.rb +++ b/app/helpers/application_helper/button/report_download_choice.rb @@ -1,5 +1,5 @@ class ApplicationHelper::Button::ReportDownloadChoice < ApplicationHelper::Button::Basic def disabled? - MiqReportResult.find(@report_result_id).try(:miq_report_result_details).try(:length).to_i == 0 + !MiqReportResult.find(@report_result_id).try(:miq_report_result_details).try(:exists?) end end diff --git a/app/helpers/application_helper/button/report_only.rb b/app/helpers/application_helper/button/report_only.rb index 08d3ac05bde..396bf0c34fb 100644 --- a/app/helpers/application_helper/button/report_only.rb +++ b/app/helpers/application_helper/button/report_only.rb @@ -11,6 +11,6 @@ def disabled? def report_records? @report.present? && @report_result_id.present? && - MiqReportResult.find(@report_result_id).try(:miq_report_result_details).try(:length).to_i > 0 + MiqReportResult.find(@report_result_id).try(:miq_report_result_details).try(:exists?) end end diff --git a/spec/controllers/chargeback_controller_spec.rb b/spec/controllers/chargeback_controller_spec.rb index d63aa440fdd..3e67374da09 100644 --- a/spec/controllers/chargeback_controller_spec.rb +++ b/spec/controllers/chargeback_controller_spec.rb @@ -577,7 +577,8 @@ def convert_chargeback_rate_to_hash(rate) miq_task.state_finished miq_report_result.report = chargeback_report.to_hash.merge(:extras=> {:total_html_rows => 100}) miq_report_result.save - allow(controller).to receive(:report_first_page) + controller.instance_variable_set(:@sb, {}) + controller.instance_variable_set(:@settings, :perpage => { :reports => 20 }) end it "fetch existing report" do diff --git a/spec/controllers/miq_report_controller/trees_spec.rb b/spec/controllers/miq_report_controller/trees_spec.rb index 8542f8b280a..f5a868246a8 100644 --- a/spec/controllers/miq_report_controller/trees_spec.rb +++ b/spec/controllers/miq_report_controller/trees_spec.rb @@ -34,9 +34,12 @@ before do login_as user controller.instance_variable_set(:@html, "