Skip to content

Commit

Permalink
Merge pull request #2229 from h-kataria/custom_report_node_title_fix
Browse files Browse the repository at this point in the history
Fixed Custom Reports node text when there is "-" present in tenant name
  • Loading branch information
Dan Clarizio authored Sep 25, 2017
2 parents be7f394 + 6368270 commit 6c18b65
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ def get_reports_menu(group = current_group, tree_type = "reports", mode = "menu"
data.where.not(:timeline => nil) if tree_type == "timeline"
data.each do |r|
r_group = r.rpt_group == "Custom" ? "#{@sb[:grp_title]} - Custom" : r.rpt_group # Get the report group
title = r_group.split('-').collect(&:strip)
title = r_group.reverse.split('-', 2).collect(&:reverse).collect(&:strip).reverse
if @temp_title != title[0]
@temp_title = title[0]
reports = []
Expand Down
18 changes: 5 additions & 13 deletions spec/controllers/miq_report_controller/menus_spec.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
describe ReportController do
describe "#menu_update" do
let(:rpt_menu) do
[
[
"Configuration Management", [
["Virtual Machines", ["VMs with Free Space > 50% by Department"]],
]
]
]
end

before do
controller.instance_variable_set(:@edit, :new => {})
controller.instance_variable_set(:@sb, :new => {})
controller.instance_variable_set(:@_params, :button => "default")

tenant = FactoryGirl.create(:tenant, :parent => Tenant.root_tenant, :name => "foo - bar", :subdomain => "foo - bar")
user = FactoryGirl.create(:user, :tenant => tenant)
@report = FactoryGirl.create(:miq_report, :rpt_type => "Custom", :miq_group => user.current_group)
@user = stub_user(:features => :all)
end

it "set menus to default" do
it "set menus to default and sets correct title for custom reports" do
expect(controller).to receive(:menu_get_form_vars)
expect(controller).to receive(:get_tree_data)
expect(controller).to receive(:replace_right_cell)
expect(controller).to receive(:get_reports_menu).with(@user.current_group, "reports", "default").and_return(rpt_menu)

controller.menu_update
expect(assigns(:edit)[:new]).to eq([["foo - bar (EVM Group): #{@user.current_group.description}", [["Custom", [@report.name]]]]])
expect(assigns(:flash_array).first[:message]).to include("default")
end
end
Expand Down

0 comments on commit 6c18b65

Please sign in to comment.