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

Instance Method Details

#authenticate_requestObject



17
18
19
# File 'lib/simple_crud/rspec/helpers/authentication.rb', line 17

def authenticate_request
  instance_exec(&setting(:authenticate))
end

#current_userObject



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_userObject



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_keyObject



21
22
23
# File 'lib/simple_crud/rspec/helpers/authentication.rb', line 21

def owner_foreign_key
  :"#{owner_association}_id"
end

#owner_paramsObject

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