authenticate 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,82 +0,0 @@
1
- require 'spec_helper'
2
- require 'support/controllers/controller_helpers'
3
-
4
- describe Authenticate::UsersController, type: :controller do
5
- it { is_expected.to be_a Authenticate::Controller }
6
-
7
- describe 'get to #new' do
8
- context 'not signed in' do
9
- it 'renders form' do
10
- get :new
11
- expect(response).to be_success
12
- expect(response).to render_template(:new)
13
- end
14
- it 'defaults email field to the value provided in the query string' do
15
- get :new, user: { email: 'dude@example.com' }
16
- expect(assigns(:user).email).to eq 'dude@example.com'
17
- expect(response).to be_success
18
- expect(response).to render_template(:new)
19
- end
20
- end
21
- context 'signed in' do
22
- it 'redirects user to the redirect_url' do
23
- sign_in
24
- get :new
25
- expect(response).to redirect_to Authenticate.configuration.redirect_url
26
- end
27
- end
28
- end
29
-
30
- describe 'post to #create' do
31
- context 'not signed in' do
32
- context 'with valid attributes' do
33
- let(:user_attributes) { attributes_for(:user) }
34
- subject { post :create, user: user_attributes }
35
-
36
- it 'creates user' do
37
- expect { subject }.to change { User.count }.by(1)
38
- end
39
-
40
- it 'assigned user' do
41
- subject
42
- expect(assigns(:user)).to be_present
43
- end
44
-
45
- it 'redirects to the redirect_url' do
46
- subject
47
- expect(response).to redirect_to Authenticate.configuration.redirect_url
48
- end
49
- end
50
-
51
- context 'with valid attributes and a session return cookie' do
52
- before do
53
- @request.cookies[:authenticate_return_to] = '/url_in_the_session'
54
- end
55
- let(:user_attributes) { attributes_for(:user) }
56
- subject { post :create, user: user_attributes }
57
-
58
- it 'creates user' do
59
- expect { subject }.to change { User.count }.by(1)
60
- end
61
-
62
- it 'assigned user' do
63
- subject
64
- expect(assigns(:user)).to be_present
65
- end
66
-
67
- it 'redirects to the redirect_url' do
68
- subject
69
- expect(response).to redirect_to '/url_in_the_session'
70
- end
71
- end
72
- end
73
-
74
- context 'signed in' do
75
- it 'redirects to redirect_url' do
76
- sign_in
77
- post :create, user: {}
78
- expect(response).to redirect_to Authenticate.configuration.redirect_url
79
- end
80
- end
81
- end
82
- end