Module: SimpleCrud::RSpec::Helpers::Authentication
- Included in:
- SimpleCrud::RSpec::Helpers
- Defined in:
- lib/simple_crud/rspec/helpers/authentication.rb
Overview
Current/other users, signing requests in and the owner association attributed to the current user.
Instance Method Summary collapse
- #authenticate_request ⇒ Object
- #current_user ⇒ Object
- #other_user ⇒ Object
- #owner_foreign_key ⇒ Object
-
#owner_params ⇒ Object
The owner association attributed to current_user, if the model has one.
Instance Method Details
#authenticate_request ⇒ Object
17 18 19 |
# File 'lib/simple_crud/rspec/helpers/authentication.rb', line 17 def authenticate_request instance_exec(&setting(:authenticate)) end |
#current_user ⇒ Object
9 10 11 |
# File 'lib/simple_crud/rspec/helpers/authentication.rb', line 9 def current_user @current_user ||= instance_exec(&setting(:current_user)) end |
#other_user ⇒ Object
13 14 15 |
# File 'lib/simple_crud/rspec/helpers/authentication.rb', line 13 def other_user @other_user ||= instance_exec(&setting(:other_user)) end |
#owner_foreign_key ⇒ Object
21 22 23 |
# File 'lib/simple_crud/rspec/helpers/authentication.rb', line 21 def owner_foreign_key :"#{owner_association}_id" end |
#owner_params ⇒ Object
The owner association attributed to current_user, if the model has one.
26 27 28 |
# File 'lib/simple_crud/rspec/helpers/authentication.rb', line 26 def owner_params owner_association ? { owner_foreign_key => current_user.id } : {} end |