Skip to content

Commit

Permalink
- improved the test to also verify the correct roles are enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelponte committed Jul 20, 2018
1 parent 50c7702 commit 0b982d4
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package module

import geb.Module
import geb.navigator.Navigator

/**
* Module representing the Roles tab which is displayed on the User edit page
@@ -21,10 +22,24 @@ class RolesTab extends Module {
}

int totalEnabledRoles() {
return $("input", type: "checkbox", id: startsWith("ROLE_"), checked: "checked").size().toInteger()
return findAllEnabledRoles().size().toInteger()
}

Navigator findAllEnabledRoles() {
return $("input", type: "checkbox", id: startsWith("ROLE_"), checked: "checked")
}

void enableRole(String roleName) {
$("input", type: "checkbox", id: roleName).value(true)
}

boolean hasEnabledRole(String roleName) {
return hasEnabledRoles([roleName])
}

boolean hasEnabledRoles(List<String> roleNames) {
return findAllEnabledRoles().collect { it.attr('id') }.containsAll(roleNames)
}


}
Original file line number Diff line number Diff line change
@@ -192,6 +192,7 @@ class UserSpec extends AbstractSecuritySpec {
then: "12 roles are listed and 1 is enabled"
assert rolesTab.totalRoles() == 12
assert rolesTab.totalEnabledRoles() == 1
assert rolesTab.hasEnabledRole('ROLE_USER')

when: "ROLE_ADMIN is enabled and the changes are saved"
rolesTab.enableRole "ROLE_ADMIN"
@@ -200,6 +201,7 @@ class UserSpec extends AbstractSecuritySpec {

then: "12 roles are listed and 2 are enabled"
assert rolesTab.totalEnabledRoles() == 2
assert rolesTab.hasEnabledRoles(['ROLE_USER', 'ROLE_ADMIN'])
assert rolesTab.totalRoles() == 12
}
}

0 comments on commit 0b982d4

Please # to comment.