Module: Plutonium::Testing::AuthHelpers
- Extended by:
- ActiveSupport::Concern
- Included in:
- NestedResource, PortalAccess, ResourceCrud
- Defined in:
- lib/plutonium/testing/auth_helpers.rb
Instance Method Summary collapse
- #current_account(portal: nil) ⇒ Object
- #login_as(account, portal: nil) ⇒ Object
- #sign_out(portal: nil) ⇒ Object
- #with_portal(portal) ⇒ Object
Instance Method Details
#current_account(portal: nil) ⇒ Object
25 26 27 28 |
# File 'lib/plutonium/testing/auth_helpers.rb', line 25 def current_account(portal: nil) portal ||= current_portal instance_variable_get(:"@__current_account_#{portal}") end |
#login_as(account, portal: nil) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/plutonium/testing/auth_helpers.rb', line 8 def login_as(account, portal: nil) portal ||= current_portal if respond_to?(:sign_in_for_tests) sign_in_for_tests(account, portal: portal) else default_rodauth_login(account, portal: portal) end instance_variable_set(:"@__current_account_#{portal}", account) end |
#sign_out(portal: nil) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/plutonium/testing/auth_helpers.rb', line 18 def sign_out(portal: nil) portal ||= current_portal post logout_path_for(portal) follow_redirect! if response.redirect? instance_variable_set(:"@__current_account_#{portal}", nil) end |
#with_portal(portal) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/plutonium/testing/auth_helpers.rb', line 30 def with_portal(portal) prev = @__portal_override @__portal_override = portal yield ensure @__portal_override = prev end |