thoughtbot-clearance 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +8 -16
- data/Rakefile +12 -10
- data/TODO.textile +7 -4
- data/generators/clearance/templates/app/controllers/application.rb +1 -1
- data/generators/clearance/templates/app/controllers/confirmations_controller.rb +1 -1
- data/generators/clearance/templates/app/controllers/passwords_controller.rb +1 -1
- data/generators/clearance/templates/app/controllers/sessions_controller.rb +1 -1
- data/generators/clearance/templates/app/controllers/users_controller.rb +1 -1
- data/generators/clearance/templates/app/models/user.rb +1 -1
- data/generators/clearance/templates/app/models/user_mailer.rb +1 -1
- data/generators/clearance/templates/test/functional/confirmations_controller_test.rb +1 -1
- data/generators/clearance/templates/test/functional/passwords_controller_test.rb +1 -1
- data/generators/clearance/templates/test/functional/sessions_controller_test.rb +1 -1
- data/generators/clearance/templates/test/functional/users_controller_test.rb +1 -1
- data/generators/clearance/templates/test/unit/user_mailer_test.rb +1 -1
- data/generators/clearance/templates/test/unit/user_test.rb +1 -1
- data/lib/clearance.rb +6 -6
- data/lib/clearance/app/controllers/application_controller.rb +58 -54
- data/lib/clearance/app/controllers/confirmations_controller.rb +30 -26
- data/lib/clearance/app/controllers/passwords_controller.rb +48 -44
- data/lib/clearance/app/controllers/sessions_controller.rb +61 -56
- data/lib/clearance/app/controllers/users_controller.rb +32 -28
- data/lib/clearance/app/models/user.rb +58 -56
- data/lib/clearance/app/models/user_mailer.rb +21 -18
- data/lib/clearance/test/test_helper.rb +66 -64
- data/lib/clearance/version.rb +2 -2
- data/test/rails_root/app/controllers/application.rb +1 -1
- data/test/rails_root/app/controllers/confirmations_controller.rb +1 -1
- data/test/rails_root/app/controllers/passwords_controller.rb +1 -1
- data/test/rails_root/app/controllers/sessions_controller.rb +1 -1
- data/test/rails_root/app/controllers/users_controller.rb +1 -1
- data/test/rails_root/app/models/user.rb +1 -1
- data/test/rails_root/app/models/user_mailer.rb +1 -1
- data/test/rails_root/test/functional/confirmations_controller_test.rb +1 -1
- data/test/rails_root/test/functional/passwords_controller_test.rb +1 -1
- data/test/rails_root/test/functional/sessions_controller_test.rb +1 -1
- data/test/rails_root/test/functional/users_controller_test.rb +1 -1
- data/test/rails_root/test/test_helper.rb +1 -1
- data/test/rails_root/test/unit/user_mailer_test.rb +1 -1
- data/test/rails_root/test/unit/user_test.rb +1 -1
- metadata +34 -10
- data/lib/clearance/test/functionals/confirmations_controller_test.rb +0 -81
- data/lib/clearance/test/functionals/passwords_controller_test.rb +0 -188
- data/lib/clearance/test/functionals/sessions_controller_test.rb +0 -91
- data/lib/clearance/test/functionals/users_controller_test.rb +0 -60
- data/lib/clearance/test/units/user_mailer_test.rb +0 -34
- data/lib/clearance/test/units/user_test.rb +0 -203
data/lib/clearance/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thoughtbot-clearance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoughtbot, inc.
|
@@ -142,10 +142,8 @@ files:
|
|
142
142
|
- test/rails_root/config/routes.rb
|
143
143
|
- test/rails_root/db
|
144
144
|
- test/rails_root/db/bootstrap
|
145
|
-
- test/rails_root/db/development.sqlite3
|
146
145
|
- test/rails_root/db/migrate
|
147
146
|
- test/rails_root/db/migrate/001_create_users.rb
|
148
|
-
- test/rails_root/db/schema.rb
|
149
147
|
- test/rails_root/db/test.sqlite3
|
150
148
|
- test/rails_root/doc
|
151
149
|
- test/rails_root/doc/README_FOR_APP
|
@@ -200,8 +198,6 @@ files:
|
|
200
198
|
- test/rails_root/script/server
|
201
199
|
- test/rails_root/test
|
202
200
|
- test/rails_root/test/factories.rb
|
203
|
-
- test/rails_root/test/fixtures
|
204
|
-
- test/rails_root/test/fixtures/mailer
|
205
201
|
- test/rails_root/test/functional
|
206
202
|
- test/rails_root/test/functional/confirmations_controller_test.rb
|
207
203
|
- test/rails_root/test/functional/passwords_controller_test.rb
|
@@ -215,11 +211,6 @@ files:
|
|
215
211
|
- test/rails_root/test/unit
|
216
212
|
- test/rails_root/test/unit/user_mailer_test.rb
|
217
213
|
- test/rails_root/test/unit/user_test.rb
|
218
|
-
- test/rails_root/tmp
|
219
|
-
- test/rails_root/tmp/cache
|
220
|
-
- test/rails_root/tmp/pids
|
221
|
-
- test/rails_root/tmp/sessions
|
222
|
-
- test/rails_root/tmp/sockets
|
223
214
|
- test/rails_root/vendor
|
224
215
|
- test/rails_root/vendor/gems
|
225
216
|
- test/rails_root/vendor/gems/mocha-0.9.1
|
@@ -541,6 +532,39 @@ files:
|
|
541
532
|
- test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/unit_test.rb
|
542
533
|
- test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/USAGE
|
543
534
|
- test/rails_root/vendor/plugins/factory_girl_on_rails/README
|
535
|
+
- test/rails_root/vendor/plugins/shoulda
|
536
|
+
- test/rails_root/vendor/plugins/shoulda/bin
|
537
|
+
- test/rails_root/vendor/plugins/shoulda/lib
|
538
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda
|
539
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/action_mailer
|
540
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/active_record
|
541
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/controller
|
542
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/controller/formats
|
543
|
+
- test/rails_root/vendor/plugins/shoulda/tasks
|
544
|
+
- test/rails_root/vendor/plugins/shoulda/test
|
545
|
+
- test/rails_root/vendor/plugins/shoulda/test/fixtures
|
546
|
+
- test/rails_root/vendor/plugins/shoulda/test/functional
|
547
|
+
- test/rails_root/vendor/plugins/shoulda/test/other
|
548
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root
|
549
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app
|
550
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/controllers
|
551
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/helpers
|
552
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/models
|
553
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views
|
554
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/layouts
|
555
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/posts
|
556
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/users
|
557
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/config
|
558
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/config/environments
|
559
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/config/initializers
|
560
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db
|
561
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db/migrate
|
562
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/log
|
563
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/public
|
564
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/script
|
565
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/vendor
|
566
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/vendor/plugins
|
567
|
+
- test/rails_root/vendor/plugins/shoulda/test/unit
|
544
568
|
has_rdoc: false
|
545
569
|
homepage: http://github.com/thoughtbot/clearance
|
546
570
|
post_install_message:
|
@@ -1,81 +0,0 @@
|
|
1
|
-
module Clearance
|
2
|
-
module ConfirmationsControllerTest
|
3
|
-
|
4
|
-
def self.included(base)
|
5
|
-
base.class_eval do
|
6
|
-
|
7
|
-
context 'A GET to #new' do
|
8
|
-
context "with the User with the given id's salt" do
|
9
|
-
setup do
|
10
|
-
@user = Factory :user
|
11
|
-
get :new, :user_id => @user.id, :salt => @user.salt
|
12
|
-
end
|
13
|
-
|
14
|
-
should 'find the User record with the given id and salt' do
|
15
|
-
assert_equal @user, assigns(:user)
|
16
|
-
end
|
17
|
-
|
18
|
-
should_respond_with :success
|
19
|
-
should_render_template :new
|
20
|
-
end
|
21
|
-
|
22
|
-
context "without the User with the given id's salt" do
|
23
|
-
setup do
|
24
|
-
user = Factory :user
|
25
|
-
salt = ''
|
26
|
-
assert_not_equal salt, user.salt
|
27
|
-
|
28
|
-
get :new, :user_id => user.id, :salt => ''
|
29
|
-
end
|
30
|
-
|
31
|
-
should_respond_with :not_found
|
32
|
-
|
33
|
-
should 'render nothing' do
|
34
|
-
assert @response.body.blank?
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'A POST to #create' do
|
40
|
-
context "with the User with the given id's salt" do
|
41
|
-
setup do
|
42
|
-
@user = Factory :user
|
43
|
-
assert ! @user.confirmed?
|
44
|
-
|
45
|
-
post :create, :user_id => @user, :salt => @user.salt
|
46
|
-
@user.reload
|
47
|
-
end
|
48
|
-
|
49
|
-
should 'confirm the User record with the given id' do
|
50
|
-
assert @user.confirmed?
|
51
|
-
end
|
52
|
-
|
53
|
-
should 'log the User in' do
|
54
|
-
assert_equal @user.id, session[:user_id]
|
55
|
-
end
|
56
|
-
|
57
|
-
should_redirect_to "user_path(@user)"
|
58
|
-
end
|
59
|
-
|
60
|
-
context "without the User with the given id's salt" do
|
61
|
-
setup do
|
62
|
-
user = Factory :user
|
63
|
-
salt = ''
|
64
|
-
assert_not_equal salt, user.salt
|
65
|
-
|
66
|
-
post :create, :user_id => user.id, :salt => salt
|
67
|
-
end
|
68
|
-
|
69
|
-
should_respond_with :not_found
|
70
|
-
|
71
|
-
should 'render nothing' do
|
72
|
-
assert @response.body.blank?
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
@@ -1,188 +0,0 @@
|
|
1
|
-
module Clearance
|
2
|
-
module PasswordsControllerTest
|
3
|
-
|
4
|
-
def self.included(base)
|
5
|
-
base.class_eval do
|
6
|
-
|
7
|
-
should_route :get, '/users/1/password/edit', :action => 'edit', :user_id => '1'
|
8
|
-
|
9
|
-
context 'with a user' do
|
10
|
-
setup { @user = Factory :user }
|
11
|
-
|
12
|
-
context 'A GET to #new' do
|
13
|
-
setup { get :new, :user_id => @user_id }
|
14
|
-
|
15
|
-
should_respond_with :success
|
16
|
-
should_render_template 'new'
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'A POST to #create' do
|
20
|
-
context "with an existing user's email address" do
|
21
|
-
setup do
|
22
|
-
ActionMailer::Base.deliveries.clear
|
23
|
-
|
24
|
-
post :create, :password => { :email => @user.email }
|
25
|
-
@email = ActionMailer::Base.deliveries[0]
|
26
|
-
end
|
27
|
-
|
28
|
-
should 'send an email to the user to edit their password' do
|
29
|
-
assert @email.subject =~ /request to change your password/i
|
30
|
-
end
|
31
|
-
|
32
|
-
should_redirect_to "new_session_path"
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'with a non-existing email address' do
|
36
|
-
setup do
|
37
|
-
email = 'user1@example.com'
|
38
|
-
assert ! User.exists?(['email = ?', email])
|
39
|
-
ActionMailer::Base.deliveries.clear
|
40
|
-
|
41
|
-
post :create, :password => { :email => email }
|
42
|
-
end
|
43
|
-
|
44
|
-
should 'not send a password reminder email' do
|
45
|
-
assert ActionMailer::Base.deliveries.empty?
|
46
|
-
end
|
47
|
-
|
48
|
-
should 'set a :warning flash' do
|
49
|
-
assert_not_nil flash.now[:warning]
|
50
|
-
end
|
51
|
-
|
52
|
-
should_render_template "new"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'A GET to #edit' do
|
57
|
-
context "with an existing user's id and password" do
|
58
|
-
setup do
|
59
|
-
get :edit,
|
60
|
-
:user_id => @user.id,
|
61
|
-
:password => @user.crypted_password,
|
62
|
-
:email => @user.email
|
63
|
-
end
|
64
|
-
|
65
|
-
should 'find the user with the given id and password' do
|
66
|
-
assert_equal @user, assigns(:user)
|
67
|
-
end
|
68
|
-
|
69
|
-
should_respond_with :success
|
70
|
-
should_render_template "edit"
|
71
|
-
|
72
|
-
should "have a form for the user's email, password, and password confirm" do
|
73
|
-
update_path = ERB::Util.h(user_password_path(@user,
|
74
|
-
:password => @user.crypted_password,
|
75
|
-
:email => @user.email))
|
76
|
-
|
77
|
-
assert_select 'form[action=?]', update_path do
|
78
|
-
assert_select 'input[name=_method][value=?]', 'put'
|
79
|
-
assert_select 'input[name=?]', 'user[password]'
|
80
|
-
assert_select 'input[name=?]', 'user[password_confirmation]'
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "with an existing user's id but not password" do
|
86
|
-
setup do
|
87
|
-
get(:edit,
|
88
|
-
:user_id => @user.id,
|
89
|
-
:password => '')
|
90
|
-
end
|
91
|
-
|
92
|
-
should_respond_with :not_found
|
93
|
-
|
94
|
-
should 'render an empty response' do
|
95
|
-
assert @response.body.blank?
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context 'A PUT to #update' do
|
101
|
-
context "with an existing user's id but not password" do
|
102
|
-
setup do
|
103
|
-
put(:update,
|
104
|
-
:user_id => @user.id,
|
105
|
-
:password => '')
|
106
|
-
end
|
107
|
-
|
108
|
-
should "not update the user's password" do
|
109
|
-
assert_not_equal @encrypted_new_password, @user.crypted_password
|
110
|
-
end
|
111
|
-
|
112
|
-
should 'not log the user in' do
|
113
|
-
assert_nil session[:user_id]
|
114
|
-
end
|
115
|
-
|
116
|
-
should_respond_with :not_found
|
117
|
-
|
118
|
-
should 'render an empty response' do
|
119
|
-
assert @response.body.blank?
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
context 'with a matching password and password confirmation' do
|
124
|
-
setup do
|
125
|
-
new_password = 'new_password'
|
126
|
-
encryption_format = "--#{@user.salt}--#{new_password}--"
|
127
|
-
@encrypted_new_password = Digest::SHA1.hexdigest encryption_format
|
128
|
-
assert_not_equal @encrypted_new_password, @user.crypted_password
|
129
|
-
|
130
|
-
put(:update,
|
131
|
-
:user_id => @user,
|
132
|
-
:email => @user.email,
|
133
|
-
:password => @user.crypted_password,
|
134
|
-
:user => {
|
135
|
-
:password => new_password,
|
136
|
-
:password_confirmation => new_password
|
137
|
-
})
|
138
|
-
@user.reload
|
139
|
-
end
|
140
|
-
|
141
|
-
should "update the user's password" do
|
142
|
-
assert_equal @encrypted_new_password, @user.crypted_password
|
143
|
-
end
|
144
|
-
|
145
|
-
should 'log the user in' do
|
146
|
-
assert_equal session[:user_id], @user.id
|
147
|
-
end
|
148
|
-
|
149
|
-
should_redirect_to "user_path(@user)"
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'with password but blank password confirmation' do
|
153
|
-
setup do
|
154
|
-
new_password = 'new_password'
|
155
|
-
encryption_format = "--#{@user.salt}--#{new_password}--"
|
156
|
-
@encrypted_new_password = Digest::SHA1.hexdigest encryption_format
|
157
|
-
|
158
|
-
put(:update,
|
159
|
-
:user_id => @user.id,
|
160
|
-
:password => @user.crypted_password,
|
161
|
-
:user => {
|
162
|
-
:password => new_password,
|
163
|
-
:password_confirmation => ''
|
164
|
-
})
|
165
|
-
@user.reload
|
166
|
-
end
|
167
|
-
|
168
|
-
should "not update the user's password" do
|
169
|
-
assert_not_equal @encrypted_new_password, @user.crypted_password
|
170
|
-
end
|
171
|
-
|
172
|
-
should 'not log the user in' do
|
173
|
-
assert_nil session[:user_id]
|
174
|
-
end
|
175
|
-
|
176
|
-
should_respond_with :not_found
|
177
|
-
|
178
|
-
should 'render an empty response' do
|
179
|
-
assert @response.body.blank?
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
end
|
188
|
-
end
|