benaldred-clearance 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/CHANGELOG.md +274 -0
  2. data/LICENSE +21 -0
  3. data/README.md +129 -0
  4. data/Rakefile +87 -0
  5. data/VERSION +1 -0
  6. data/app/controllers/clearance/confirmations_controller.rb +76 -0
  7. data/app/controllers/clearance/passwords_controller.rb +85 -0
  8. data/app/controllers/clearance/sessions_controller.rb +67 -0
  9. data/app/controllers/clearance/users_controller.rb +35 -0
  10. data/app/models/clearance_mailer.rb +21 -0
  11. data/app/views/clearance_mailer/change_password.html.erb +9 -0
  12. data/app/views/clearance_mailer/confirmation.html.erb +5 -0
  13. data/app/views/passwords/edit.html.erb +23 -0
  14. data/app/views/passwords/new.html.erb +15 -0
  15. data/app/views/sessions/new.html.erb +24 -0
  16. data/app/views/users/_form.html.erb +13 -0
  17. data/app/views/users/new.html.erb +6 -0
  18. data/generators/clearance/USAGE +1 -0
  19. data/generators/clearance/clearance_generator.rb +68 -0
  20. data/generators/clearance/lib/insert_commands.rb +33 -0
  21. data/generators/clearance/lib/rake_commands.rb +22 -0
  22. data/generators/clearance/templates/README +24 -0
  23. data/generators/clearance/templates/clearance.rb +3 -0
  24. data/generators/clearance/templates/factories.rb +13 -0
  25. data/generators/clearance/templates/migrations/create_users.rb +21 -0
  26. data/generators/clearance/templates/migrations/update_users.rb +41 -0
  27. data/generators/clearance/templates/user.rb +3 -0
  28. data/generators/clearance_features/USAGE +1 -0
  29. data/generators/clearance_features/clearance_features_generator.rb +19 -0
  30. data/generators/clearance_features/templates/features/password_reset.feature +33 -0
  31. data/generators/clearance_features/templates/features/sign_in.feature +35 -0
  32. data/generators/clearance_features/templates/features/sign_out.feature +15 -0
  33. data/generators/clearance_features/templates/features/sign_up.feature +45 -0
  34. data/generators/clearance_features/templates/features/step_definitions/clearance_steps.rb +122 -0
  35. data/generators/clearance_features/templates/features/support/paths.rb +23 -0
  36. data/generators/clearance_views/USAGE +0 -0
  37. data/generators/clearance_views/clearance_views_generator.rb +27 -0
  38. data/generators/clearance_views/templates/formtastic/passwords/edit.html.erb +21 -0
  39. data/generators/clearance_views/templates/formtastic/passwords/new.html.erb +15 -0
  40. data/generators/clearance_views/templates/formtastic/sessions/new.html.erb +21 -0
  41. data/generators/clearance_views/templates/formtastic/users/_inputs.html.erb +6 -0
  42. data/generators/clearance_views/templates/formtastic/users/new.html.erb +10 -0
  43. data/lib/clearance.rb +7 -0
  44. data/lib/clearance/authentication.rb +131 -0
  45. data/lib/clearance/configuration.rb +26 -0
  46. data/lib/clearance/extensions/errors.rb +6 -0
  47. data/lib/clearance/extensions/rescue.rb +5 -0
  48. data/lib/clearance/routes.rb +49 -0
  49. data/lib/clearance/user.rb +215 -0
  50. data/rails/init.rb +1 -0
  51. data/shoulda_macros/clearance.rb +266 -0
  52. data/test/controllers/confirmations_controller_test.rb +104 -0
  53. data/test/controllers/passwords_controller_test.rb +183 -0
  54. data/test/controllers/sessions_controller_test.rb +146 -0
  55. data/test/controllers/users_controller_test.rb +65 -0
  56. data/test/models/clearance_mailer_test.rb +55 -0
  57. data/test/models/user_test.rb +255 -0
  58. data/test/rails_root/app/controllers/accounts_controller.rb +10 -0
  59. data/test/rails_root/app/controllers/application_controller.rb +6 -0
  60. data/test/rails_root/app/helpers/application_helper.rb +5 -0
  61. data/test/rails_root/app/helpers/confirmations_helper.rb +2 -0
  62. data/test/rails_root/app/helpers/passwords_helper.rb +2 -0
  63. data/test/rails_root/app/models/user.rb +3 -0
  64. data/test/rails_root/config/boot.rb +110 -0
  65. data/test/rails_root/config/environment.rb +17 -0
  66. data/test/rails_root/config/environments/development.rb +19 -0
  67. data/test/rails_root/config/environments/production.rb +1 -0
  68. data/test/rails_root/config/environments/test.rb +36 -0
  69. data/test/rails_root/config/initializers/clearance.rb +3 -0
  70. data/test/rails_root/config/initializers/inflections.rb +10 -0
  71. data/test/rails_root/config/initializers/mime_types.rb +5 -0
  72. data/test/rails_root/config/initializers/requires.rb +13 -0
  73. data/test/rails_root/config/initializers/time_formats.rb +4 -0
  74. data/test/rails_root/config/routes.rb +6 -0
  75. data/test/rails_root/features/step_definitions/clearance_steps.rb +122 -0
  76. data/test/rails_root/features/step_definitions/web_steps.rb +259 -0
  77. data/test/rails_root/features/support/env.rb +47 -0
  78. data/test/rails_root/features/support/paths.rb +23 -0
  79. data/test/rails_root/public/dispatch.rb +10 -0
  80. data/test/rails_root/script/create_project.rb +52 -0
  81. data/test/rails_root/test/factories/clearance.rb +13 -0
  82. data/test/rails_root/test/functional/accounts_controller_test.rb +23 -0
  83. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb +21 -0
  84. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/lib/formtastic.rb +1236 -0
  85. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/lib/justin_french/formtastic.rb +10 -0
  86. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/rails/init.rb +3 -0
  87. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/spec/formtastic_spec.rb +2900 -0
  88. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/spec/test_helper.rb +14 -0
  89. data/test/test_helper.rb +19 -0
  90. metadata +160 -0
