mirror of
https://github.com/wahyd4/libr-2.git
synced 2026-08-09 05:15:53 +10:00
14 lines
448 B
Ruby
14 lines
448 B
Ruby
module TestBaseHelper
|
|
def user_sign_in(user = double('user'))
|
|
if user.nil?
|
|
allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, {:scope => :user})
|
|
allow(controller).to receive(:current_user).and_return(nil)
|
|
else
|
|
allow(request.env['warden']).to receive(:authenticate!).and_return(user)
|
|
allow(controller).to receive(:current_user).and_return(user)
|
|
@current_user = user
|
|
end
|
|
end
|
|
end
|
|
|