From 2bd10eec7a5366ea3445241107461a8f850c12da Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Wed, 24 May 2017 12:25:57 -0400 Subject: [PATCH] Fixed condition in disabled? method Fixed a check in disabled? method introduced in commit 4b33666a0990231ecc7f3de899ccace90a6a4070 during refactoring of toolbar methods in https://github.com/ManageIQ/manageiq/pull/13052 https://bugzilla.redhat.com/show_bug.cgi?id=1455283 --- app/helpers/application_helper/button/role_suspend.rb | 4 ++-- .../application_helper/buttons/role_suspend_spec.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper/button/role_suspend.rb b/app/helpers/application_helper/button/role_suspend.rb index 22bd001bd1f..5613b7daaf5 100644 --- a/app/helpers/application_helper/button/role_suspend.rb +++ b/app/helpers/application_helper/button/role_suspend.rb @@ -4,12 +4,12 @@ class ApplicationHelper::Button::RoleSuspend < ApplicationHelper::Button::RolePo def disabled? @error_message = if @view_context.x_node != 'root' && @record.server_role.regional_role? _('This role can only be managed at the Region level') - elsif @record.active && @record.server_role.max_concurrent == 1 + elsif @record.active _("Activate the %{server_role_description} Role on another Server to \ suspend it on %{server_name} [%{server_id}]") % {:server_role_description => @record.server_role.description, :server_name => @record.miq_server.name, - :server_id => @record.miq_server.id} + :server_id => @record.miq_server.id} if @record.server_role.max_concurrent == 1 else _('Only active Roles on active Servers can be suspended') end diff --git a/spec/helpers/application_helper/buttons/role_suspend_spec.rb b/spec/helpers/application_helper/buttons/role_suspend_spec.rb index 3d61055ea6e..3b30918a49e 100644 --- a/spec/helpers/application_helper/buttons/role_suspend_spec.rb +++ b/spec/helpers/application_helper/buttons/role_suspend_spec.rb @@ -78,6 +78,17 @@ button.calculate_properties expect(button[:title]).to eq("Only active Roles on active Servers can be suspended") end + + # enable button when record is active and max concurrent is not 1 + it "enables the suspend role button " do + allow(@record).to receive(:active).and_return(true) + allow(@record.server_role).to receive(:max_concurrent).and_return(2) + view_context = setup_view_context_with_sandbox({}) + button = described_class.new(view_context, {}, {'record' => @record}, {}) + allow(view_context).to receive(:x_node).and_return('z-1r23') + expect(button.disabled?).to be_falsey + button.calculate_properties + end end end end