@@ -0,0 +1,274 @@
1
+ 0.8.8 (02/25/2010)
2
+ ------------------
3
+ * Fixed sign_in and sign_out not setting current_user (Joe Ferris)
4
+
5
+ 0.8.7 (02/21/2010)
6
+ ------------------
7
+
8
+ * [#43] Fixed global sign out bug. (Ryan McGreary)
9
+ * [#69] Allow Rails apps to before_filter :authenticate the entire app
10
+ in ApplicationController and still have password recovery work without
11
+ overriding any controllers. (Claudio Poli, Dan Croak)
12
+ * [#72] #[21] Rails3 fix for ActionController/ActionDispatch change.
13
+ (Joseph Holsten, Peter Haza, Dan Croak)
14
+
15
+ 0.8.6 (02/17/2010)
16
+ ------------------
17
+
18
+ * Clearance features capitalization should match view text (Bobby Wilson)
19
+ * [#39] skip :authenticate before_filter in controllers so apps can easily
20
+ authenticate a whole site without subclassing (Matthew Ford)
21
+ * [#45] Added randomness to token and salt generation (Ryan McGeary)
22
+ * [#43] Reset the remember_token on sign out instead of sign in. Allows for the same
23
+ user to sign in from two locations at once. (Ryan McGeary)
24
+ * [#62] Append the version number to generated update migrations (Joe Ferris)
25
+ * Allow overridden user models to skip email/password validations
26
+ conditionally. This makes username/facebook integration easier. (Joe Ferris)
27
+
28
+ 0.8.5 (01/20/2010)
29
+ ------------------
30
+
31
+ * replaced routing hack with Clearance::Routes.draw(map) to give
32
+ more control to the application developer. (Dan Croak)
33
+ * removed attr_accessible from Clearance::User. (Dan Croak)
34
+ * fixed bug in password reset feature. (Ben Orenstein, Dan Croak)
35
+ * use Jeweler for gemming. (Dan Croak)
36
+ * remove dependency on root_path, use '/' instead. (Dan Croak)
37
+ * use Clearance.configure block to set mailer sender instead of
38
+ DO_NOT_REPLY constant. (Dan Croak)
39
+
40
+ 0.8.4 (12/08/2009)
41
+ ------------------
42
+
43
+ * [#48] remove unnecessary require 'factory_girl' in generator (Dan Croak)
44
+ * reference gemcutter (not github) as the gem source in README (Dan Croak)
45
+ * add IRC, rdoc.info links to README (Dan Croak)
46
+ * move user confirmation email trigger into model (Chad Pytel)
47
+
48
+ 0.8.3 (09/21/2009)
49
+ ------------------
50
+
51
+ * [#27] remove class_eval in Clearance::Authentication. (Anuj Dutta)
52
+ * Avoid possible collisions in the remember me token (Joe Ferris)
53
+
54
+ 0.8.2 (09/01/2009)
55
+ ------------------
56
+
57
+ * current_user= accessor method. (Joe Ferris, Josh Clayton)
58
+ * set current_user in sign_in. (Jon Yurek)
59
+
60
+ 0.8.1 (08/31/2009)
61
+ ------------------
62
+
63
+ * Removed unnecessary remember_token_expires_at column and the
64
+ remember? and forget_me! user instance methods. (Dan Croak)
65
+
66
+ 0.8.0 (08/31/2009)
67
+ ------------------
68
+
69
+ * Always remember me. Replaced session-and-remember-me authentication with
70
+ always using a cookie with a long timeout. (Dan Croak)
71
+ * Documented Clearance::Authentication with YARD. (Dan Croak)
72
+ * Documented Clearance::User with YARD. (Dan Croak)
73
+
74
+ 0.7.0 (08/04/2009)
75
+ ------------------
76
+
77
+ * Redirect signed in user who clicks confirmation link again. (Dan Croak)
78
+ * Redirect signed out user who clicks confirmation link again. (Dan Croak)
79
+ * Added signed_out? convenience method for controllers, helpers, views. (Dan
80
+ Croak)
81
+ * Added clearance_views generator. By default, creates formtastic views which
82
+ pass all tests and features. (Dan Croak)
83
+
84
+ 0.6.9 (07/04/2009)
85
+ ------------------
86
+
87
+ * Added timestamps to create users migration. (Dan Croak)
88
+ * Ready for Ruby 1.9. (Jason Morrison, Nick Quaranto)
89
+
90
+ 0.6.8 (06/24/2009)
91
+ ------------------
92
+
93
+ * Added defined? checks for various Rails constants such as ActionController
94
+ for easier unit testing of Clearance extensions... particularly ActiveRecord
95
+ extensions... particularly strong_password. (Dan Croak)
96
+
97
+ 0.6.7 (06/13/2009)
98
+ ------------------
99
+
100
+ * [#30] Added sign_up, sign_in, sign_out named routes. (Dan Croak)
101
+ * [#22] Minimizing Reek smell: Duplication in redirect_back_or. (Dan Croak)
102
+ * Deprecated sign_user_in. Told developers to use sign_in instead. (Dan
103
+ Croak)
104
+ * [#16] flash_success_after_create, flash_notice_after_create, flash_failure_after_create, flash_sucess_after_update, flash_success_after_destroy, etc. (Dan Croak)
105
+ * [#17] bug. added #create to forbidden before_filters on confirmations controller. (Dan Croak)
106
+ * [#24] should_be_signed_in_as shouldn't look in the session. (Dan Croak)
107
+ * README improvements. (Dan Croak)
108
+ * Move routes loading to separate file. (Joshua Clayton)
109
+
110
+ 0.6.6 (05/18/2009)
111
+ ------------------
112
+
113
+ * [#14] replaced class_eval in Clearance::User with modules. This was needed
114
+ in a thoughtbot client app so we could write our own validations. (Dan Croak)
115
+
116
+ 0.6.5 (05/17/2009)
117
+ ------------------
118
+
119
+ * [#6] Make Clearance i18n aware. (Timur Vafin, Marcel Goerner, Eugene Bolshakov, Dan Croak)
120
+
121
+ 0.6.4 (05/12/2009)
122
+ ------------------
123
+
124
+ * Moved issue tracking to Github from Lighthouse. (Dan Croak)
125
+ * [#7] asking higher-level questions of controllers in webrat steps, such as signed_in? instead of what's in the session. same for accessors. (Dan Croak)
126
+ * [#11] replacing sign_in_as & sign_out shoulda macros with a stubbing (requires no dependency) approach. this will avoid dealing with the internals of current_user, such as session & cookies. added sign_in macro which signs in an email confirmed user from clearance's factories. (Dan Croak)
127
+ * [#13] move private methods on sessions controller into Clearance::Authentication module (Dan Croak)
128
+ * [#9] audited flash keys. (Dan Croak)
129
+
130
+ 0.6.3 (04/23/2009)
131
+ ------------------
132
+
133
+ * Scoping ClearanceMailer properly within controllers so it works in production environments. (Nick Quaranto)
134
+
135
+ 0.6.2 (04/22/2009)
136
+ ------------------
137
+
138
+ * Insert Clearance::User into User model if it exists. (Nick Quaranto)
139
+ * World(NavigationHelpers) Cucumber 3.0 style. (Shay Arnett & Mark Cornick)
140
+
141
+ 0.6.1 (04/21/2009)
142
+ ------------------
143
+
144
+ * Scope operators are necessary to keep Rails happy. Reverting the original
145
+ revert so they're back in the library now for constants referenced inside of
146
+ the gem. (Nick Quaranto)
147
+
148
+ 0.6.0 (04/21/2009)
149
+ ------------------
150
+
151
+ * Converted Clearance to a Rails engine. (Dan Croak & Joe Ferris)
152
+ * Include Clearance::User in User model in app. (Dan Croak & Joe Ferris)
153
+ * Include Clearance::Authentication in ApplicationController. (Dan Croak & Joe Ferris)
154
+ * Namespace controllers under Clearance. (Dan Croak & Joe Ferris)
155
+ * Routes move to engine, use namespaced controllers but publicly the same. (Dan Croak & Joe Ferris)
156
+ * If you want to override a controller, subclass it like SessionsController <
157
+ Clearance::SessionsController. This gives you access to usual hooks such as
158
+ url_after_create. (Dan Croak & Joe Ferris)
159
+ * Controllers, mailer, model, routes all unit tested inside engine. Use
160
+ script/generate clearance_features to test integration of Clearance with your
161
+ Rails app. No longer including modules in your app's test files. (Dan Croak & Joe Ferris)
162
+ * Moved views to engine. (Joe Ferris)
163
+ * Converted generated test/factories/clearance.rb to use inheritence for
164
+ email_confirmed_user. (Dan Croak)
165
+ * Corrected some spelling errors with methods (Nick Quaranto)
166
+ * Converted "I should see error messages" to use a regex in the features (Nick
167
+ Quaranto)
168
+ * Loading clearance routes after rails routes via some monkeypatching (Nick
169
+ Quaranto)
170
+ * Made the clearance controllers unloadable to stop constant loading errors in
171
+ development mode (Nick Quaranto)
172
+
173
+ 0.5.6 (4/11/2009)
174
+ -----------------
175
+
176
+ * [#57] Step definition changed for "User should see error messages" so
177
+ features won't fail for certain validations. (Nick Quaranto)
178
+
179
+ 0.5.5 (3/23/2009)
180
+ -----------------
181
+
182
+ * Removing duplicate test to get rid of warning. (Nick Quaranto)
183
+
184
+ 0.5.4 (3/21/2009)
185
+ -----------------
186
+
187
+ * When users fail logging in, redirect them instead of rendering. (Matt
188
+ Jankowski)
189
+
190
+ 0.5.3 (3/5/2009)
191
+ ----------------
192
+
193
+ * Clearance now works with (and requires) Shoulda 2.10.0. (Mark Cornick, Joe
194
+ Ferris, Dan Croak)
195
+ * Prefer flat over nested contexts in sessions_controller_test. (Joe Ferris,
196
+ Dan Croak)
197
+
198
+ 0.5.2 (3/2/2009)
199
+ ----------------
200
+
201
+ * Fixed last remaining errors in Rails 2.3 tests. Now fully compatible. (Joe
202
+ Ferris, Dan Croak)
203
+
204
+ 0.5.1 (2/27/2009)
205
+ -----------------
206
+
207
+ * [#46] A user with unconfirmed email who resets password now confirms email.
208
+ (Marcel Görner)
209
+ * Refactored user_from_cookie, user_from_session, User#authenticate to use
210
+ more direct return code instead of ugly, harder to read ternary. (Dan Croak)
211
+ * Switch order of cookies and sessions to take advantage of Rails 2.3's "Rack-based lazy-loaded sessions":http://is.gd/i23E. (Dan Croak)
212
+ * Altered generator to interact with application_controller.rb instead of
213
+ application.rb in Rails 2.3 apps. (Dan Croak)
214
+ * [#42] Bug fix. Rack-based session change altered how to test remember me
215
+ cookie. (Mihai Anca)
216
+
217
+ 0.5.0 (2/27/2009)
218
+ -----------------
219
+
220
+ * Fixed problem with Cucumber features. (Dan Croak)
221
+ * Fixed mising HTTP fluency use case. (Dan Croak)
222
+ * Refactored User#update_password to take just parameters it needs. (Dan
223
+ Croak)
224
+ * Refactored User unit tests to be more readable. (Dan Croak)
225
+
226
+ 0.4.9 (2/20/2009)
227
+ -----------------
228
+
229
+ * Protect passwords & confirmations actions with forbidden filters. (Dan Croak)
230
+ * Return 403 Forbidden status code in those cases. (Tim Pope)
231
+ * Test 403 Forbidden status code in Cucumber feature. (Dan Croak, Joe Ferris)
232
+ * Raise custom ActionController::Forbidden error internally. (Joe Ferris, Mike Burns, Jason Morrison)
233
+ * Test ActionController::Forbidden error is raised in functional test. (Joe Ferris, Mike Burns, Dan Croak)
234
+ * [#45] Fixed bug that allowed anyone to edit another user's password (Marcel Görner)
235
+ * Required Factory Girl >= 1.2.0. (Dan Croak)
236
+
237
+ 0.4.8 (2/16/2009)
238
+ -----------------
239
+
240
+ * Added support paths for Cucumber. (Ben Mabey)
241
+ * Added documentation for the flash. (Ben Mabey)
242
+ * Generators require "test_helper" instead of File.join. for rr compatibility. (Joe Ferris)
243
+ * Removed interpolated email address from flash message to make i18n easier. (Bence Nagy)
244
+ * Standardized flash messages that refer to email delivery. (Dan Croak)
245
+
246
+ 0.4.7 (2/12/2009)
247
+ -----------------
248
+
249
+ * Removed Clearance::Test::TestHelper so there is one less setup step. (Dan Croak)
250
+ * All test helpers now in shoulda_macros. (Dan Croak)
251
+
252
+ 0.4.6 (2/11/2009)
253
+ -----------------
254
+
255
+ * Made the modules behave like mixins again. (hat-tip Eloy Duran)
256
+ * Created Actions and PrivateMethods modules on controllers for future RDoc reasons. (Dan Croak, Joe Ferris)
257
+
258
+ 0.4.5 (2/9/2009)
259
+ ----------------
260
+
261
+ * [#43] Removed email downcasing because local-part is case sensitive per RFC5321. (Dan Croak)
262
+ * [#42] Removed dependency on Mocha. (Dan Croak)
263
+ * Required Shoulda >= 2.9.1. (Dan Croak)
264
+ * Added password reset feature to clearance_features generator. (Eugene Bolshakov, Dan Croak)
265
+ * Removed unnecessary session[:salt]. (Dan Croak)
266
+ * [#41] Only store location for session[:return_to] for GET requests. (Dan Croak)
267
+ * Audited "sign up" naming convention. "Register" had slipped in a few places. (Dan Croak)
268
+ * Switched to SHA1 encryption. Cypher doesn't matter much for email confirmation, password reset. Better to have shorter hashes in the emails for clients who line break on 72 chars. (Dan Croak)
269
+
270
+ 0.4.4 (2/2/2009)
271
+ ----------------
272
+
273
+ * Added a generator for Cucumber features. (Joe Ferris, Dan Croak)
274
+ * Standarized naming for "Sign up," "Sign in," and "Sign out". (Dan Croak)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2008 thoughtbot, inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,129 @@
1
+ Clearance
2
+ =========
3
+
4
+ Rails authentication with email & password.
5
+
6
+ [We have clearance, Clarence.](http://www.youtube.com/v/mNRXJEE3Nz8)
7
+
8
+ Help
9
+ ----
10
+
11
+ * [documentation](http://rdoc.info/projects/thoughtbot/clearance)
12
+ * [#thoughtbot](irc://irc.freenode.net/thoughtbot) IRC channel on freenode
13
+ * [mailing list](http://groups.google.com/group/thoughtbot-clearance)
14
+
15
+ Bugs, Patches
16
+ -------------
17
+
18
+ Fork away and create a [Github Issue](http://github.com/thoughtbot/clearance/issues).
19
+
20
+ Installation
21
+ ------------
22
+
23
+ Clearance is a Rails engine. It works with versions of Rails greater than 2.3.
24
+
25
+ Install it as a gem however you like to install gems. Gem Bundler example:
26
+
27
+ gem "clearance"
28
+
29
+ Make sure the development database exists and run the generator:
30
+
31
+ script/generate clearance
32
+
33
+ This:
34
+
35
+ * inserts Clearance::User into your User model
36
+ * inserts Clearance::Authentication into your ApplicationController
37
+ * inserts Clearance::Routes.draw(map) into your config.routes.rb
38
+ * created a migration that either creates a users table or adds only missing columns
39
+ * prints further instructions
40
+
41
+ Usage
42
+ -----
43
+
44
+ If you want to authenticate users for a controller action, use the authenticate
45
+ method in a before_filter.
46
+
47
+ class WidgetsController < ApplicationController
48
+ before_filter :authenticate
49
+ def index
50
+ @widgets = Widget.all
51
+ end
52
+ end
53
+
54
+ Customizing
55
+ -----------
56
+
57
+ To change any of provided actions, subclass a Clearance controller...
58
+
59
+ class SessionsController < Clearance::SessionsController
60
+ def new
61
+ # my special new action
62
+ end
63
+ def url_after_create
64
+ my_special_path
65
+ end
66
+ end
67
+
68
+ and add your route above (before) Clearance routes in config/routes.rb:
69
+
70
+ map.resource :session, :controller => 'sessions'
71
+
72
+ See lib/clearance/routes.rb for all the routes Clearance provides.
73
+
74
+ Actions that redirect (create, update, and destroy) in Clearance controllers
75
+ can be overriden by re-defining url_after_(action) methods as seen above.
76
+
77
+ Optional Cucumber features
78
+ --------------------------
79
+
80
+ As your app evolves, you want to know that authentication still works. Our
81
+ opinion is that you should test its integration with your app using
82
+ [Cucumber](http://cukes.info).
83
+
84
+ Run the Cucumber generator and Clearance feature generator:
85
+
86
+ script/generate cucumber
87
+ script/generate clearance_features
88
+
89
+ All of the files generated should be new with the exception of the
90
+ features/support/paths.rb file. If you have not modified your paths.rb then you
91
+ will be okay to replace it with this one. If you need to keep your paths.rb
92
+ file then add these locations in your paths.rb manually:
93
+
94
+ def path_to(page_name)
95
+ case page_name
96
+ when /the sign up page/i
97
+ new_user_path
98
+ when /the sign in page/i
99
+ new_session_path
100
+ when /the password reset request page/i
101
+ new_password_path
102
+ end
103
+ end
104
+
105
+ Optional Formtastic views
106
+ -------------------------
107
+
108
+ We use & recommend [Formtastic](http://github.com/justinfrench/formtastic].
109
+
110
+ Clearance has another generator to generate Formastic views:
111
+
112
+ script/generate clearance_views
113
+
114
+ Its implementation is designed so other view styles (Haml?) can be generated.
115
+
116
+ Authors
117
+ -------
118
+
119
+ Clearance was extracted out of [Hoptoad](http://hoptoadapp.com). We merged the
120
+ authentication code from two of thoughtbot client Rails apps and have since
121
+ used it each time we need authentication.
122
+
123
+ The following people have improved the library. Thank you!
124
+
125
+ Dan Croak, Mike Burns, Jason Morrison, Joe Ferris, Eugene Bolshakov,
126
+ Nick Quaranto, Josh Nichols, Mike Breen, Marcel Görner, Bence Nagy, Ben Mabey,
127
+ Eloy Duran, Tim Pope, Mihai Anca, Mark Cornick, Shay Arnett, Joshua Clayton,
128
+ Mustafa Ekim, Jon Yurek, Anuj Dutta, Chad Pytel, Ben Orenstein, Bobby Wilson,
129
+ Matthew Ford, Ryan McGeary, Claudio Poli, Joseph Holsten, and Peter Haza.
@@ -0,0 +1,87 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'cucumber/rake/task'
6
+
7
+ namespace :test do
8
+ Rake::TestTask.new(:basic => ["generator:cleanup",
9
+ "generator:clearance",
10
+ "generator:clearance_features"]) do |task|
11
+ task.libs << "lib"
12
+ task.libs << "test"
13
+ task.pattern = "test/**/*_test.rb"
14
+ task.verbose = false
15
+ end
16
+
17
+ Rake::TestTask.new(:views => ["generator:clearance_views"]) do |task|
18
+ task.libs << "lib"
19
+ task.libs << "test"
20
+ task.pattern = "test/**/*_test.rb"
21
+ task.verbose = false
22
+ end
23
+
24
+ Cucumber::Rake::Task.new(:features) do |t|
25
+ t.cucumber_opts = "--format progress"
26
+ t.profile = 'features'
27
+ end
28
+
29
+ Cucumber::Rake::Task.new(:features_for_views) do |t|
30
+ t.cucumber_opts = "--format progress"
31
+ t.profile = 'features_for_views'
32
+ end
33
+ end
34
+
35
+ generators = %w(clearance clearance_features clearance_views)
36
+
37
+ namespace :generator do
38
+ desc "Cleans up the test app before running the generator"
39
+ task :cleanup do
40
+ FileList["test/rails_root/db/**/*"].each do |each|
41
+ FileUtils.rm_rf(each)
42
+ end
43
+
44
+ FileUtils.rm_rf("test/rails_root/vendor/plugins/clearance")
45
+ FileUtils.mkdir_p("test/rails_root/vendor/plugins")
46
+ clearance_root = File.expand_path(File.dirname(__FILE__))
47
+ system("ln -s #{clearance_root} test/rails_root/vendor/plugins/clearance")
48
+ end
49
+
50
+ desc "Run the clearance generator"
51
+ task :clearance do
52
+ system "cd test/rails_root && ./script/generate clearance -f && rake db:migrate db:test:prepare"
53
+ end
54
+
55
+ desc "Run the clearance features generator"
56
+ task :clearance_features do
57
+ system "cd test/rails_root && ./script/generate clearance_features -f"
58
+ end
59
+
60
+ desc "Run the clearance views generator"
61
+ task :clearance_views do
62
+ system "cd test/rails_root && ./script/generate clearance_views -f"
63
+ end
64
+ end
65
+
66
+ desc "Run the test suite"
67
+ task :default => ['test:basic', 'test:features',
68
+ 'test:views', 'test:features_for_views']
69
+
70
+ require 'jeweler'
71
+
72
+ Jeweler::Tasks.new do |gem|
73
+ gem.name = "clearance"
74
+ gem.summary = "Rails authentication with email & password."
75
+ gem.description = "Rails authentication with email & password."
76
+ gem.email = "support@thoughtbot.com"
77
+ gem.homepage = "http://github.com/thoughtbot/clearance"
78
+ gem.authors = ["Dan Croak", "Mike Burns", "Jason Morrison",
79
+ "Joe Ferris", "Eugene Bolshakov", "Nick Quaranto",
80
+ "Josh Nichols", "Mike Breen", "Marcel Görner",
81
+ "Bence Nagy", "Ben Mabey", "Eloy Duran",
82
+ "Tim Pope", "Mihai Anca", "Mark Cornick",
83
+ "Shay Arnett", "Jon Yurek", "Chad Pytel"]
84
+ gem.files = FileList["[A-Z]*", "{app,config,generators,lib,shoulda_macros,rails}/**/*"]
85
+ end
86
+
87
+ Jeweler::GemcutterTasks.new