Skip to content

Commit

Permalink
Showing alert for physical providers with invalid credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasgabriel committed Jan 12, 2018
1 parent 85aceb6 commit e0ba050
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/controllers/ems_physical_infra_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ def self.table_name
@table_name ||= "ems_physical_infra"
end

def show_list
super
check_providers_credentials
end

# Check if there are providers with invalid credentials
# if it's true, adds an alert message to user
def check_providers_credentials
model.find_each do |provider|
if provider.authentication_status.casecmp("invalid").zero?
add_flash(_("The provider \"%{name}\" is with invalid credentials") % {:name => provider.name}, :error)
end
end
end

def ems_path(*args)
ems_physical_infra_path(*args)
end
Expand Down
7 changes: 7 additions & 0 deletions spec/controllers/ems_physical_infra_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,16 @@
before(:each) do
stub_user(:features => :all)
FactoryGirl.create(:ems_vmware)
@provider = FactoryGirl.create(:ems_physical_infra, :with_invalid_authentication)
get :show_list
end
it { expect(response.status).to eq(200) }

context "show provider with invalid credentials" do
it "shows an alert to user" do
expect(assigns(:flash_array).first[:message]).to include("The provider \"#{@provider.name}\" is with invalid credentials")
end
end
end

describe "breadcrumbs path on a 'show' page of an Physical Infrastructure Provider accessed from Dashboard maintab" do
Expand Down

0 comments on commit e0ba050

Please sign in to comment.