authkit 0.0.1 → 0.2.1
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.
- checksums.yaml +4 -4
- data/README.md +48 -33
- data/authkit.gemspec +0 -1
- data/lib/authkit/version.rb +1 -1
- data/lib/generators/authkit/install_generator.rb +38 -15
- data/lib/generators/authkit/templates/app/controllers/application_controller.rb +2 -2
- data/lib/generators/authkit/templates/app/controllers/password_reset_controller.rb +9 -3
- data/lib/generators/authkit/templates/app/controllers/sessions_controller.rb +9 -3
- data/lib/generators/authkit/templates/app/controllers/signup_controller.rb +44 -0
- data/lib/generators/authkit/templates/app/controllers/users_controller.rb +3 -43
- data/lib/generators/authkit/templates/app/forms/signup.rb +82 -0
- data/lib/generators/authkit/templates/app/models/user.rb +8 -3
- data/lib/generators/authkit/templates/app/views/{users → signup}/new.html.erb +6 -6
- data/lib/generators/authkit/templates/config/initializers/filter_parameter_logging.rb +22 -0
- data/lib/generators/authkit/templates/spec/controllers/application_controller_spec.rb +9 -8
- data/lib/generators/authkit/templates/spec/controllers/email_confirmation_controller_spec.rb +1 -2
- data/lib/generators/authkit/templates/spec/controllers/password_change_controller_spec.rb +1 -2
- data/lib/generators/authkit/templates/spec/controllers/password_reset_controller_spec.rb +9 -13
- data/lib/generators/authkit/templates/spec/controllers/sessions_controller_spec.rb +9 -20
- data/lib/generators/authkit/templates/spec/controllers/signup_controller_spec.rb +95 -0
- data/lib/generators/authkit/templates/spec/controllers/users_controller_spec.rb +19 -93
- data/lib/generators/authkit/templates/spec/factories/user.rb +11 -0
- data/lib/generators/authkit/templates/spec/forms/signup_spec.rb +91 -0
- data/lib/generators/authkit/templates/spec/models/user_spec.rb +9 -10
- data/lib/generators/authkit/templates/spec/spec_helper.rb +4 -0
- data/spec/spec_helper.rb +2 -0
- metadata +10 -17
@@ -1,13 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ApplicationController do
|
4
|
-
let(:
|
5
|
-
let(:
|
6
|
-
let(:
|
7
|
-
let(:unknown_session) { { user_id: "2" } }
|
4
|
+
let(:user) { create(:user) }
|
5
|
+
let(:logged_in_session) { { user_id: user.id } }
|
6
|
+
let(:unknown_session) { { user_id: user.id + 1000000 } }
|
8
7
|
|
9
8
|
before(:each) do
|
10
|
-
|
9
|
+
user
|
11
10
|
end
|
12
11
|
|
13
12
|
controller do
|
@@ -34,7 +33,9 @@ describe ApplicationController do
|
|
34
33
|
end
|
35
34
|
|
36
35
|
it "does not perform multiple finds" do
|
37
|
-
|
36
|
+
where = double
|
37
|
+
where.stub(:first).and_return(nil)
|
38
|
+
User.should_receive(:where).and_return(where)
|
38
39
|
get :new, {}, unknown_session
|
39
40
|
controller.send(:current_user).should be_nil
|
40
41
|
end
|
@@ -55,7 +56,7 @@ describe ApplicationController do
|
|
55
56
|
end
|
56
57
|
|
57
58
|
it "sets the time zone" do
|
58
|
-
|
59
|
+
User.any_instance.should_receive(:time_zone).and_return("Pacific Time (US & Canada)")
|
59
60
|
get :index, {}, logged_in_session
|
60
61
|
Time.zone.name.should == "Pacific Time (US & Canada)"
|
61
62
|
end
|
@@ -167,7 +168,7 @@ describe ApplicationController do
|
|
167
168
|
|
168
169
|
it "clears the remember token" do
|
169
170
|
get :index, {}, logged_in_session
|
170
|
-
|
171
|
+
User.any_instance.should_receive(:clear_remember_token).and_return(:true)
|
171
172
|
controller.send(:logout)
|
172
173
|
end
|
173
174
|
end
|
data/lib/generators/authkit/templates/spec/controllers/email_confirmation_controller_spec.rb
CHANGED
@@ -3,8 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe EmailConfirmationController do
|
4
4
|
render_views
|
5
5
|
|
6
|
-
let(:
|
7
|
-
let(:user) { User.new(user_params) }
|
6
|
+
let(:user) { build(:user) }
|
8
7
|
let(:token) { "TOKEN" }
|
9
8
|
|
10
9
|
describe "GET 'show'" do
|
@@ -3,8 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe PasswordChangeController do
|
4
4
|
render_views
|
5
5
|
|
6
|
-
let(:
|
7
|
-
let(:user) { User.new(user_params) }
|
6
|
+
let(:user) { build(:user) }
|
8
7
|
let(:token) { "TOKEN" }
|
9
8
|
|
10
9
|
describe "GET 'show'" do
|
@@ -3,8 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe PasswordResetController do
|
4
4
|
render_views
|
5
5
|
|
6
|
-
let(:
|
7
|
-
let(:user) { User.new(user_params) }
|
6
|
+
let(:user) { create(:user, email: "test@example.com") }
|
8
7
|
|
9
8
|
describe "GET 'show'" do
|
10
9
|
it "returns http success" do
|
@@ -15,10 +14,7 @@ describe PasswordResetController do
|
|
15
14
|
|
16
15
|
describe "POST 'create'" do
|
17
16
|
before(:each) do
|
18
|
-
|
19
|
-
User.stub(:find_by_username_or_email).with("unknown@example.com").and_return(nil)
|
20
|
-
user.stub(:persisted?).and_return(true)
|
21
|
-
user.stub(:id).and_return(1)
|
17
|
+
user
|
22
18
|
end
|
23
19
|
|
24
20
|
it "redirects the user" do
|
@@ -27,13 +23,8 @@ describe PasswordResetController do
|
|
27
23
|
end
|
28
24
|
|
29
25
|
it "finds the user by the email or user name" do
|
30
|
-
User.should_receive(:find_by_username_or_email).with("test@example.com").and_return(user)
|
31
26
|
post :create, {email: "test@example.com"}
|
32
|
-
|
33
|
-
|
34
|
-
it "downcases the email or user name" do
|
35
|
-
User.should_receive(:find_by_username_or_email).with("test@example.com").and_return(user)
|
36
|
-
post :create, {email: "TEST@EXAMPLE.COM"}
|
27
|
+
controller.send(:user).should == user
|
37
28
|
end
|
38
29
|
|
39
30
|
it "logs any current user out if it finds the user" do
|
@@ -42,7 +33,7 @@ describe PasswordResetController do
|
|
42
33
|
end
|
43
34
|
|
44
35
|
it "resets the password if it finds the user" do
|
45
|
-
|
36
|
+
User.any_instance.should_receive(:send_reset_password).and_return(true)
|
46
37
|
post :create, {email: "test@example.com"}
|
47
38
|
end
|
48
39
|
|
@@ -51,6 +42,11 @@ describe PasswordResetController do
|
|
51
42
|
post :create, {email: "unknown@example.com"}
|
52
43
|
end
|
53
44
|
|
45
|
+
it "downcases the email or user name" do
|
46
|
+
User.any_instance.should_receive(:send_reset_password).and_return(true)
|
47
|
+
post :create, {email: "TEST@EXAMPLE.COM"}
|
48
|
+
end
|
49
|
+
|
54
50
|
describe "from json" do
|
55
51
|
it "returns http success" do
|
56
52
|
post :create, {email: "test@example.com", format: "json"}
|
@@ -3,13 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe SessionsController do
|
4
4
|
render_views
|
5
5
|
|
6
|
-
let(:
|
7
|
-
let(:
|
8
|
-
let(:logged_in_session) { { user_id: "1" } }
|
9
|
-
|
10
|
-
before(:each) do
|
11
|
-
User.stub(:find_by).with("1").and_return(user)
|
12
|
-
end
|
6
|
+
let(:user) { create(:user, email: "test@example.com") }
|
7
|
+
let(:logged_in_session) { { user_id: user.id } }
|
13
8
|
|
14
9
|
describe "GET 'new'" do
|
15
10
|
it "returns http success" do
|
@@ -20,8 +15,7 @@ describe SessionsController do
|
|
20
15
|
|
21
16
|
describe "POST 'create'" do
|
22
17
|
before(:each) do
|
23
|
-
|
24
|
-
User.stub(:find_by_username_or_email).with("unknown@example.com").and_return(nil)
|
18
|
+
user
|
25
19
|
end
|
26
20
|
|
27
21
|
it "redirects the user" do
|
@@ -29,18 +23,8 @@ describe SessionsController do
|
|
29
23
|
response.should be_redirect
|
30
24
|
end
|
31
25
|
|
32
|
-
it "finds the user by the email or user name" do
|
33
|
-
User.should_receive(:find_by_username_or_email).with("test@example.com").and_return(user)
|
34
|
-
post :create, {email: "test@example.com", password: "example"}
|
35
|
-
end
|
36
|
-
|
37
|
-
it "downcases the email or user name" do
|
38
|
-
User.should_receive(:find_by_username_or_email).with("test@example.com").and_return(user)
|
39
|
-
post :create, {email: "TEST@EXAMPLE.COM", password: "example"}
|
40
|
-
end
|
41
|
-
|
42
26
|
it "authenticates if it finds the user" do
|
43
|
-
|
27
|
+
User.any_instance.should_receive(:authenticate).and_return(true)
|
44
28
|
post :create, {email: "test@example.com", password: "example"}
|
45
29
|
end
|
46
30
|
|
@@ -49,6 +33,11 @@ describe SessionsController do
|
|
49
33
|
post :create, {email: "unknown@example.com", password: "example"}
|
50
34
|
end
|
51
35
|
|
36
|
+
it "downcases the email or user name" do
|
37
|
+
User.any_instance.should_receive(:authenticate).and_return(true)
|
38
|
+
post :create, {email: "TEST@EXAMPLE.COM", password: "example"}
|
39
|
+
end
|
40
|
+
|
52
41
|
it "signs the user in" do
|
53
42
|
post :create, {email: "test@example.com", password: "example"}
|
54
43
|
controller.send(:current_user).should == user
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SignupController do
|
4
|
+
render_views
|
5
|
+
|
6
|
+
let(:signup_params) { attributes_for(:user) }
|
7
|
+
let(:invalid_params) { signup_params.merge(password: 'newpassword', password_confirmation: 'wrongpassword') }
|
8
|
+
|
9
|
+
describe "GET 'new'" do
|
10
|
+
it "returns http success" do
|
11
|
+
get :new
|
12
|
+
response.should be_success
|
13
|
+
assigns(:signup).should_not be_nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "POST 'create'" do
|
18
|
+
describe "with valid params" do
|
19
|
+
describe "from html" do
|
20
|
+
it "creates a new user" do
|
21
|
+
expect {
|
22
|
+
post :create, {signup: signup_params}, {}
|
23
|
+
}.to change(User, :count).by(1)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "confirms the email" do
|
27
|
+
User.any_instance.should_receive(:send_confirmation)
|
28
|
+
post :create, {signup: signup_params}, {}
|
29
|
+
end
|
30
|
+
|
31
|
+
it "signs the user in" do
|
32
|
+
post :create, {signup: signup_params}, {}
|
33
|
+
controller.send(:current_user).should == assigns(:signup).user
|
34
|
+
end
|
35
|
+
|
36
|
+
it "redirects to the root" do
|
37
|
+
post :create, {signup: signup_params}
|
38
|
+
response.should be_redirect
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "from json" do
|
43
|
+
it "creates the user" do
|
44
|
+
expect {
|
45
|
+
post :create, {signup: signup_params, format: 'json'}, {}
|
46
|
+
}.to change(User, :count).by(1)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "signs the user in" do
|
50
|
+
post :create, {signup: signup_params, format: 'json'}, {}
|
51
|
+
controller.send(:current_user).should == assigns(:signup).user
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns http success" do
|
55
|
+
post :create, {signup: signup_params, format: 'json'}
|
56
|
+
response.should be_success
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "with invalid params" do
|
62
|
+
describe "from html" do
|
63
|
+
it "renders the new page" do
|
64
|
+
post :create, {signup: invalid_params}, {}
|
65
|
+
response.should render_template("new")
|
66
|
+
end
|
67
|
+
|
68
|
+
it "does not create a user" do
|
69
|
+
expect {
|
70
|
+
post :create, {signup: invalid_params}, {}
|
71
|
+
}.to_not change(User, :count)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "sets the errors" do
|
75
|
+
post :create, {signup: invalid_params}, {}
|
76
|
+
assigns(:signup).should have(2).errors_on(:password_confirmation)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "from json" do
|
81
|
+
it "returns a 422" do
|
82
|
+
post :create, {signup: invalid_params, format: 'json'}, {}
|
83
|
+
response.code.should == '422'
|
84
|
+
end
|
85
|
+
|
86
|
+
it "includes the errors in the json" do
|
87
|
+
post :create, {signup: invalid_params, format: 'json'}, {}
|
88
|
+
assigns(:signup).should have(2).errors_on(:password_confirmation)
|
89
|
+
response.body.should =~ /doesn't match Password/i
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
@@ -3,100 +3,10 @@ require 'spec_helper'
|
|
3
3
|
describe UsersController do
|
4
4
|
render_views
|
5
5
|
|
6
|
-
let(:
|
6
|
+
let(:user) { create(:user, email: "test@example.com") }
|
7
|
+
let(:user_params) { attributes_for(:user) }
|
7
8
|
let(:invalid_params) { user_params.merge(password: 'newpassword', password_confirmation: 'wrongpassword') }
|
8
|
-
let(:
|
9
|
-
let(:logged_in_session) { { user_id: "1" } }
|
10
|
-
|
11
|
-
before(:each) do
|
12
|
-
User.stub(:find_by).with("1").and_return(user)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "GET 'new'" do
|
16
|
-
it "returns http success" do
|
17
|
-
get :new
|
18
|
-
response.should be_success
|
19
|
-
assigns(:user).should be_a_new(User)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "POST 'create'" do
|
24
|
-
describe "with valid params" do
|
25
|
-
describe "from html" do
|
26
|
-
it "creates a new user" do
|
27
|
-
expect {
|
28
|
-
post :create, {user: user_params}, {}
|
29
|
-
}.to change(User, :count).by(1)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "confirms the email" do
|
33
|
-
User.any_instance.should_receive(:send_confirmation)
|
34
|
-
post :create, {user: user_params}, {}
|
35
|
-
end
|
36
|
-
|
37
|
-
it "signs the user in" do
|
38
|
-
post :create, {user: user_params}, {}
|
39
|
-
controller.send(:current_user).should == assigns(:user)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "redirects to the root" do
|
43
|
-
post :create, {user: user_params}
|
44
|
-
response.should be_redirect
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "from json" do
|
49
|
-
it "creates the user" do
|
50
|
-
expect {
|
51
|
-
post :create, {user: user_params, format: 'json'}, {}
|
52
|
-
}.to change(User, :count).by(1)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "signs the user in" do
|
56
|
-
post :create, {user: user_params, format: 'json'}, {}
|
57
|
-
controller.send(:current_user).should == assigns(:user)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "returns http success" do
|
61
|
-
post :create, {user: user_params, format: 'json'}
|
62
|
-
response.should be_success
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "with invalid params" do
|
68
|
-
describe "from html" do
|
69
|
-
it "renders the new page" do
|
70
|
-
post :create, {user: invalid_params}, {}
|
71
|
-
response.should render_template("new")
|
72
|
-
end
|
73
|
-
|
74
|
-
it "does not create a user" do
|
75
|
-
expect {
|
76
|
-
post :create, {user: invalid_params}, {}
|
77
|
-
}.to_not change(User, :count)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "sets the errors" do
|
81
|
-
post :create, {user: invalid_params}, {}
|
82
|
-
assigns(:user).should have(2).errors_on(:password_confirmation)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "from json" do
|
87
|
-
it "returns a 422" do
|
88
|
-
post :create, {user: invalid_params, format: 'json'}, {}
|
89
|
-
response.code.should == '422'
|
90
|
-
end
|
91
|
-
|
92
|
-
it "includes the errors in the json" do
|
93
|
-
post :create, {user: invalid_params, format: 'json'}, {}
|
94
|
-
assigns(:user).should have(2).errors_on(:password_confirmation)
|
95
|
-
response.body.should =~ /doesn't match Password/i
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
9
|
+
let(:logged_in_session) { { user_id: user.id } }
|
100
10
|
|
101
11
|
describe "GET 'edit'" do
|
102
12
|
it "redirects if there is no current user" do
|
@@ -118,6 +28,10 @@ describe UsersController do
|
|
118
28
|
|
119
29
|
describe "with valid params" do
|
120
30
|
describe "when changing the email" do
|
31
|
+
before(:each) do
|
32
|
+
controller.stub(:current_user).and_return(user)
|
33
|
+
end
|
34
|
+
|
121
35
|
it "doesn't send the confirmation the email if unchanged" do
|
122
36
|
user.email = user.confirmation_email
|
123
37
|
user.confirmation_email = nil
|
@@ -138,6 +52,10 @@ describe UsersController do
|
|
138
52
|
end
|
139
53
|
|
140
54
|
describe "from html" do
|
55
|
+
before(:each) do
|
56
|
+
controller.stub(:current_user).and_return(user)
|
57
|
+
end
|
58
|
+
|
141
59
|
it "updates the user" do
|
142
60
|
expect {
|
143
61
|
put :update, {user: user_params.merge(first_name: "Alvarez")}, logged_in_session
|
@@ -151,6 +69,10 @@ describe UsersController do
|
|
151
69
|
end
|
152
70
|
|
153
71
|
describe "from json" do
|
72
|
+
before(:each) do
|
73
|
+
controller.stub(:current_user).and_return(user)
|
74
|
+
end
|
75
|
+
|
154
76
|
it "updates the user" do
|
155
77
|
expect {
|
156
78
|
put :update, {user: user_params.merge(first_name: "Alvarez"), format: 'json'}, logged_in_session
|
@@ -160,6 +82,10 @@ describe UsersController do
|
|
160
82
|
end
|
161
83
|
|
162
84
|
describe "with invalid params" do
|
85
|
+
before(:each) do
|
86
|
+
controller.stub(:current_user).and_return(user)
|
87
|
+
end
|
88
|
+
|
163
89
|
describe "from html" do
|
164
90
|
before(:each) do
|
165
91
|
put :update, {user: invalid_params}, logged_in_session
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Signup do
|
4
|
+
let(:signup) { Signup.new }
|
5
|
+
|
6
|
+
it "should not be persisted" do
|
7
|
+
signup.should_not be_persisted
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "validation" do
|
11
|
+
it "should validate terms of service acceptance" do
|
12
|
+
signup.terms_of_service = "1"
|
13
|
+
signup.valid?
|
14
|
+
signup.should_not have(1).errors_on(:terms_of_service)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should validate models" do
|
18
|
+
signup.user = User.new
|
19
|
+
signup.user.should_receive(:valid?).and_return(true)
|
20
|
+
signup.valid?
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should copy errors from the user to the signup" do
|
24
|
+
signup.user = User.new
|
25
|
+
signup.valid?
|
26
|
+
signup.should have(1).errors_on(:password)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "saving" do
|
31
|
+
it "should validate" do
|
32
|
+
signup.should_receive(:valid?)
|
33
|
+
signup.save
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "when valid" do
|
37
|
+
it "should persist" do
|
38
|
+
signup.user = User.new
|
39
|
+
signup.should_receive(:valid?).and_return(true)
|
40
|
+
signup.user.should_receive(:save!)
|
41
|
+
signup.save
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should send the welcome" do
|
45
|
+
signup.user = User.new
|
46
|
+
signup.should_receive(:valid?).and_return(true)
|
47
|
+
signup.stub(:persist!)
|
48
|
+
signup.user.should_receive(:send_welcome)
|
49
|
+
signup.save
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should send the confirmation" do
|
53
|
+
signup.user = User.new
|
54
|
+
signup.should_receive(:valid?).and_return(true)
|
55
|
+
signup.stub(:persist!)
|
56
|
+
signup.user.should_receive(:send_confirmation)
|
57
|
+
signup.save
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "when invalid" do
|
62
|
+
it "should not persist" do
|
63
|
+
signup.should_receive(:valid?).and_return(false)
|
64
|
+
signup.should_not_receive(:persist!)
|
65
|
+
signup.save
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should not send the welcome" do
|
69
|
+
signup.should_receive(:valid?).and_return(false)
|
70
|
+
signup.should_not_receive(:send_welcome)
|
71
|
+
signup.save
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should not send the confirmation" do
|
75
|
+
signup.should_receive(:valid?).and_return(false)
|
76
|
+
signup.should_not_receive(:send_confirmation)
|
77
|
+
signup.save
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should create a new user" do
|
83
|
+
user = User.new
|
84
|
+
User.should_receive(:new).and_return(user)
|
85
|
+
user.stub(:valid?).and_return(true)
|
86
|
+
user.should_receive(:save!)
|
87
|
+
signup.stub(:valid?).and_return(true)
|
88
|
+
signup.save
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe User do
|
4
|
-
let(:user_params) {
|
4
|
+
let(:user_params) { attributes_for(:user) }
|
5
5
|
|
6
6
|
it "has secure password support" do
|
7
7
|
User.new.should respond_to(:authenticate)
|
@@ -32,7 +32,7 @@ describe User do
|
|
32
32
|
describe "validations" do
|
33
33
|
describe "unique" do
|
34
34
|
before(:each) do
|
35
|
-
|
35
|
+
create(:user)
|
36
36
|
end
|
37
37
|
it { should validate_uniqueness_of(:username) }
|
38
38
|
it { should validate_uniqueness_of(:email) }
|
@@ -53,11 +53,10 @@ describe User do
|
|
53
53
|
|
54
54
|
describe "tokens" do
|
55
55
|
it "finds a user from a token" do
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
User.
|
60
|
-
User.user_from_token(token).should == user
|
56
|
+
user = create(:user)
|
57
|
+
verifier = ActiveSupport::MessageVerifier.new(Rails.application.config.secret_key_base)
|
58
|
+
token = verifier.generate(user.id)
|
59
|
+
User.user_from_token(token).id.should == user.id
|
61
60
|
end
|
62
61
|
|
63
62
|
it "does not find a user from an invalid token" do
|
@@ -171,7 +170,7 @@ describe User do
|
|
171
170
|
end
|
172
171
|
|
173
172
|
describe "emails" do
|
174
|
-
let(:user) {
|
173
|
+
let(:user) { build(:user) }
|
175
174
|
|
176
175
|
describe "with valid params" do
|
177
176
|
it "confirms the email" do
|
@@ -219,7 +218,7 @@ describe User do
|
|
219
218
|
end
|
220
219
|
|
221
220
|
it "does not confirm emails if they are already used" do
|
222
|
-
|
221
|
+
create(:user, email: "new@example.com", username: "newuser")
|
223
222
|
user.confirmation_email = "new@example.com"
|
224
223
|
user.confirmation_token = "TOKEN"
|
225
224
|
user.email_confirmed.should == false
|
@@ -229,7 +228,7 @@ describe User do
|
|
229
228
|
|
230
229
|
describe "passwords" do
|
231
230
|
it "changes the password if it matches" do
|
232
|
-
user =
|
231
|
+
user = build(:user)
|
233
232
|
user.should_receive(:save).and_return(true)
|
234
233
|
user.change_password("password", "password")
|
235
234
|
user.password_digest.should_not be_blank
|
data/spec/spec_helper.rb
CHANGED
@@ -11,6 +11,8 @@ RSpec.configure do |config|
|
|
11
11
|
config.use_transactional_fixtures = true
|
12
12
|
config.infer_base_class_for_anonymous_controllers = false
|
13
13
|
config.order = "random"
|
14
|
+
config.include FactoryGirl::Syntax::Methods
|
15
|
+
|
14
16
|
# Because we are not running things in Rails we need to stub some secrets
|
15
17
|
config.before(:each) { Rails.application.config.stub(:secret_token).and_return("SECRET") }
|
16
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Rafter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: mocha
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: active_model_otp
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,13 +105,16 @@ files:
|
|
119
105
|
- lib/generators/authkit/templates/app/controllers/password_change_controller.rb
|
120
106
|
- lib/generators/authkit/templates/app/controllers/password_reset_controller.rb
|
121
107
|
- lib/generators/authkit/templates/app/controllers/sessions_controller.rb
|
108
|
+
- lib/generators/authkit/templates/app/controllers/signup_controller.rb
|
122
109
|
- lib/generators/authkit/templates/app/controllers/users_controller.rb
|
110
|
+
- lib/generators/authkit/templates/app/forms/signup.rb
|
123
111
|
- lib/generators/authkit/templates/app/models/user.rb
|
124
112
|
- lib/generators/authkit/templates/app/views/password_change/show.html.erb
|
125
113
|
- lib/generators/authkit/templates/app/views/password_reset/show.html.erb
|
126
114
|
- lib/generators/authkit/templates/app/views/sessions/new.html.erb
|
115
|
+
- lib/generators/authkit/templates/app/views/signup/new.html.erb
|
127
116
|
- lib/generators/authkit/templates/app/views/users/edit.html.erb
|
128
|
-
- lib/generators/authkit/templates/
|
117
|
+
- lib/generators/authkit/templates/config/initializers/filter_parameter_logging.rb
|
129
118
|
- lib/generators/authkit/templates/db/migrate/add_authkit_fields_to_users.rb
|
130
119
|
- lib/generators/authkit/templates/db/migrate/create_users.rb
|
131
120
|
- lib/generators/authkit/templates/lib/email_format_validator.rb
|
@@ -134,8 +123,12 @@ files:
|
|
134
123
|
- lib/generators/authkit/templates/spec/controllers/password_change_controller_spec.rb
|
135
124
|
- lib/generators/authkit/templates/spec/controllers/password_reset_controller_spec.rb
|
136
125
|
- lib/generators/authkit/templates/spec/controllers/sessions_controller_spec.rb
|
126
|
+
- lib/generators/authkit/templates/spec/controllers/signup_controller_spec.rb
|
137
127
|
- lib/generators/authkit/templates/spec/controllers/users_controller_spec.rb
|
128
|
+
- lib/generators/authkit/templates/spec/factories/user.rb
|
129
|
+
- lib/generators/authkit/templates/spec/forms/signup_spec.rb
|
138
130
|
- lib/generators/authkit/templates/spec/models/user_spec.rb
|
131
|
+
- lib/generators/authkit/templates/spec/spec_helper.rb
|
139
132
|
- spec/spec_helper.rb
|
140
133
|
homepage: https://github.com/jeffrafter/authkit
|
141
134
|
licenses:
|