Skip to content

Commit

Permalink
Disable the provider refresh button for suspended providers
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Jan 15, 2019
1 parent 638eee1 commit b761e77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/helpers/application_helper/button/ems_refresh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/helpers/application_helper/buttons/ems_refresh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b761e77

Please sign in to comment.