diff --git a/app/helpers/application_helper/button/ems_refresh.rb b/app/helpers/application_helper/button/ems_refresh.rb index e45c74b05a5..a7ab862b557 100644 --- a/app/helpers/application_helper/button/ems_refresh.rb +++ b/app/helpers/application_helper/button/ems_refresh.rb @@ -3,6 +3,7 @@ class ApplicationHelper::Button::EmsRefresh < ApplicationHelper::Button::Basic def disabled? super + @error_message ||= _("Unable to refresh the provider while it is suspended") unless @record.enabled? @error_message ||= _("Credentials must be valid to refresh a provider") unless @record.authentication_status.downcase == "valid" @error_message.present? end diff --git a/spec/helpers/application_helper/buttons/ems_refresh_spec.rb b/spec/helpers/application_helper/buttons/ems_refresh_spec.rb index c4491e5f3d5..df31d2639e5 100644 --- a/spec/helpers/application_helper/buttons/ems_refresh_spec.rb +++ b/spec/helpers/application_helper/buttons/ems_refresh_spec.rb @@ -6,13 +6,22 @@ describe '#disabled?' do subject { button[:title] } before { allow(record).to receive(:authentication_status).and_return(auth_status) } + before { allow(record).to receive(:enabled?).and_return(enabled) } + + context 'provider is suspended' do + let(:enabled) { false } + let(:auth_status) { "Valid" } + it { expect(button.disabled?).to be_truthy } + end context 'and record authentication status is valid' do + let(:enabled) { true } let(:auth_status) { "Valid" } it { expect(button.disabled?).to be_falsey } end context 'and record authentication status is not valid' do + let(:enabled) { true } let(:auth_status) { "Invalid" } it { expect(button.disabled?).to be_truthy } end