clearance 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of clearance might be problematic. Click here for more details.
- data/CHANGELOG.textile +194 -0
- data/LICENSE +21 -0
- data/README.textile +123 -0
- data/Rakefile +103 -0
- data/TODO.textile +6 -0
- data/app/controllers/clearance/confirmations_controller.rb +75 -0
- data/app/controllers/clearance/passwords_controller.rb +84 -0
- data/app/controllers/clearance/sessions_controller.rb +66 -0
- data/app/controllers/clearance/users_controller.rb +35 -0
- data/app/models/clearance_mailer.rb +23 -0
- data/app/views/clearance_mailer/change_password.html.erb +9 -0
- data/app/views/clearance_mailer/confirmation.html.erb +5 -0
- data/app/views/passwords/edit.html.erb +23 -0
- data/app/views/passwords/new.html.erb +15 -0
- data/app/views/sessions/new.html.erb +24 -0
- data/app/views/users/_form.html.erb +13 -0
- data/app/views/users/new.html.erb +6 -0
- data/config/clearance_routes.rb +30 -0
- data/generators/clearance/USAGE +1 -0
- data/generators/clearance/clearance_generator.rb +41 -0
- data/generators/clearance/lib/insert_commands.rb +33 -0
- data/generators/clearance/lib/rake_commands.rb +22 -0
- data/generators/clearance/templates/README +22 -0
- data/generators/clearance/templates/factories.rb +13 -0
- data/generators/clearance/templates/migrations/create_users.rb +21 -0
- data/generators/clearance/templates/migrations/update_users.rb +41 -0
- data/generators/clearance/templates/user.rb +3 -0
- data/generators/clearance_features/USAGE +1 -0
- data/generators/clearance_features/clearance_features_generator.rb +20 -0
- data/generators/clearance_features/templates/features/password_reset.feature +33 -0
- data/generators/clearance_features/templates/features/sign_in.feature +35 -0
- data/generators/clearance_features/templates/features/sign_out.feature +15 -0
- data/generators/clearance_features/templates/features/sign_up.feature +45 -0
- data/generators/clearance_features/templates/features/step_definitions/clearance_steps.rb +116 -0
- data/generators/clearance_features/templates/features/step_definitions/factory_girl_steps.rb +5 -0
- data/generators/clearance_features/templates/features/support/paths.rb +22 -0
- data/generators/clearance_views/USAGE +0 -0
- data/generators/clearance_views/clearance_views_generator.rb +27 -0
- data/generators/clearance_views/templates/formtastic/passwords/edit.html.erb +21 -0
- data/generators/clearance_views/templates/formtastic/passwords/new.html.erb +15 -0
- data/generators/clearance_views/templates/formtastic/sessions/new.html.erb +21 -0
- data/generators/clearance_views/templates/formtastic/users/_inputs.html.erb +6 -0
- data/generators/clearance_views/templates/formtastic/users/new.html.erb +10 -0
- data/lib/clearance.rb +6 -0
- data/lib/clearance/authentication.rb +125 -0
- data/lib/clearance/extensions/errors.rb +6 -0
- data/lib/clearance/extensions/rescue.rb +3 -0
- data/lib/clearance/extensions/routes.rb +14 -0
- data/lib/clearance/user.rb +199 -0
- data/rails/init.rb +1 -0
- data/shoulda_macros/clearance.rb +266 -0
- metadata +120 -0
data/CHANGELOG.textile
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
h2. 0.8.2 (09/01/2009)
|
2
|
+
|
3
|
+
* current_user= accessor method. (Joe Ferris, Josh Clayton)
|
4
|
+
* set current_user in sign_in. (Jon Yurek)
|
5
|
+
|
6
|
+
h2. 0.8.1 (08/31/2009)
|
7
|
+
|
8
|
+
* Removed unnecessary remember_token_expires_at column and the
|
9
|
+
remember? and forget_me! user instance methods. (Dan Croak)
|
10
|
+
|
11
|
+
h2. 0.8.0 (08/31/2009)
|
12
|
+
|
13
|
+
* Always remember me. Replaced session-and-remember-me authentication with
|
14
|
+
always using a cookie with a long timeout. (Dan Croak)
|
15
|
+
* Documented Clearance::Authentication with YARD. (Dan Croak)
|
16
|
+
* Documented Clearance::User with YARD. (Dan Croak)
|
17
|
+
|
18
|
+
h2. 0.7.0 (08/04/2009)
|
19
|
+
|
20
|
+
* Redirect signed in user who clicks confirmation link again. (Dan Croak)
|
21
|
+
* Redirect signed out user who clicks confirmation link again. (Dan Croak)
|
22
|
+
* Added signed_out? convenience method for controllers, helpers, views. (Dan
|
23
|
+
Croak)
|
24
|
+
* Added clearance_views generator. By default, creates formtastic views which
|
25
|
+
pass all tests and features. (Dan Croak)
|
26
|
+
|
27
|
+
h2. 0.6.9 (07/04/2009)
|
28
|
+
|
29
|
+
* Added timestamps to create users migration. (Dan Croak)
|
30
|
+
* Ready for Ruby 1.9. (Jason Morrison, Nick Quaranto)
|
31
|
+
|
32
|
+
h2. 0.6.8 (06/24/2009)
|
33
|
+
|
34
|
+
* Added defined? checks for various Rails constants such as ActionController
|
35
|
+
for easier unit testing of Clearance extensions... particularly ActiveRecord
|
36
|
+
extensions... particularly strong_password. (Dan Croak)
|
37
|
+
|
38
|
+
h2. 0.6.7 (06/13/2009)
|
39
|
+
|
40
|
+
* [#30] Added sign_up, sign_in, sign_out named routes. (Dan Croak)
|
41
|
+
* [#22] Minimizing Reek smell: Duplication in redirect_back_or. (Dan Croak)
|
42
|
+
* Deprecated sign_user_in. Told developers to use sign_in instead. (Dan
|
43
|
+
Croak)
|
44
|
+
* [#16] flash_success_after_create, flash_notice_after_create, flash_failure_after_create, flash_sucess_after_update, flash_success_after_destroy, etc. (Dan Croak)
|
45
|
+
* [#17] bug. added #create to forbidden before_filters on confirmations controller. (Dan Croak)
|
46
|
+
* [#24] should_be_signed_in_as shouldn't look in the session. (Dan Croak)
|
47
|
+
* README improvements. (Dan Croak)
|
48
|
+
* Move routes loading to separate file. (Joshua Clayton)
|
49
|
+
|
50
|
+
h2. 0.6.6 (05/18/2009)
|
51
|
+
|
52
|
+
* [#14] replaced class_eval in Clearance::User with modules. This was needed
|
53
|
+
in a thoughtbot client app so we could write our own validations. (Dan Croak)
|
54
|
+
|
55
|
+
h2. 0.6.5 (05/17/2009)
|
56
|
+
|
57
|
+
* [#6] Make Clearance i18n aware. (Timur Vafin, Marcel Goerner, Eugene Bolshakov, Dan Croak)
|
58
|
+
|
59
|
+
h2. 0.6.4 (05/12/2009)
|
60
|
+
|
61
|
+
* Moved issue tracking to Github from Lighthouse. (Dan Croak)
|
62
|
+
* [#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)
|
63
|
+
* [#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)
|
64
|
+
* [#13] move private methods on sessions controller into Clearance::Authentication module (Dan Croak)
|
65
|
+
* [#9] audited flash keys. (Dan Croak)
|
66
|
+
|
67
|
+
h2. 0.6.3 (04/23/2009)
|
68
|
+
|
69
|
+
* Scoping ClearanceMailer properly within controllers so it works in production environments. (Nick Quaranto)
|
70
|
+
|
71
|
+
h2. 0.6.2 (04/22/2009)
|
72
|
+
|
73
|
+
* Insert Clearance::User into User model if it exists. (Nick Quaranto)
|
74
|
+
* World(NavigationHelpers) Cucumber 3.0 style. (Shay Arnett & Mark Cornick)
|
75
|
+
|
76
|
+
h2. 0.6.1 (04/21/2009)
|
77
|
+
|
78
|
+
* Scope operators are necessary to keep Rails happy. Reverting the original
|
79
|
+
revert so they're back in the library now for constants referenced inside of
|
80
|
+
the gem. (Nick Quaranto)
|
81
|
+
|
82
|
+
h2. 0.6.0 (04/21/2009)
|
83
|
+
|
84
|
+
* Converted Clearance to a Rails engine. (Dan Croak & Joe Ferris)
|
85
|
+
* Include Clearance::User in User model in app. (Dan Croak & Joe Ferris)
|
86
|
+
* Include Clearance::Authentication in ApplicationController. (Dan Croak & Joe Ferris)
|
87
|
+
* Namespace controllers under Clearance. (Dan Croak & Joe Ferris)
|
88
|
+
* Routes move to engine, use namespaced controllers but publicly the same. (Dan Croak & Joe Ferris)
|
89
|
+
* If you want to override a controller, subclass it like SessionsController <
|
90
|
+
Clearance::SessionsController. This gives you access to usual hooks such as
|
91
|
+
url_after_create. (Dan Croak & Joe Ferris)
|
92
|
+
* Controllers, mailer, model, routes all unit tested inside engine. Use
|
93
|
+
script/generate clearance_features to test integration of Clearance with your
|
94
|
+
Rails app. No longer including modules in your app's test files. (Dan Croak & Joe Ferris)
|
95
|
+
* Moved views to engine. (Joe Ferris)
|
96
|
+
* Converted generated test/factories/clearance.rb to use inheritence for
|
97
|
+
email_confirmed_user. (Dan Croak)
|
98
|
+
* Corrected some spelling errors with methods (Nick Quaranto)
|
99
|
+
* Converted "I should see error messages" to use a regex in the features (Nick
|
100
|
+
Quaranto)
|
101
|
+
* Loading clearance routes after rails routes via some monkeypatching (Nick
|
102
|
+
Quaranto)
|
103
|
+
* Made the clearance controllers unloadable to stop constant loading errors in
|
104
|
+
development mode (Nick Quaranto)
|
105
|
+
|
106
|
+
h2. 0.5.6 (4/11/2009)
|
107
|
+
|
108
|
+
* [#57] Step definition changed for "User should see error messages" so
|
109
|
+
features won't fail for certain validations. (Nick Quaranto)
|
110
|
+
|
111
|
+
h2. 0.5.5 (3/23/2009)
|
112
|
+
|
113
|
+
* Removing duplicate test to get rid of warning. (Nick Quaranto)
|
114
|
+
|
115
|
+
h2. 0.5.4 (3/21/2009)
|
116
|
+
|
117
|
+
* When users fail logging in, redirect them instead of rendering. (Matt
|
118
|
+
Jankowski)
|
119
|
+
|
120
|
+
h2. 0.5.3 (3/5/2009)
|
121
|
+
|
122
|
+
* Clearance now works with (and requires) Shoulda 2.10.0. (Mark Cornick, Joe
|
123
|
+
Ferris, Dan Croak)
|
124
|
+
* Prefer flat over nested contexts in sessions_controller_test. (Joe Ferris,
|
125
|
+
Dan Croak)
|
126
|
+
|
127
|
+
h2. 0.5.2 (3/2/2009)
|
128
|
+
|
129
|
+
* Fixed last remaining errors in Rails 2.3 tests. Now fully compatible. (Joe
|
130
|
+
Ferris, Dan Croak)
|
131
|
+
|
132
|
+
h2. 0.5.1 (2/27/2009)
|
133
|
+
|
134
|
+
* [#46] A user with unconfirmed email who resets password now confirms email.
|
135
|
+
(Marcel Görner)
|
136
|
+
* Refactored user_from_cookie, user_from_session, User#authenticate to use
|
137
|
+
more direct return code instead of ugly, harder to read ternary. (Dan Croak)
|
138
|
+
* 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)
|
139
|
+
* Altered generator to interact with application_controller.rb instead of
|
140
|
+
application.rb in Rails 2.3 apps. (Dan Croak)
|
141
|
+
* [#42] Bug fix. Rack-based session change altered how to test remember me
|
142
|
+
cookie. (Mihai Anca)
|
143
|
+
|
144
|
+
h2. 0.5.0 (2/27/2009)
|
145
|
+
|
146
|
+
* Fixed problem with Cucumber features. (Dan Croak)
|
147
|
+
* Fixed mising HTTP fluency use case. (Dan Croak)
|
148
|
+
* Refactored User#update_password to take just parameters it needs. (Dan
|
149
|
+
Croak)
|
150
|
+
* Refactored User unit tests to be more readable. (Dan Croak)
|
151
|
+
|
152
|
+
h2. 0.4.9 (2/20/2009)
|
153
|
+
|
154
|
+
* Protect passwords & confirmations actions with forbidden filters. (Dan Croak)
|
155
|
+
* Return 403 Forbidden status code in those cases. (Tim Pope)
|
156
|
+
* Test 403 Forbidden status code in Cucumber feature. (Dan Croak, Joe Ferris)
|
157
|
+
* Raise custom ActionController::Forbidden error internally. (Joe Ferris, Mike Burns, Jason Morrison)
|
158
|
+
* Test ActionController::Forbidden error is raised in functional test. (Joe Ferris, Mike Burns, Dan Croak)
|
159
|
+
* [#45] Fixed bug that allowed anyone to edit another user's password (Marcel Görner)
|
160
|
+
* Required Factory Girl >= 1.2.0. (Dan Croak)
|
161
|
+
|
162
|
+
h2. 0.4.8 (2/16/2009)
|
163
|
+
|
164
|
+
* Added support paths for Cucumber. (Ben Mabey)
|
165
|
+
* Added documentation for the flash. (Ben Mabey)
|
166
|
+
* Generators require "test_helper" instead of File.join. for rr compatibility. (Joe Ferris)
|
167
|
+
* Removed interpolated email address from flash message to make i18n easier. (Bence Nagy)
|
168
|
+
* Standardized flash messages that refer to email delivery. (Dan Croak)
|
169
|
+
|
170
|
+
h2. 0.4.7 (2/12/2009)
|
171
|
+
|
172
|
+
* Removed Clearance::Test::TestHelper so there is one less setup step. (Dan Croak)
|
173
|
+
* All test helpers now in shoulda_macros. (Dan Croak)
|
174
|
+
|
175
|
+
h2. 0.4.6 (2/11/2009)
|
176
|
+
|
177
|
+
* Made the modules behave like mixins again. (hat-tip Eloy Duran)
|
178
|
+
* Created Actions and PrivateMethods modules on controllers for future RDoc reasons. (Dan Croak, Joe Ferris)
|
179
|
+
|
180
|
+
h2. 0.4.5 (2/9/2009)
|
181
|
+
|
182
|
+
* [#43] Removed email downcasing because local-part is case sensitive per RFC5321. (Dan Croak)
|
183
|
+
* [#42] Removed dependency on Mocha. (Dan Croak)
|
184
|
+
* Required Shoulda >= 2.9.1. (Dan Croak)
|
185
|
+
* Added password reset feature to clearance_features generator. (Eugene Bolshakov, Dan Croak)
|
186
|
+
* Removed unnecessary session[:salt]. (Dan Croak)
|
187
|
+
* [#41] Only store location for session[:return_to] for GET requests. (Dan Croak)
|
188
|
+
* Audited "sign up" naming convention. "Register" had slipped in a few places. (Dan Croak)
|
189
|
+
* 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)
|
190
|
+
|
191
|
+
h2. 0.4.4 (2/2/2009)
|
192
|
+
|
193
|
+
* Added a generator for Cucumber features. (Joe Ferris, Dan Croak)
|
194
|
+
* 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.
|
data/README.textile
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
h1. Clearance
|
2
|
+
|
3
|
+
Rails authentication with email & password.
|
4
|
+
|
5
|
+
"We have clearance, Clarence.":http://www.youtube.com/v/mNRXJEE3Nz8
|
6
|
+
|
7
|
+
h2. Suspenders
|
8
|
+
|
9
|
+
Clearance is included in "Suspenders":http://github.com/thoughtbot/suspenders, which thoughtbot uses on all of our apps. We highly recommend you try it. Suspenders is the "King Gem" in our ecosystem, representating what we think the current state-of-the-art is in Rails development.
|
10
|
+
|
11
|
+
h2. Installation
|
12
|
+
|
13
|
+
Clearance is a Rails engine. It works with versions of Rails greater than 2.3.
|
14
|
+
|
15
|
+
In config/environment.rb:
|
16
|
+
|
17
|
+
<pre>
|
18
|
+
config.gem "thoughtbot-clearance",
|
19
|
+
:lib => 'clearance',
|
20
|
+
:source => 'http://gems.github.com',
|
21
|
+
:version => '0.8.2'
|
22
|
+
</pre>
|
23
|
+
|
24
|
+
Vendor the gem:
|
25
|
+
|
26
|
+
<pre>
|
27
|
+
rake gems:install
|
28
|
+
rake gems:unpack
|
29
|
+
</pre>
|
30
|
+
|
31
|
+
Make sure the development database exists and run the generator:
|
32
|
+
|
33
|
+
<pre>
|
34
|
+
script/generate clearance
|
35
|
+
</pre>
|
36
|
+
|
37
|
+
A number of files will be created and instructions will be printed.
|
38
|
+
|
39
|
+
You may already have some of these files. Don't worry. You'll be asked if you want to overwrite them.
|
40
|
+
|
41
|
+
Run the migration:
|
42
|
+
|
43
|
+
<pre>
|
44
|
+
rake db:migrate
|
45
|
+
</pre>
|
46
|
+
|
47
|
+
h2. If you aren't on Suspenders, you aren't done
|
48
|
+
|
49
|
+
Define a HOST constant in your environment files.
|
50
|
+
In config/environments/test.rb and config/environments/development.rb it can be:
|
51
|
+
|
52
|
+
<pre>
|
53
|
+
HOST = "localhost"
|
54
|
+
</pre>
|
55
|
+
|
56
|
+
In production.rb it must be the actual host your application is deployed to.
|
57
|
+
The constant is used by mailers to generate URLs in emails.
|
58
|
+
|
59
|
+
In config/environment.rb:
|
60
|
+
|
61
|
+
<pre>
|
62
|
+
DO_NOT_REPLY = "donotreply@example.com"
|
63
|
+
</pre>
|
64
|
+
|
65
|
+
Define root_url to *something* in your config/routes.rb:
|
66
|
+
|
67
|
+
<pre>
|
68
|
+
map.root :controller => 'home'
|
69
|
+
</pre>
|
70
|
+
|
71
|
+
h2. Cucumber Features
|
72
|
+
|
73
|
+
As your app evolves, you want to know that authentication still works. thoughtbot's opinion is that you should test its integration with your app using "Cucumber":http://cukes.info/.
|
74
|
+
|
75
|
+
Run the Cucumber generator (if you haven't already) and Clearance's feature generator:
|
76
|
+
|
77
|
+
<pre>
|
78
|
+
script/generate cucumber
|
79
|
+
script/generate clearance_features
|
80
|
+
</pre>
|
81
|
+
|
82
|
+
All of the files generated should be new with the exception of the features/support/paths.rb file. If you have not modified your paths.rb then you will be okay to replace it with this one. If you need to keep your paths.rb file then add these locations in your paths.rb manually:
|
83
|
+
|
84
|
+
<pre>
|
85
|
+
def path_to(page_name)
|
86
|
+
case page_name
|
87
|
+
...
|
88
|
+
when /the sign up page/i
|
89
|
+
new_user_path
|
90
|
+
when /the sign in page/i
|
91
|
+
new_session_path
|
92
|
+
when /the password reset request page/i
|
93
|
+
new_password_path
|
94
|
+
...
|
95
|
+
end
|
96
|
+
</pre>
|
97
|
+
|
98
|
+
h2. Formtastic views
|
99
|
+
|
100
|
+
We have begun standardizing our forms using "Formtastic":http://github.com/justinfrench/formtastic. We highly recommend trying it. It will make your Rails view life more interesting.
|
101
|
+
|
102
|
+
Clearance has another generator to generate Formastic views:
|
103
|
+
|
104
|
+
<pre>
|
105
|
+
script/generate clearance_views
|
106
|
+
</pre>
|
107
|
+
|
108
|
+
Its implementation is designed so that other view styles can be generated if the community wants it. However, we haven't needed them so you'll have to write the patch and send it back if you want other styles (such as Haml).
|
109
|
+
|
110
|
+
h2. Authors
|
111
|
+
|
112
|
+
Clearance was extracted out of "Hoptoad":http://hoptoadapp.com. We merged the authentication code from two of thoughtbot's clients' Rails apps and have since used it each time we need authentication. The following people have improved the library. Thank you!
|
113
|
+
|
114
|
+
Dan Croak, Mike Burns, Jason Morrison, Joe Ferris, Eugene Bolshakov, Nick Quaranto, Josh Nichols, Mike Breen, Marcel Görner, Bence Nagy, Ben Mabey, Eloy Duran, Tim Pope, Mihai Anca, Mark Cornick, Shay Arnett, Joshua Clayton, Mustafa Ekim, & Jon Yurek.
|
115
|
+
|
116
|
+
h2. Questions?
|
117
|
+
|
118
|
+
Ask the "mailing list":http://groups.google.com/group/thoughtbot-clearance
|
119
|
+
|
120
|
+
h2. Suggestions, Bugs, Refactoring?
|
121
|
+
|
122
|
+
Fork away and create a "Github Issue":http://github.com/thoughtbot/clearance/issues. Please don't send pull requests.
|
123
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,103 @@
|
|
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.feature_pattern = "test/rails_root/features/*.feature"
|
27
|
+
end
|
28
|
+
|
29
|
+
Cucumber::Rake::Task.new(:features_for_views) do |t|
|
30
|
+
t.cucumber_opts = "--format progress"
|
31
|
+
t.feature_pattern = "test/rails_root/features/*.feature"
|
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
|
+
generators.each do |generator|
|
41
|
+
FileList["generators/#{generator}/templates/**/*.*"].each do |each|
|
42
|
+
file = "test/rails_root/#{each.gsub("generators/#{generator}/templates/",'')}"
|
43
|
+
File.delete(file) if File.exists?(file)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
FileList["test/rails_root/db/**/*"].each do |each|
|
48
|
+
FileUtils.rm_rf(each)
|
49
|
+
end
|
50
|
+
|
51
|
+
FileUtils.rm_rf("test/rails_root/vendor/plugins/clearance")
|
52
|
+
FileUtils.mkdir_p("test/rails_root/vendor/plugins")
|
53
|
+
clearance_root = File.expand_path(File.dirname(__FILE__))
|
54
|
+
system("ln -s #{clearance_root} test/rails_root/vendor/plugins/clearance")
|
55
|
+
|
56
|
+
FileUtils.rm_rf("test/rails_root/app/views/passwords")
|
57
|
+
FileUtils.rm_rf("test/rails_root/app/views/sessions")
|
58
|
+
FileUtils.rm_rf("test/rails_root/app/views/users")
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Run the clearance generator"
|
62
|
+
task :clearance do
|
63
|
+
system "cd test/rails_root && ./script/generate clearance && rake db:migrate db:test:prepare"
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "Run the clearance features generator"
|
67
|
+
task :clearance_features do
|
68
|
+
system "cd test/rails_root && ./script/generate clearance_features"
|
69
|
+
end
|
70
|
+
|
71
|
+
desc "Run the clearance views generator"
|
72
|
+
task :clearance_views do
|
73
|
+
system "cd test/rails_root && ./script/generate clearance_views"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "Run the test suite"
|
78
|
+
task :default => ['test:basic', 'test:features',
|
79
|
+
'test:views', 'test:features_for_views']
|
80
|
+
|
81
|
+
gem_spec = Gem::Specification.new do |gem_spec|
|
82
|
+
gem_spec.name = "clearance"
|
83
|
+
gem_spec.version = "0.8.2"
|
84
|
+
gem_spec.summary = "Rails authentication with email & password."
|
85
|
+
gem_spec.email = "support@thoughtbot.com"
|
86
|
+
gem_spec.homepage = "http://github.com/thoughtbot/clearance"
|
87
|
+
gem_spec.description = "Rails authentication with email & password."
|
88
|
+
gem_spec.authors = ["Dan Croak", "Mike Burns", "Jason Morrison",
|
89
|
+
"Joe Ferris", "Eugene Bolshakov", "Nick Quaranto",
|
90
|
+
"Josh Nichols", "Mike Breen", "Marcel Görner",
|
91
|
+
"Bence Nagy", "Ben Mabey", "Eloy Duran",
|
92
|
+
"Tim Pope", "Mihai Anca", "Mark Cornick",
|
93
|
+
"Shay Arnett", "Jon Yurek"]
|
94
|
+
gem_spec.files = FileList["[A-Z]*", "{app,config,generators,lib,shoulda_macros,rails}/**/*"]
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "Generate a gemspec file"
|
98
|
+
task :gemspec do
|
99
|
+
File.open("#{gem_spec.name}.gemspec", 'w') do |f|
|
100
|
+
f.write gem_spec.to_yaml
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|