2016-03-28 01:06:52 +03:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Auth::SessionsController, type: :controller do
|
2016-11-17 13:29:11 +02:00
|
|
|
render_views
|
|
|
|
|
2016-03-28 01:06:52 +03:00
|
|
|
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]
|
2016-08-17 18:56:23 +03:00
|
|
|
post :create, params: { user: { email: user.email, password: user.password } }
|
2016-03-28 01:06:52 +03:00
|
|
|
end
|
|
|
|
|
2016-09-27 00:55:21 +03:00
|
|
|
it 'redirects to home' do
|
2016-03-28 01:06:52 +03:00
|
|
|
expect(response).to redirect_to(root_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'logs the user in' do
|
|
|
|
expect(controller.current_user).to eq user
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|