Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rails_helper'
- class AuthenticationController < ApplicationController
- before_action :authenticate_auth_user!
- def index
- render text: 'Super secret stuff!'
- end
- end
- RSpec.describe AuthenticationController, type: :controller do
- describe 'GET #index' do
- context 'user logged in' do
- it "responds with an HTTP 200 status code" do
- user = User.create(email: "testmail@testserv.com", password: "qwerty123", password_confirmation: "qwerty123")
- sign_in user
- routes.draw { get "index" => "authentication#index" }
- get :index, format: :json
- expect(response).to have_http_status(200)
- end
- end
- context 'user doesn\'t logged in' do
- it "responds with an HTTP 401 status code" do
- routes.draw { get "index" => "authentication#index" }
- get :index, format: :json
- expect(response).to have_http_status(401)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement