Skip to content

Commit

Permalink
Fixed condition in disabled? method
Browse files Browse the repository at this point in the history
Fixed a check in disabled? method introduced in commit 4b33666 during refactoring of toolbar methods in ManageIQ/manageiq#13052

https://bugzilla.redhat.com/show_bug.cgi?id=1455283
  • Loading branch information
h-kataria committed May 24, 2017
1 parent 7662fd9 commit 2bd10ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/helpers/application_helper/button/role_suspend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions spec/helpers/application_helper/buttons/role_suspend_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2bd10ee

Please sign in to comment.