You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
774 B

  1. require 'rails_helper'
  2. RSpec.describe Auth::SessionsController, type: :controller do
  3. describe 'GET #new' do
  4. before do
  5. request.env["devise.mapping"] = Devise.mappings[:user]
  6. end
  7. it 'returns http success' do
  8. get :new
  9. expect(response).to have_http_status(:success)
  10. end
  11. end
  12. describe 'POST #create' do
  13. let(:user) { Fabricate(:user, email: 'foo@bar.com', password: 'abcdefgh') }
  14. before do
  15. request.env["devise.mapping"] = Devise.mappings[:user]
  16. post :create, params: { user: { email: user.email, password: user.password } }
  17. end
  18. it 'redirects to home' do
  19. expect(response).to redirect_to(root_path)
  20. end
  21. it 'logs the user in' do
  22. expect(controller.current_user).to eq user
  23. end
  24. end
  25. end