blob: be81527d4d891c23f307223f9007d4fe83936d58 (
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
|
require 'rails_helper'
RSpec.describe SessionsController, type: :controller do
describe "GET #new" do
it "returns http success" do
get :new
expect(response).to have_http_status(:success)
end
it "loads a new user" do
get :new
expect(assigns(:user)).to be_new_record
end
end
describe "GET #create" do
context "when credentials are valid" do
let(:user) { create(:user) }
before { get :create, username: user.username, password: 'password' }
it "creates a new session for the user" do
expect(session[:x]).to eql(user.id)
end
it "redirects the user to the dashboard" do
expect(response).to redirect_to(agents_path)
end
end
end
describe "GET #destroy" do
it "returns http success" do
get :destroy
expect(response).to have_http_status(:success)
end
end
end
|