Resolves
https://bugzilla.redhat.com/show_bug.cgi?id=718122
---
.../controllers/provider_accounts_controller.rb | 20 +++++++++++++-------
src/config/locales/en.yml | 6 ++++++
src/features/provider_account.feature | 2 +-
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/src/app/controllers/provider_accounts_controller.rb
b/src/app/controllers/provider_accounts_controller.rb
index a5cfb83..b797d9e 100644
--- a/src/app/controllers/provider_accounts_controller.rb
+++ b/src/app/controllers/provider_accounts_controller.rb
@@ -75,13 +75,19 @@ class ProviderAccountsController < ApplicationController
@provider_account.quota.set_maximum_running_instances(limit)
@provider_account.pool_families << PoolFamily.default
- if @provider_account.save
- @provider_account.assign_owner_roles(current_user)
- @provider_account.populate_realms
- flash[:notice] = "Provider account added."
- redirect_to provider_account_path(@provider_account)
- else
- flash[:error] = "Credentials are invalid!"
+ begin
+ if @provider_account.save
+ @provider_account.assign_owner_roles(current_user)
+ @provider_account.populate_realms
+ flash[:notice] = t('provider_accounts.index.account_added', :list =>
@provider_account.name, :count => 1)
+ redirect_to provider_account_path(@provider_account)
+ else
+ flash[:error] = "Credentials are invalid!"
+ render :action => 'new' and return
+ end
+ rescue Exception => e
+ flash[:error] = "#{t('provider_accounts.index.account_not_added',
:list => @provider_account.name,
+ :count => 1)}: #{e.message}"
render :action => 'new' and return
end
end
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 021cffa..7f8354a 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -192,6 +192,12 @@ en:
account_not_deleted:
one: "Account %{list} was not deleted. There are instances associated with
it."
other: "Accounts %{list} were not deleted. They have instances associated
with them."
+ account_added:
+ one: "Account %{list} was added."
+ other: "Accounts %{list} were added."
+ account_not_added:
+ one: "Account %{list} could not be added"
+ other: "Accounts %{list} could not be added"
new:
new_provider_account: New Account
required_field: Required field.
diff --git a/src/features/provider_account.feature
b/src/features/provider_account.feature
index 16eae92..348fa5b 100644
--- a/src/features/provider_account.feature
+++ b/src/features/provider_account.feature
@@ -41,7 +41,7 @@ Feature: Manage Provider Accounts
And I fill in "quota[maximum_running_instances]" with "13"
And I press "Save"
Then I should be on testaccount's provider account page
- And I should see "Provider account added"
+ And I should see "Account testaccount was added."
And I should have a provider account named "testaccount"
And I should see "Properties for testaccount"
And I should see "Running instances quota: 13"
--
1.7.4.4