require 'rails_helper' RSpec.describe "UserSignIns", type: :request do describe "GET /users/sign_in" do it "works! (now write some real specs)" do get new_user_session_path expect(response).to have_http_status(200) end end describe 'POST /users/sign_in' do context 'no user' do it 'shows appropriate message' do post user_session_path, params: {user: {email: 'user435@example.com', password: 'test124'}} # expect(response.redirect_url.to_s).to include '/users/sign_in' # get response.redirect_url expect(response.body).to include 'Invalid email or password' end end context 'unconfirmed user' do let!(:user) { create :user, password: 'test124' } it 'shows message indicating that there should be a confirmation' do post user_session_path, params: {user: {email: user.email, password: 'test124'}} expect(response.redirect_url.to_s).to include '/users/sign_in' get response.redirect_url expect(response.body).to include 'You have to confirm your account before continuing' end end context 'confirmed user' do let!(:user) { create :user, :confirmed, password: 'test124' } it 'redirects to the user app' do post user_session_path, params: {user: {email: user.email, password: 'test124'}} expect(response.redirect_url).to eq Mozo.user_url expect(response.redirect_url).to eq 'https://user.mozo.bar' end end end end