Commit ff2cbc07 authored by Eugen Rochko's avatar Eugen Rochko

Remember me enabled by default

parent c38ad208
class Auth::SessionsController < Devise::SessionsController
include Devise::Controllers::Rememberable
layout 'auth'
def create
super do |resource|
remember_me(resource)
end
end
end
......@@ -11,8 +11,4 @@ class User < ActiveRecord::Base
def admin?
self.admin
end
def remember_me
(super == nil) ? '1' : super
end
end
require 'rails_helper'
RSpec.describe Auth::SessionsController, type: :controller do
describe 'GET #new' do
before do
request.env["devise.mapping"] = Devise.mappings[:user]
end
it 'returns http success' do
get :new
expect(response).to have_http_status(:success)
end
end
describe 'POST #create' do
let(:user) { Fabricate(:user, email: 'foo@bar.com', password: 'abcdefgh') }
before do
request.env["devise.mapping"] = Devise.mappings[:user]
post :create, user: { email: user.email, password: user.password }
end
it 'redirects to home page' do
expect(response).to redirect_to(root_path)
end
it 'logs the user in' do
expect(controller.current_user).to eq user
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment