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.

33 lines
790 B

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