blob: 6c4756aa29b52ede8f79291118988337c6a5515e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
require "rails_helper"
describe ApplicationController do
controller do
def index
current_user
render text: 'hello'
end
end
context "when signed in" do
let(:user) { create(:user, password: 'password', password_confirmation: 'password') }
let(:user_session) { create(:session, user: user) }
before { cookies.signed[:raphael] = user_session.id }
before { get :index }
it "lets you continue to do whatever the heck you were trying to do" do
expect(response.status).to eql(200)
end
it "loads the current user" do
expect(assigns(:current_user)).to eql(user)
end
end
context "when not signed in" do
before :each do
cookies.signed[:raphael] = rand(100)
get :index
end
it "boots you out when their is no session_id" do
expect(response).to redirect_to(new_session_path)
end
it "boots you out when the session id is not known" do
expect(response).to redirect_to(new_session_path)
end
end
end
|