authkit 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -3
- data/Rakefile +3 -2
- data/lib/authkit/version.rb +1 -1
- data/lib/generators/authkit/install_generator.rb +181 -35
- data/lib/generators/authkit/templates/app/controllers/application_controller.rb +6 -0
- data/lib/generators/authkit/templates/app/controllers/auths_controller.rb +144 -0
- data/lib/generators/authkit/templates/app/controllers/email_confirmation_controller.rb +1 -1
- data/lib/generators/authkit/templates/app/controllers/password_reset_controller.rb +7 -1
- data/lib/generators/authkit/templates/app/controllers/sessions_controller.rb +11 -2
- data/lib/generators/authkit/templates/app/controllers/signup_controller.rb +4 -2
- data/lib/generators/authkit/templates/app/controllers/upload_controller.rb +78 -0
- data/lib/generators/authkit/templates/app/controllers/users_controller.rb +2 -2
- data/lib/generators/authkit/templates/app/forms/signup.rb +57 -7
- data/lib/generators/authkit/templates/app/helpers/auths_helper.rb +26 -0
- data/lib/generators/authkit/templates/app/helpers/upload_helper.rb +118 -0
- data/lib/generators/authkit/templates/app/models/auth.rb +81 -0
- data/lib/generators/authkit/templates/app/models/avatar.rb +45 -0
- data/lib/generators/authkit/templates/app/models/user.rb +53 -26
- data/lib/generators/authkit/templates/app/views/auths/connect.html.erb +34 -0
- data/lib/generators/authkit/templates/app/views/password_change/show.html.erb +9 -9
- data/lib/generators/authkit/templates/app/views/password_reset/show.html.erb +6 -6
- data/lib/generators/authkit/templates/app/views/sessions/new.html.erb +25 -7
- data/lib/generators/authkit/templates/app/views/signup/new.html.erb +44 -32
- data/lib/generators/authkit/templates/app/views/users/complete.html.erb +39 -0
- data/lib/generators/authkit/templates/app/views/users/edit.html.erb +31 -31
- data/lib/generators/authkit/templates/app/workers/avatar_import_worker.rb +12 -0
- data/lib/generators/authkit/templates/config/initializers/filter_parameter_logging.rb +2 -2
- data/lib/generators/authkit/templates/config/initializers/omniauth.rb +59 -0
- data/lib/generators/authkit/templates/config/initializers/paperclip.rb +68 -0
- data/lib/generators/authkit/templates/db/migrate/add_authkit_fields_to_users.rb +8 -6
- data/lib/generators/authkit/templates/db/migrate/create_auths.rb +24 -0
- data/lib/generators/authkit/templates/db/migrate/create_avatars.rb +27 -0
- data/lib/generators/authkit/templates/lib/full_name_splitter.rb +111 -0
- data/lib/generators/authkit/templates/lib/username_format_validator.rb +11 -0
- data/lib/generators/authkit/templates/spec/controllers/application_controller_spec.rb +31 -38
- data/lib/generators/authkit/templates/spec/controllers/auths_controller_spec.rb +72 -0
- data/lib/generators/authkit/templates/spec/controllers/email_confirmation_controller_spec.rb +25 -27
- data/lib/generators/authkit/templates/spec/controllers/password_change_controller_spec.rb +30 -30
- data/lib/generators/authkit/templates/spec/controllers/password_reset_controller_spec.rb +20 -20
- data/lib/generators/authkit/templates/spec/controllers/sessions_controller_spec.rb +33 -33
- data/lib/generators/authkit/templates/spec/controllers/signup_controller_spec.rb +19 -19
- data/lib/generators/authkit/templates/spec/controllers/users_controller_spec.rb +21 -21
- data/lib/generators/authkit/templates/spec/factories/user.rb +3 -3
- data/lib/generators/authkit/templates/spec/forms/signup_spec.rb +32 -31
- data/lib/generators/authkit/templates/spec/models/auth_spec.rb +18 -0
- data/lib/generators/authkit/templates/spec/models/user_spec.rb +72 -78
- data/spec/rails_helper.rb +50 -0
- data/spec/spec_helper.rb +70 -13
- metadata +35 -17
- data/lib/generators/authkit/templates/spec/spec_helper.rb +0 -4
@@ -1,15 +1,15 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
3
|
describe SessionsController do
|
4
4
|
render_views
|
5
5
|
|
6
|
-
let(:user) { create(:user
|
6
|
+
let(:user) { create(:user) }
|
7
7
|
let(:logged_in_session) { { user_id: user.id } }
|
8
8
|
|
9
9
|
describe "GET 'new'" do
|
10
10
|
it "returns http success" do
|
11
11
|
get 'new'
|
12
|
-
response.
|
12
|
+
expect(response).to be_success
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -19,73 +19,73 @@ describe SessionsController do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "redirects the user" do
|
22
|
-
post :create, {email:
|
23
|
-
response.
|
22
|
+
post :create, {email: user.email, password: "example"}
|
23
|
+
expect(response).to be_redirect
|
24
24
|
end
|
25
25
|
|
26
26
|
it "authenticates if it finds the user" do
|
27
|
-
User.
|
28
|
-
post :create, {email:
|
27
|
+
expect_any_instance_of(User).to receive(:authenticate).and_return(true)
|
28
|
+
post :create, {email: user.email, password: "example"}
|
29
29
|
end
|
30
30
|
|
31
31
|
it "does not authenticate if it does not find a user" do
|
32
|
-
User.
|
32
|
+
expect_any_instance_of(User).to_not receive(:authenticate)
|
33
33
|
post :create, {email: "unknown@example.com", password: "example"}
|
34
34
|
end
|
35
35
|
|
36
36
|
it "downcases the email or user name" do
|
37
|
-
User.
|
38
|
-
post :create, {email:
|
37
|
+
expect_any_instance_of(User).to receive(:authenticate).and_return(true)
|
38
|
+
post :create, {email: user.email, password: "example"}
|
39
39
|
end
|
40
40
|
|
41
41
|
it "signs the user in" do
|
42
|
-
post :create, {email:
|
43
|
-
controller.send(:current_user).
|
42
|
+
post :create, {email: user.email, password: "example"}
|
43
|
+
expect(controller.send(:current_user)).to eq(user)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "remembers the user if remember me is chosen" do
|
47
|
-
User.
|
48
|
-
controller.
|
49
|
-
post :create, {email:
|
50
|
-
controller.send(:current_user).
|
47
|
+
expect_any_instance_of(User).to receive(:set_remember_token)
|
48
|
+
expect(controller).to receive(:set_remember_cookie)
|
49
|
+
post :create, {email: user.email, password: "example", remember_me: "1"}
|
50
|
+
expect(controller.send(:current_user)).to eq(user)
|
51
51
|
end
|
52
52
|
|
53
53
|
it "does not remember the user if remember me is not chosen" do
|
54
|
-
User.
|
55
|
-
controller.
|
56
|
-
post :create, {email:
|
57
|
-
controller.send(:current_user).
|
54
|
+
expect_any_instance_of(User).to_not receive(:set_remember_token)
|
55
|
+
expect(controller).to_not receive(:set_remember_cookie)
|
56
|
+
post :create, {email: user.email, password: "example", remember_me: ""}
|
57
|
+
expect(controller.send(:current_user)).to eq(user)
|
58
58
|
end
|
59
59
|
|
60
60
|
describe "from json" do
|
61
61
|
it "returns http success" do
|
62
|
-
post :create, {email:
|
63
|
-
response.
|
62
|
+
post :create, {email: user.email, password: "example", format: "json"}
|
63
|
+
expect(response).to be_success
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe "with invalid password" do
|
68
68
|
describe "from html" do
|
69
69
|
it "sets the flash message" do
|
70
|
-
post :create, {email:
|
71
|
-
flash.now[:error].
|
70
|
+
post :create, {email: user.email, password: "wrongpassword"}
|
71
|
+
expect(flash.now[:error]).to_not be_empty
|
72
72
|
end
|
73
73
|
|
74
74
|
it "renders the new page" do
|
75
|
-
post :create, {email:
|
76
|
-
response.
|
75
|
+
post :create, {email: user.email, password: "wrongpassword"}
|
76
|
+
expect(response).to render_template(:new)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
80
|
describe "from json" do
|
81
81
|
it "returns an error" do
|
82
|
-
post :create, {email:
|
83
|
-
response.body.
|
82
|
+
post :create, {email: user.email, password: "wrongpassword", format: "json"}
|
83
|
+
expect(response.body).to match(/invalid user name or password/i)
|
84
84
|
end
|
85
85
|
|
86
86
|
it "returns forbidden status" do
|
87
|
-
post :create, {email:
|
88
|
-
response.code.
|
87
|
+
post :create, {email: user.email, password: "wrongpassword", format: "json"}
|
88
|
+
expect(response.code).to eq('422')
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
@@ -94,20 +94,20 @@ describe SessionsController do
|
|
94
94
|
describe "DELETE 'destroy'" do
|
95
95
|
it "logs the user out" do
|
96
96
|
delete "destroy", {}, logged_in_session
|
97
|
-
controller.send(:current_user).
|
97
|
+
expect(controller.send(:current_user)).to be_nil
|
98
98
|
end
|
99
99
|
|
100
100
|
describe "from html" do
|
101
101
|
it "redirects the user" do
|
102
102
|
delete "destroy", {}, logged_in_session
|
103
|
-
response.
|
103
|
+
expect(response).to redirect_to(root_path)
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
107
|
describe "from json" do
|
108
108
|
it "returns http success" do
|
109
109
|
delete "destroy", {format: 'json'}, logged_in_session
|
110
|
-
response.
|
110
|
+
expect(response).to be_success
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
3
|
describe SignupController do
|
4
4
|
render_views
|
@@ -9,8 +9,8 @@ describe SignupController do
|
|
9
9
|
describe "GET 'new'" do
|
10
10
|
it "returns http success" do
|
11
11
|
get :new
|
12
|
-
response.
|
13
|
-
assigns(:signup).
|
12
|
+
expect(response).to be_success
|
13
|
+
expect(assigns(:signup)).to_not be_nil
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -24,32 +24,32 @@ describe SignupController do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "confirms the email" do
|
27
|
-
User.
|
27
|
+
expect_any_instance_of(User).to receive(:send_confirmation)
|
28
28
|
post :create, {signup: signup_params}, {}
|
29
29
|
end
|
30
30
|
|
31
31
|
it "signs the user in" do
|
32
32
|
post :create, {signup: signup_params}, {}
|
33
|
-
controller.send(:current_user).
|
33
|
+
expect(controller.send(:current_user)).to eq(assigns(:signup).user)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "remembers the user if remember me is chosen" do
|
37
|
-
User.
|
38
|
-
controller.
|
37
|
+
expect_any_instance_of(User).to receive(:set_remember_token)
|
38
|
+
expect(controller).to receive(:set_remember_cookie)
|
39
39
|
post :create, {signup: signup_params, remember_me: "1"}, {}
|
40
|
-
controller.send(:current_user).
|
40
|
+
expect(controller.send(:current_user)).to eq(assigns(:signup).user)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "does not remember the user if remember me is not chosen" do
|
44
|
-
User.
|
45
|
-
controller.
|
44
|
+
expect_any_instance_of(User).to_not receive(:set_remember_token)
|
45
|
+
expect(controller).to_not receive(:set_remember_cookie)
|
46
46
|
post :create, {signup: signup_params, remember_me: ""}, {}
|
47
|
-
controller.send(:current_user).
|
47
|
+
expect(controller.send(:current_user)).to eq(assigns(:signup).user)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "redirects to the root" do
|
51
51
|
post :create, {signup: signup_params}
|
52
|
-
response.
|
52
|
+
expect(response).to be_redirect
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -62,12 +62,12 @@ describe SignupController do
|
|
62
62
|
|
63
63
|
it "signs the user in" do
|
64
64
|
post :create, {signup: signup_params, format: 'json'}, {}
|
65
|
-
controller.send(:current_user).
|
65
|
+
expect(controller.send(:current_user)).to eq(assigns(:signup).user)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "returns http success" do
|
69
69
|
post :create, {signup: signup_params, format: 'json'}
|
70
|
-
response.
|
70
|
+
expect(response).to be_success
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -76,7 +76,7 @@ describe SignupController do
|
|
76
76
|
describe "from html" do
|
77
77
|
it "renders the new page" do
|
78
78
|
post :create, {signup: invalid_params}, {}
|
79
|
-
response.
|
79
|
+
expect(response).to render_template("new")
|
80
80
|
end
|
81
81
|
|
82
82
|
it "does not create a user" do
|
@@ -87,20 +87,20 @@ describe SignupController do
|
|
87
87
|
|
88
88
|
it "sets the errors" do
|
89
89
|
post :create, {signup: invalid_params}, {}
|
90
|
-
assigns(:signup).
|
90
|
+
expect(assigns(:signup).errors[:password_confirmation].size).to eq(1)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
describe "from json" do
|
95
95
|
it "returns a 422" do
|
96
96
|
post :create, {signup: invalid_params, format: 'json'}, {}
|
97
|
-
response.code.
|
97
|
+
expect(response.code).to eq('422')
|
98
98
|
end
|
99
99
|
|
100
100
|
it "includes the errors in the json" do
|
101
101
|
post :create, {signup: invalid_params, format: 'json'}, {}
|
102
|
-
assigns(:signup).
|
103
|
-
response.body.
|
102
|
+
expect(assigns(:signup).errors[:password_confirmation].size).to eq(1)
|
103
|
+
expect(response.body).to match(/doesn't match Password/i)
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
3
|
describe UsersController do
|
4
4
|
render_views
|
5
5
|
|
6
|
-
let(:user) { create(:user
|
6
|
+
let(:user) { create(:user) }
|
7
7
|
let(:user_params) { attributes_for(:user) }
|
8
8
|
let(:invalid_params) { user_params.merge(password: 'newpassword', password_confirmation: 'wrongpassword') }
|
9
9
|
let(:logged_in_session) { { user_id: user.id } }
|
@@ -11,49 +11,49 @@ describe UsersController do
|
|
11
11
|
describe "GET 'edit'" do
|
12
12
|
it "redirects if there is no current user" do
|
13
13
|
get :edit
|
14
|
-
response.
|
14
|
+
expect(response).to be_redirect
|
15
15
|
end
|
16
16
|
|
17
17
|
it "edits the current user" do
|
18
18
|
get :edit, {}, logged_in_session
|
19
|
-
response.
|
19
|
+
expect(response).to be_success
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "PUT 'update'" do
|
24
24
|
it "redirects if there is no current user" do
|
25
25
|
put :update, {user: user_params.merge(first_name: "Alvarez")}
|
26
|
-
response.
|
26
|
+
expect(response).to be_redirect
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "with valid params" do
|
30
30
|
describe "when changing the email" do
|
31
31
|
before(:each) do
|
32
|
-
controller.
|
32
|
+
allow(controller).to receive(:current_user).and_return(user)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "doesn't send the confirmation the email if unchanged" do
|
36
36
|
user.email = user.confirmation_email
|
37
37
|
user.confirmation_email = nil
|
38
|
-
user.
|
39
|
-
put :update, {user: user_params.merge(confirmation_email:
|
38
|
+
expect(user).to_not receive(:send_confirmation)
|
39
|
+
put :update, {user: user_params.merge(confirmation_email: user.email)}, logged_in_session
|
40
40
|
end
|
41
41
|
|
42
42
|
it "doesn't reconfirm if the confirmation email is unchanged" do
|
43
|
-
user.
|
44
|
-
put :update, {user: user_params.merge(confirmation_email:
|
43
|
+
expect(user).to_not receive(:send_confirmation)
|
44
|
+
put :update, {user: user_params.merge(confirmation_email: user.email)}, logged_in_session
|
45
45
|
end
|
46
46
|
|
47
47
|
it "confirms the confirmation email" do
|
48
48
|
user.email = "old@example.com"
|
49
|
-
user.
|
49
|
+
expect(user).to receive(:send_confirmation).and_return(true)
|
50
50
|
put :update, {user: user_params.merge(confirmation_email: "new@example.com")}, logged_in_session
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
describe "from html" do
|
55
55
|
before(:each) do
|
56
|
-
controller.
|
56
|
+
allow(controller).to receive(:current_user).and_return(user)
|
57
57
|
end
|
58
58
|
|
59
59
|
it "updates the user" do
|
@@ -64,13 +64,13 @@ describe UsersController do
|
|
64
64
|
|
65
65
|
it "redirects the user" do
|
66
66
|
put :update, {user: user_params}, logged_in_session
|
67
|
-
response.
|
67
|
+
expect(response).to be_redirect
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
describe "from json" do
|
72
72
|
before(:each) do
|
73
|
-
controller.
|
73
|
+
allow(controller).to receive(:current_user).and_return(user)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "updates the user" do
|
@@ -83,7 +83,7 @@ describe UsersController do
|
|
83
83
|
|
84
84
|
describe "with invalid params" do
|
85
85
|
before(:each) do
|
86
|
-
controller.
|
86
|
+
allow(controller).to receive(:current_user).and_return(user)
|
87
87
|
end
|
88
88
|
|
89
89
|
describe "from html" do
|
@@ -92,12 +92,12 @@ describe UsersController do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it "renders the edit page" do
|
95
|
-
response.
|
96
|
-
response.
|
95
|
+
expect(response).to render_template('edit')
|
96
|
+
expect(response).to be_success
|
97
97
|
end
|
98
98
|
|
99
99
|
it "sets the errors" do
|
100
|
-
user.
|
100
|
+
expect(user.errors[:password_confirmation].size).to eq(1)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -107,12 +107,12 @@ describe UsersController do
|
|
107
107
|
end
|
108
108
|
|
109
109
|
it "returns a 422" do
|
110
|
-
response.code.
|
110
|
+
expect(response.code).to eq('422')
|
111
111
|
end
|
112
112
|
|
113
113
|
it "includes the errors in the json" do
|
114
|
-
user.
|
115
|
-
response.body.
|
114
|
+
expect(user.errors[:password_confirmation].size).to eq(1)
|
115
|
+
expect(response.body).to match(/doesn't match Password/i)
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :user do
|
3
|
-
email "
|
4
|
-
username "
|
5
|
-
password "example"
|
3
|
+
sequence(:email) { |n| "user-#{n}@example.com" }
|
4
|
+
<% if username? %>sequence(:username) { |n| "user-#{n}" }
|
5
|
+
<% end %>password "example"
|
6
6
|
password_confirmation "example"
|
7
7
|
first_name "John"
|
8
8
|
last_name "Example"
|
@@ -1,93 +1,94 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
3
|
describe Signup do
|
4
4
|
let(:signup) { Signup.new }
|
5
5
|
|
6
6
|
it "should not be persisted" do
|
7
|
-
signup.
|
7
|
+
expect(signup).to_not be_persisted
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "validation" do
|
11
11
|
it "should validate terms of service acceptance" do
|
12
12
|
signup.terms_of_service = "1"
|
13
13
|
signup.valid?
|
14
|
-
signup.
|
14
|
+
expect(signup.errors[:terms_of_service].size).to eq(0)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should validate models" do
|
18
18
|
signup.user = User.new
|
19
|
-
signup.user.
|
19
|
+
expect(signup.user).to receive(:valid?).and_return(true)
|
20
20
|
signup.valid?
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should copy errors from the user to the signup" do
|
24
24
|
signup.user = User.new
|
25
25
|
signup.valid?
|
26
|
-
signup.
|
26
|
+
expect(signup.errors[:password].size).to eq(1)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "saving" do
|
31
31
|
it "should validate" do
|
32
|
-
signup.
|
32
|
+
expect(signup).to receive(:valid?)
|
33
33
|
signup.save
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "when valid" do
|
37
37
|
it "should persist" do
|
38
|
-
signup.user =
|
39
|
-
signup.
|
40
|
-
signup.user.
|
41
|
-
signup.user.should_receive(:send_confirmation)
|
38
|
+
signup.user = build(:user)
|
39
|
+
expect(signup).to receive(:valid?).and_return(true)
|
40
|
+
expect(signup.user).to receive(:save!)
|
42
41
|
signup.save
|
43
42
|
end
|
44
43
|
|
45
44
|
it "should send the welcome" do
|
46
|
-
signup.user =
|
47
|
-
signup.
|
48
|
-
signup.
|
49
|
-
signup.
|
50
|
-
signup.user.
|
45
|
+
signup.user = build(:user)
|
46
|
+
signup.email = signup.user.email
|
47
|
+
expect(signup).to receive(:valid?).and_return(true)
|
48
|
+
allow(signup).to receive(:persist!)
|
49
|
+
expect(signup.user).to receive(:send_welcome)
|
51
50
|
signup.save
|
52
51
|
end
|
53
52
|
|
54
53
|
it "should send the confirmation" do
|
55
|
-
signup.user =
|
56
|
-
signup.
|
57
|
-
signup.
|
58
|
-
signup.
|
54
|
+
signup.user = build(:user)
|
55
|
+
signup.email = signup.user.email
|
56
|
+
expect(signup).to receive(:valid?).and_return(true)
|
57
|
+
allow(signup).to receive(:persist!)
|
58
|
+
expect(signup.user).to receive(:send_confirmation)
|
59
59
|
signup.save
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
describe "when invalid" do
|
64
64
|
it "should not persist" do
|
65
|
-
signup.
|
66
|
-
signup.
|
65
|
+
expect(signup).to receive(:valid?).and_return(false)
|
66
|
+
expect(signup).to_not receive(:persist!)
|
67
67
|
signup.save
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should not send the welcome" do
|
71
|
-
signup.
|
72
|
-
signup.
|
71
|
+
expect(signup).to receive(:valid?).and_return(false)
|
72
|
+
expect(signup).to_not receive(:send_welcome!)
|
73
73
|
signup.save
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should not send the confirmation" do
|
77
|
-
signup.
|
78
|
-
signup.
|
77
|
+
expect(signup).to receive(:valid?).and_return(false)
|
78
|
+
expect(signup).to_not receive(:send_confirmation!)
|
79
79
|
signup.save
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should create a new user" do
|
85
|
-
user =
|
86
|
-
User.
|
87
|
-
user.
|
88
|
-
user.
|
89
|
-
user.
|
90
|
-
signup.
|
85
|
+
user = build(:user)
|
86
|
+
expect(User).to receive(:new).and_return(user)
|
87
|
+
allow(user).to receive(:valid?).and_return(true)
|
88
|
+
expect(user).to receive(:save!)
|
89
|
+
expect(user).to receive(:send_confirmation)
|
90
|
+
allow(signup).to receive(:valid?).and_return(true)
|
91
|
+
signup.email = "new@example.com"
|
91
92
|
signup.save
|
92
93
|
end
|
93
94
|
|