From c3e2f99dad3a2fd3a3996b42467b724584479361 Mon Sep 17 00:00:00 2001 From: Chua Jie Sheng Date: Mon, 24 Nov 2014 12:06:32 +0800 Subject: [PATCH] #223 | Jie Sheng | Exclude contact page from authentication and added test to verify --- app/controllers/users_controller.rb | 2 +- features/add_roles.feature | 125 ++++++++++++++-------------- 2 files changed, 65 insertions(+), 62 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9c77dfa98..9b1e69e03 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2,7 +2,7 @@ class UsersController < ApplicationController before_action :clean_role_ids, :only => [:update, :create] before_action :load_user, :only => [:show, :edit, :update, :destroy] - skip_before_action :check_authentication, :set_locale, :only => :register_unverified + skip_before_action :check_authentication, :set_locale, :only => [:register_unverified, :contact] def index authorize! :read, User diff --git a/features/add_roles.feature b/features/add_roles.feature index d9df1d86a..ef28a8d8e 100644 --- a/features/add_roles.feature +++ b/features/add_roles.feature @@ -5,38 +5,38 @@ Feature: Add new role And I am on create role page When I enter the following role details - | name | description | permissions | - | super admin | like an admin, but super | highlight_fields | + | name | description | permissions | + | super admin | like an admin, but super | highlight_fields | And I submit the form Then I should be on roles index page And I should see the following roles - | name | description | permissions | - | super admin | like an admin, but super | highlight_fields | + | name | description | permissions | + | super admin | like an admin, but super | highlight_fields | Scenario: Filtering by role Given I am logged in as a user with "Admin" permission And I am on create role page - And I enter the following role details - | name | description | permissions | - | Can Edit Child | can edit child | edit_child | + And I enter the following role details + | name | description | permissions | + | Can Edit Child | can edit child | edit_child | And I submit the form When I try to filter user roles by permission "Edit Child" Then I should see the following roles - | name | description | permissions | - | Can Edit Child | can edit child | edit_child | + | name | description | permissions | + | Can Edit Child | can edit child | edit_child | @roles Scenario: Sorting by Ascending Order Given I am logged in as a user with "Admin" permission When I try to filter user roles sorted by "Ascending" Then I should see the following roles sorted: - |name | - |Admin | - |Field Admin | - |Field Worker | + | name | + | Admin | + | Field Admin | + | Field Worker | @javascript @roles @@ -44,74 +44,77 @@ Feature: Add new role Given I am logged in as a user with "Admin" permission When I try to filter user roles sorted by "Descending" Then I should see the following roles sorted: - |name | - |Field Worker | - |Field Admin | - |Admin | + | name | + | Field Worker | + | Field Admin | + | Admin | @roles Scenario:Editing a newly created role - Given I am logged in as a user with "Admin" permission - And I am on create role page - And I enter the following role details + Given I am logged in as a user with "Admin" permission + And I am on create role page + And I enter the following role details | name | description | permissions | | Automation Role | can edit child | view_users | - And I submit the form - When I edit the role Automation Role - And I enter the following permission details - | permissions | - | register_child | - | view_and_search_child | - | view_roles | - | edit_child | - | create_and_edit_users | - | view_and_download_reports | - And I update the form - And I am on manage users page - And I follow "Create User" - When I fill in the following: - | Full Name | Test Automation | - | User Name | Automation | - | Password | automation | - | Re-enter password | automation | - | Organisation | UNICEF | - And I check "Automation Role" - And I press "Create" - And I logout - Then I am logged in as user automation with password as automation - Then I should be able to view the tab USERS - And I should be able to view the tab REPORTS - And I should be able to view the tab CHILDREN - And I logout - Then I am logged in as user mary with password as 123 - And I am on the manage users page - Then user "automation" should exist on the page - Then I should see "Edit" for "automation" - Then I should see "Delete" for "automation" + And I submit the form + When I edit the role Automation Role + And I enter the following permission details + | permissions | + | register_child | + | view_and_search_child | + | view_roles | + | edit_child | + | create_and_edit_users | + | view_and_download_reports | + And I update the form + And I am on manage users page + And I follow "Create User" + When I fill in the following: + | Full Name | Test Automation | + | User Name | Automation | + | Password | automation | + | Re-enter password | automation | + | Organisation | UNICEF | + And I check "Automation Role" + And I check "Share Contact Info" + And I press "Create" + And I logout + Then I follow "Contact & Help" + And I should see "Test Automation" + And I should see "UNICEF" + Then I am logged in as user automation with password as automation + Then I should be able to view the tab USERS + And I should be able to view the tab REPORTS + And I should be able to view the tab CHILDREN + And I logout + Then I am logged in as user mary with password as 123 + And I am on the manage users page + Then user "automation" should exist on the page + Then I should see "Edit" for "automation" + Then I should see "Delete" for "automation" @roles Scenario:Creating user with sysadmin role Given I am logged in as a user with "Admin" permission And I am on create role page And I enter the following role details - | name | description | permissions | - | Auto Admin | can edit child | users_for_synchronisation | + | name | description | permissions | + | Auto Admin | can edit child | users_for_synchronisation | And I submit the form When I edit the role Auto Admin And I enter the following permission details - | permissions | + | permissions | | users_for_synchronisation | | view_and_download_reports | And I update the form And I am on manage users page And I follow "Create User" When I fill in the following: - | Full Name | Test Automation | - | User Name | Automation | - | Password | automation | - | Re-enter password | automation | - | Organisation | UNICEF | - + | Full Name | Test Automation | + | User Name | Automation | + | Password | automation | + | Re-enter password | automation | + | Organisation | UNICEF | And I check "Auto Admin" And I press "Create" And I logout