Skip to content

Commit

Permalink
Display widget's title in full screen of widget result
Browse files Browse the repository at this point in the history
there is used title from report for report result
  • Loading branch information
lpichler committed Jan 14, 2019
1 parent 4a75962 commit 30e31f7
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ def report_only
session[:rpt_task_id] = nil # Clear out report task id, using a saved report

@report = rr.report
@report_title = rr.full_screen_title
@html = report_build_html_table(rr.report_results, rr.html_rows.join)
@ght_type = params[:type] || (@report.graph.blank? ? 'tabular' : 'hybrid')
@render_chart = (@ght_type == 'hybrid')
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_show_report.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
%h3= _("Choose a Report to view.")
- else
%fieldset
%h3= @report.title
%h3= @report_title
= render :partial => "layouts/flash_msg"
= render :partial => "shared/report_chart_and_html", :locals => {:html => @html, :chart => @render_chart, :report => @report}
2 changes: 1 addition & 1 deletion app/views/layouts/report_only.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%html.layout-pf.layout-pf-fixed.transitions{:lang => I18n.locale.to_s.sub('-', '_')}
%head
%title
= "%{product}: %{title}" % {:product => Vmdb::Appliance.PRODUCT_NAME, :title => @report.title}
= "%{product}: %{title}" % {:product => Vmdb::Appliance.PRODUCT_NAME, :title => @report_title}
= favicon_link_tag
= stylesheet_link_tag 'application'
= stylesheet_link_tag '/custom.css'
Expand Down
43 changes: 43 additions & 0 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
require 'ostruct'

describe ApplicationController do
describe "#report_only" do
let(:group) { FactoryBot.create(:miq_group, :miq_user_role => FactoryBot.create(:miq_user_role)) }
let(:user) { FactoryBot.create(:user, :miq_groups => [group]) }
let(:report_title) { "VMs using thin provisioned disks" }
let(:report) { FactoryBot.create(:miq_report, :title => report_title) }
let(:report_result_for_report) { FactoryBot.create(:miq_report_result, :miq_group => group, :miq_report_id => report.id, :report => report) }
let(:widget_title) { "Widget: VMs using thin provisioned disks" }
let(:widget) { FactoryBot.create(:miq_widget, :widget => widget_title) }
let(:widget_content) { FactoryBot.create(:miq_widget_content, :miq_widget => widget) }
let(:report_for_widget) { FactoryBot.create(:miq_report, :title => widget_title) }
let(:report_result_for_widget) { FactoryBot.create(:miq_report_result, :miq_group => group, :miq_report => report_for_widget, :report => report_for_widget, :report_source => MiqWidget::WIDGET_REPORT_SOURCE) }

before do
login_as user
end

it "uses correct variables for rendering result of report" do
controller.instance_variable_set(:@sb, :pages => { :rr_id => report_result_for_report.id })
controller.instance_variable_set(:@_params, :rr_id => report_result_for_report.id)

expect(controller).to receive(:render).with('shared/show_report', :layout => 'report_only')
controller.send(:report_only)

expect(controller.instance_variable_get(:@report_title)).to eq(report_title)
expect(controller.instance_variable_get(:@report)).to eq(report)
expect(controller.instance_variable_get(:@ght_type)).to eq('tabular')
expect(controller.instance_variable_get(:@render_chart)).to be_falsey
end

it "uses correct variables for rendering result of report" do
controller.instance_variable_set(:@sb, :pages => { :rr_id => report_result_for_widget.id })
controller.instance_variable_set(:@_params, :rr_id => report_result_for_widget.id)

expect(controller).to receive(:render).with('shared/show_report', :layout => 'report_only')
controller.send(:report_only)

expect(controller.instance_variable_get(:@report_title)).to eq(widget_title)
expect(controller.instance_variable_get(:@report)).to eq(report_for_widget)
expect(controller.instance_variable_get(:@ght_type)).to eq('tabular')
expect(controller.instance_variable_get(:@render_chart)).to be_falsey
end
end

describe "#find_record_with_rbac" do
before do
EvmSpecHelper.create_guid_miq_server_zone
Expand Down

0 comments on commit 30e31f7

Please sign in to comment.