Class: PermissionsObject
- Inherits:
-
Object
- Object
- PermissionsObject
- Includes:
- DataFactory, Foundry, Navigation
- Defined in:
- lib/kuality-coeus/data_objects/proposal_development/permissions.rb
Instance Attribute Summary collapse
-
#aggregators ⇒ Object
Returns the value of attribute aggregators.
-
#approvers ⇒ Object
Returns the value of attribute approvers.
-
#budget_creators ⇒ Object
Returns the value of attribute budget_creators.
-
#delete_proposals ⇒ Object
Returns the value of attribute delete_proposals.
-
#document_id ⇒ Object
Returns the value of attribute document_id.
-
#narrative_writers ⇒ Object
Returns the value of attribute narrative_writers.
-
#viewers ⇒ Object
Returns the value of attribute viewers.
Instance Method Summary collapse
-
#add_roles(username, *roles) ⇒ Object
This method is used when the user is already assigned a role and you need to assign them more roles.
-
#assign ⇒ Object
It’s important to realize that this method assigns users to roles, but does not check who is already assigned.
- #delete(username) ⇒ Object
-
#initialize(browser, opts = {}) ⇒ PermissionsObject
constructor
A new instance of PermissionsObject.
Methods included from Navigation
#doc_search, #fill_out, #fill_out_item, #on_document?, #on_page?, #open_document
Methods included from Utilities
#get, #make_user, #random_percentage, #set, #snake_case
Constructor Details
#initialize(browser, opts = {}) ⇒ PermissionsObject
Returns a new instance of PermissionsObject.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/kuality-coeus/data_objects/proposal_development/permissions.rb', line 10 def initialize(browser, opts={}) @browser = browser defaults = { budget_creators: [], # Arrays should contain usernames narrative_writers: [], viewers: [], delete_proposals: [], approvers: [] } (defaults.merge(opts)) requires :document_id, :aggregators end |
Instance Attribute Details
#aggregators ⇒ Object
Returns the value of attribute aggregators.
7 8 9 |
# File 'lib/kuality-coeus/data_objects/proposal_development/permissions.rb', line 7 def aggregators @aggregators end |
#approvers ⇒ Object
Returns the value of attribute approvers.
7 8 9 |
# File 'lib/kuality-coeus/data_objects/proposal_development/permissions.rb', line 7 def approvers @approvers end |
#budget_creators ⇒ Object
Returns the value of attribute budget_creators.
7 8 9 |
# File 'lib/kuality-coeus/data_objects/proposal_development/permissions.rb', line 7 def budget_creators @budget_creators end |
#delete_proposals ⇒ Object
Returns the value of attribute delete_proposals.
7 8 9 |
# File 'lib/kuality-coeus/data_objects/proposal_development/permissions.rb', line 7 def delete_proposals @delete_proposals end |
#document_id ⇒ Object
Returns the value of attribute document_id.
7 8 9 |
# File 'lib/kuality-coeus/data_objects/proposal_development/permissions.rb', line 7 def document_id @document_id end |
#narrative_writers ⇒ Object
Returns the value of attribute narrative_writers.
7 8 9 |
# File 'lib/kuality-coeus/data_objects/proposal_development/permissions.rb', line 7 def narrative_writers @narrative_writers end |
#viewers ⇒ Object
Returns the value of attribute viewers.
7 8 9 |
# File 'lib/kuality-coeus/data_objects/proposal_development/permissions.rb', line 7 def viewers @viewers end |
Instance Method Details
#add_roles(username, *roles) ⇒ Object
This method is used when the user is already assigned a role and you need to assign them more roles.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/kuality-coeus/data_objects/proposal_development/permissions.rb', line 63 def add_roles(username, *roles) # get to the right page... navigate on Permissions do |page| # click the edit role button for the right user... page.edit_role username # This opens a new window, so we have to use it... page.windows.last.use end on Roles do |page| roles.each do |role| # Set the appropriate role checkbox... page.send(snakify(role)).set # Add the username to the correct role # instance variable... get(roles.invert[role]) << username end page.save # Now we're done with the child window so we close it... page.close # Attach to the main window again... page.windows.first.use end end |
#assign ⇒ Object
It’s important to realize that this method assigns users to roles, but does not check who is already assigned. You need to make sure that the values used in the instantiation of the class are an accurate reflection of what exists in the site, if that’s important to the test.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/kuality-coeus/data_objects/proposal_development/permissions.rb', line 31 def assign navigate on Permissions do |add| # See the roles method defined below... roles.each do |inst_var, role| get(inst_var).each do |username| if add.assigned_users.include?(username) unless add.assigned_role(username).include?(role) add.edit_role username on Roles do |roles| roles.use_new_tab roles.send(StringFactory.damballa(role)).set roles.save sleep 1.2 # Need to wait for the window to close roles.use_new_tab end add.save end else add.user_name.set username add.role.select role add.add add.user_row(username).wait_until_present add.save end end end end end |
#delete(username) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/kuality-coeus/data_objects/proposal_development/permissions.rb', line 88 def delete username navigate on(Permissions).delete username roles.each do |role| get(role).delete_if { |name| name==username } end end |