mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-15 13:45:25 +08:00
24 lines
509 B
Ruby
24 lines
509 B
Ruby
module ControllerMacros
|
|
def login_user
|
|
before(:each) do
|
|
@request.env['devise.mapping'] = Devise.mappings[:user]
|
|
user = create :user
|
|
user.confirm
|
|
sign_in user
|
|
end
|
|
end
|
|
|
|
def login_api_user
|
|
before(:each) do
|
|
user = create :user
|
|
user.confirm
|
|
|
|
@request.headers.merge!({
|
|
'Authorization': 'Bearer ' + Api::CoreJwt.encode(sub: user.id),
|
|
'Content-Type': 'application/json'
|
|
})
|
|
|
|
subject.send(:authenticate_request!)
|
|
end
|
|
end
|
|
end
|