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 9, 2018
1 parent 85aceb6 commit a7ecfb9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/controllers/ems_physical_infra_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class EmsPhysicalInfraController < ApplicationController

before_action :check_privileges
before_action :get_session_data
before_action :check_providers_credentials
after_action :cleanup_action
after_action :set_session_data

Expand All @@ -18,6 +19,16 @@ def self.table_name
@table_name ||= "ems_physical_infra"
end

# Check if there are providers with invalid credentials
# if true, adds a alert message to user
def check_providers_credentials
model.find_each do |provider|
unless provider.last_refresh_status == "never" && provider.authentication_status_ok?
add_flash(_("The provider \"%<name>s\" is with invalid credentials") % {:name => provider.name}, :error)
end
end
end

def ems_path(*args)
ems_physical_infra_path(*args)
end
Expand Down
8 changes: 8 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,17 @@
before(:each) do
stub_user(:features => :all)
FactoryGirl.create(:ems_vmware)
@provider = FactoryGirl.create(:ems_physical_infra)
allow(@provider).to receive(:authentication_status_ok?).and_return(false)
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 a7ecfb9

Please sign in to comment.