Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

#223 | Jie Sheng | Exclude contact page from authentication and added test to verify #790

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
125 changes: 64 additions & 61 deletions features/add_roles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,113 +5,116 @@ 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
Scenario: Sorting by Descending Order
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
Expand Down