From: Jan Provaznik <jprovazn(a)redhat.com>
---
src/features/realm.feature | 48 ++++++++++++++++++++++++++
src/features/step_definitions/realm_steps.rb | 24 +++++++++++++
src/features/support/paths.rb | 3 ++
3 files changed, 75 insertions(+), 0 deletions(-)
create mode 100644 src/features/realm.feature
create mode 100644 src/features/step_definitions/realm_steps.rb
diff --git a/src/features/realm.feature b/src/features/realm.feature
new file mode 100644
index 0000000..e067c9f
--- /dev/null
+++ b/src/features/realm.feature
@@ -0,0 +1,48 @@
+Feature: Manage Realms
+ In order to manage realms
+ As an admin
+ I want to add/edit/remove realms
+
+ Background:
+ Given I am an authorised user
+ And I am logged in
+ And there's no realm
+ And a realm "testrealm1" exists
+ And I am using new UI
+
+ Scenario: Create new frontend realm
+ Given I am on the admin realms page
+ When I follow "Create"
+ Then I should see "Create a new Realm"
+ When I fill in "frontend_realm[name]" with "testrealm2"
+ And I choose "frontend_realm_backend_realm_type_provider"
+ And I press "Save"
+ Then I should see "Realm was added."
+
+ Scenario: Change the name
+ Given I am on the admin realms page
+ And there is a realm "testrealm1"
+ When I follow "testrealm1"
+ And I follow "Edit"
+ Then I should see "Editing Realm:"
+ When I fill in "frontend_realm[name]" with "testrealm2"
+ And I press "Save"
+ Then I should see "Realm updated successfully!"
+
+ Scenario: Show realm detials
+ Given a realm "testrealm2" exists
+ And I am on the admin realms page
+ When I follow "testrealm2"
+ Then I should be on testrealm2's realm page
+
+ Scenario: Delete realms
+ Given a realm "testrealm2" exists
+ And I am on the admin realms page
+ And there are 2 realms
+ When I check "testrealm2" realm
+ And I check "testrealm1" realm
+ And I press "Delete"
+ Then there should be only 0 realms
+ And I should be on the admin realms page
+ And I should not see "testrealm1"
+ And I should not see "testrealm2"
diff --git a/src/features/step_definitions/realm_steps.rb
b/src/features/step_definitions/realm_steps.rb
new file mode 100644
index 0000000..b8780c1
--- /dev/null
+++ b/src/features/step_definitions/realm_steps.rb
@@ -0,0 +1,24 @@
+Given /there's no realm/ do
+ FrontendRealm.destroy_all
+end
+
+Given /^a realm "([^"]*)" exists$/ do |realm_name|
+ FrontendRealm.create(:name => realm_name, :backend_realm =>
Factory(:mock_provider))
+end
+
+Given /^there is a realm "([^"]*)"$/ do |name|
+ FrontendRealm.find_by_name(name).should_not == nil
+end
+
+Given /^there are (\d+) realms$/ do |number|
+ FrontendRealm.count.should == number.to_i
+end
+
+When /^(?:|I )check "([^"]*)" realm$/ do |realm_name|
+ realm = FrontendRealm.find_by_name(realm_name)
+ check("realm_id_#{realm.id}")
+end
+
+Then /^there should be only (\d+) realms$/ do |number|
+ FrontendRealm.count.should == number.to_i
+end
diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb
index c0c77dc..800361e 100644
--- a/src/features/support/paths.rb
+++ b/src/features/support/paths.rb
@@ -23,6 +23,9 @@ module NavigationHelpers
when /^(.*)'s role page$/i
admin_role_path(Role.find_by_name($1))
+ when /^(.*)'s realm page$/i
+ admin_realm_path(FrontendRealm.find_by_name($1))
+
when /the account page/
account_path
--
1.7.3.4