Commit 7b2f54c313ce10db131581ee3e438565a1df74d1

Authored by Daniel Croak
1 parent 726dd83e

upgraded clearance to 0.8.2

Showing 104 changed files with 2065 additions and 2120 deletions   Show diff stats
config/environment.rb
... ... @@ -49,7 +49,7 @@ Rails::Initializer.run do |config|
49 49 config.gem "thoughtbot-clearance",
50 50 :lib => 'clearance',
51 51 :source => 'http://gems.github.com',
52   - :version => '0.7.0'
  52 + :version => '0.8.2'
53 53 config.gem "activemerchant",
54 54 :lib => 'active_merchant',
55 55 :version => '1.4.2'
... ...
vendor/gems/thoughtbot-clearance-0.7.0/.specification
... ... @@ -1,145 +0,0 @@
1   ---- !ruby/object:Gem::Specification
2   -name: thoughtbot-clearance
3   -version: !ruby/object:Gem::Version
4   - version: 0.7.0
5   -platform: ruby
6   -authors:
7   -- Dan Croak
8   -- Mike Burns
9   -- Jason Morrison
10   -- Joe Ferris
11   -- Eugene Bolshakov
12   -- Nick Quaranto
13   -- Josh Nichols
14   -- Mike Breen
15   -- "Marcel G\xC3\xB6rner"
16   -- Bence Nagy
17   -- Ben Mabey
18   -- Eloy Duran
19   -- Tim Pope
20   -- Mihai Anca
21   -- Mark Cornick
22   -- Shay Arnett
23   -autorequire:
24   -bindir: bin
25   -cert_chain: []
26   -
27   -date: 2009-08-04 00:00:00 -04:00
28   -default_executable:
29   -dependencies: []
30   -
31   -description: Rails authentication with email & password.
32   -email: support@thoughtbot.com
33   -executables: []
34   -
35   -extensions: []
36   -
37   -extra_rdoc_files: []
38   -
39   -files:
40   -- CHANGELOG.textile
41   -- LICENSE
42   -- Rakefile
43   -- README.textile
44   -- TODO.textile
45   -- app/controllers
46   -- app/controllers/clearance
47   -- app/controllers/clearance/confirmations_controller.rb
48   -- app/controllers/clearance/passwords_controller.rb
49   -- app/controllers/clearance/sessions_controller.rb
50   -- app/controllers/clearance/users_controller.rb
51   -- app/models
52   -- app/models/clearance_mailer.rb
53   -- app/views
54   -- app/views/clearance_mailer
55   -- app/views/clearance_mailer/change_password.html.erb
56   -- app/views/clearance_mailer/confirmation.html.erb
57   -- app/views/passwords
58   -- app/views/passwords/edit.html.erb
59   -- app/views/passwords/new.html.erb
60   -- app/views/sessions
61   -- app/views/sessions/new.html.erb
62   -- app/views/users
63   -- app/views/users/_form.html.erb
64   -- app/views/users/new.html.erb
65   -- config/clearance_routes.rb
66   -- generators/clearance
67   -- generators/clearance/clearance_generator.rb
68   -- generators/clearance/lib
69   -- generators/clearance/lib/insert_commands.rb
70   -- generators/clearance/lib/rake_commands.rb
71   -- generators/clearance/templates
72   -- generators/clearance/templates/factories.rb
73   -- generators/clearance/templates/migrations
74   -- generators/clearance/templates/migrations/create_users.rb
75   -- generators/clearance/templates/migrations/update_users.rb
76   -- generators/clearance/templates/README
77   -- generators/clearance/templates/user.rb
78   -- generators/clearance/USAGE
79   -- generators/clearance_features
80   -- generators/clearance_features/clearance_features_generator.rb
81   -- generators/clearance_features/templates
82   -- generators/clearance_features/templates/features
83   -- generators/clearance_features/templates/features/password_reset.feature
84   -- generators/clearance_features/templates/features/sign_in.feature
85   -- generators/clearance_features/templates/features/sign_out.feature
86   -- generators/clearance_features/templates/features/sign_up.feature
87   -- generators/clearance_features/templates/features/step_definitions
88   -- generators/clearance_features/templates/features/step_definitions/clearance_steps.rb
89   -- generators/clearance_features/templates/features/step_definitions/factory_girl_steps.rb
90   -- generators/clearance_features/templates/features/support
91   -- generators/clearance_features/templates/features/support/paths.rb
92   -- generators/clearance_features/USAGE
93   -- generators/clearance_views
94   -- generators/clearance_views/clearance_views_generator.rb
95   -- generators/clearance_views/templates
96   -- generators/clearance_views/templates/formtastic
97   -- generators/clearance_views/templates/formtastic/passwords
98   -- generators/clearance_views/templates/formtastic/passwords/edit.html.erb
99   -- generators/clearance_views/templates/formtastic/passwords/new.html.erb
100   -- generators/clearance_views/templates/formtastic/sessions
101   -- generators/clearance_views/templates/formtastic/sessions/new.html.erb
102   -- generators/clearance_views/templates/formtastic/users
103   -- generators/clearance_views/templates/formtastic/users/_inputs.html.erb
104   -- generators/clearance_views/templates/formtastic/users/new.html.erb
105   -- generators/clearance_views/USAGE
106   -- lib/clearance
107   -- lib/clearance/authentication.rb
108   -- lib/clearance/extensions
109   -- lib/clearance/extensions/errors.rb
110   -- lib/clearance/extensions/rescue.rb
111   -- lib/clearance/extensions/routes.rb
112   -- lib/clearance/user.rb
113   -- lib/clearance.rb
114   -- shoulda_macros/clearance.rb
115   -- rails/init.rb
116   -has_rdoc: true
117   -homepage: http://github.com/thoughtbot/clearance
118   -licenses: []
119   -
120   -post_install_message:
121   -rdoc_options: []
122   -
123   -require_paths:
124   -- lib
125   -required_ruby_version: !ruby/object:Gem::Requirement
126   - requirements:
127   - - - ">="
128   - - !ruby/object:Gem::Version
129   - version: "0"
130   - version:
131   -required_rubygems_version: !ruby/object:Gem::Requirement
132   - requirements:
133   - - - ">="
134   - - !ruby/object:Gem::Version
135   - version: "0"
136   - version:
137   -requirements: []
138   -
139   -rubyforge_project:
140   -rubygems_version: 1.3.4
141   -signing_key:
142   -specification_version: 3
143   -summary: Rails authentication with email & password.
144   -test_files: []
145   -
vendor/gems/thoughtbot-clearance-0.7.0/CHANGELOG.textile
... ... @@ -1,176 +0,0 @@
1   -h2. 0.7.0 (08/04/2009)
2   -
3   -* Redirect signed in user who clicks confirmation link again. (Dan Croak)
4   -* Redirect signed out user who clicks confirmation link again. (Dan Croak)
5   -* Added signed_out? convenience method for controllers, helpers, views. (Dan
6   -Croak)
7   -* Added clearance_views generator. By default, creates formtastic views which
8   -pass all tests and features. (Dan Croak)
9   -
10   -h2. 0.6.9 (07/04/2009)
11   -
12   -* Added timestamps to create users migration. (Dan Croak)
13   -* Ready for Ruby 1.9. (Jason Morrison, Nick Quaranto)
14   -
15   -h2. 0.6.8 (06/24/2009)
16   -
17   -* Added defined? checks for various Rails constants such as ActionController
18   -for easier unit testing of Clearance extensions... particularly ActiveRecord
19   -extensions... particularly strong_password. (Dan Croak)
20   -
21   -h2. 0.6.7 (06/13/2009)
22   -
23   -* [#30] Added sign_up, sign_in, sign_out named routes. (Dan Croak)
24   -* [#22] Minimizing Reek smell: Duplication in redirect_back_or. (Dan Croak)
25   -* Deprecated sign_user_in. Told developers to use sign_in instead. (Dan
26   -Croak)
27   -* [#16] flash_success_after_create, flash_notice_after_create, flash_failure_after_create, flash_sucess_after_update, flash_success_after_destroy, etc. (Dan Croak)
28   -* [#17] bug. added #create to forbidden before_filters on confirmations controller. (Dan Croak)
29   -* [#24] should_be_signed_in_as shouldn't look in the session. (Dan Croak)
30   -* README improvements. (Dan Croak)
31   -* Move routes loading to separate file. (Joshua Clayton)
32   -
33   -h2. 0.6.6 (05/18/2009)
34   -
35   -* [#14] replaced class_eval in Clearance::User with modules. This was needed
36   -in a thoughtbot client app so we could write our own validations. (Dan Croak)
37   -
38   -h2. 0.6.5 (05/17/2009)
39   -
40   -* [#6] Make Clearance i18n aware. (Timur Vafin, Marcel Goerner, Eugene Bolshakov, Dan Croak)
41   -
42   -h2. 0.6.4 (05/12/2009)
43   -
44   -* Moved issue tracking to Github from Lighthouse. (Dan Croak)
45   -* [#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)
46   -* [#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)
47   -* [#13] move private methods on sessions controller into Clearance::Authentication module (Dan Croak)
48   -* [#9] audited flash keys. (Dan Croak)
49   -
50   -h2. 0.6.3 (04/23/2009)
51   -
52   -* Scoping ClearanceMailer properly within controllers so it works in production environments. (Nick Quaranto)
53   -
54   -h2. 0.6.2 (04/22/2009)
55   -
56   -* Insert Clearance::User into User model if it exists. (Nick Quaranto)
57   -* World(NavigationHelpers) Cucumber 3.0 style. (Shay Arnett & Mark Cornick)
58   -
59   -h2. 0.6.1 (04/21/2009)
60   -* Scope operators are necessary to keep Rails happy. Reverting the original
61   -revert so they're back in the library now for constants referenced inside of
62   -the gem. (Nick Quaranto)
63   -
64   -h2. 0.6.0 (04/21/2009)
65   -
66   -* Converted Clearance to a Rails engine. (Dan Croak & Joe Ferris)
67   -* Include Clearance::User in User model in app. (Dan Croak & Joe Ferris)
68   -* Include Clearance::Authentication in ApplicationController. (Dan Croak & Joe Ferris)
69   -* Namespace controllers under Clearance. (Dan Croak & Joe Ferris)
70   -* Routes move to engine, use namespaced controllers but publicly the same. (Dan Croak & Joe Ferris)
71   -* If you want to override a controller, subclass it like SessionsController <
72   -Clearance::SessionsController. This gives you access to usual hooks such as
73   -url_after_create. (Dan Croak & Joe Ferris)
74   -* Controllers, mailer, model, routes all unit tested inside engine. Use
75   -script/generate clearance_features to test integration of Clearance with your
76   -Rails app. No longer including modules in your app's test files. (Dan Croak & Joe Ferris)
77   -* Moved views to engine. (Joe Ferris)
78   -* Converted generated test/factories/clearance.rb to use inheritence for
79   -email_confirmed_user. (Dan Croak)
80   -* Corrected some spelling errors with methods (Nick Quaranto)
81   -* Converted "I should see error messages" to use a regex in the features (Nick
82   -Quaranto)
83   -* Loading clearance routes after rails routes via some monkeypatching (Nick
84   -Quaranto)
85   -* Made the clearance controllers unloadable to stop constant loading errors in
86   -development mode (Nick Quaranto)
87   -
88   -h2. 0.5.6 (4/11/2009)
89   -
90   -* [#57] Step definition changed for "User should see error messages" so
91   -features won't fail for certain validations. (Nick Quaranto)
92   -
93   -h2. 0.5.5 (3/23/2009)
94   -
95   -* Removing duplicate test to get rid of warning. (Nick Quaranto)
96   -
97   -h2. 0.5.4 (3/21/2009)
98   -
99   -* When users fail logging in, redirect them instead of rendering. (Matt
100   -Jankowski)
101   -
102   -h2. 0.5.3 (3/5/2009)
103   -
104   -* Clearance now works with (and requires) Shoulda 2.10.0. (Mark Cornick, Joe
105   -Ferris, Dan Croak)
106   -* Prefer flat over nested contexts in sessions_controller_test. (Joe Ferris,
107   -Dan Croak)
108   -
109   -h2. 0.5.2 (3/2/2009)
110   -
111   -* Fixed last remaining errors in Rails 2.3 tests. Now fully compatible. (Joe
112   -Ferris, Dan Croak)
113   -
114   -h2. 0.5.1 (2/27/2009)
115   -
116   -* [#46] A user with unconfirmed email who resets password now confirms email.
117   -(Marcel Görner)
118   -* Refactored user_from_cookie, user_from_session, User#authenticate to use
119   -more direct return code instead of ugly, harder to read ternary. (Dan Croak)
120   -* 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)
121   -* Altered generator to interact with application_controller.rb instead of
122   -application.rb in Rails 2.3 apps. (Dan Croak)
123   -* [#42] Bug fix. Rack-based session change altered how to test remember me
124   -cookie. (Mihai Anca)
125   -
126   -h2. 0.5.0 (2/27/2009)
127   -
128   -* Fixed problem with Cucumber features. (Dan Croak)
129   -* Fixed mising HTTP fluency use case. (Dan Croak)
130   -* Refactored User#update_password to take just parameters it needs. (Dan
131   -Croak)
132   -* Refactored User unit tests to be more readable. (Dan Croak)
133   -
134   -h2. 0.4.9 (2/20/2009)
135   -
136   -* Protect passwords & confirmations actions with forbidden filters. (Dan Croak)
137   -* Return 403 Forbidden status code in those cases. (Tim Pope)
138   -* Test 403 Forbidden status code in Cucumber feature. (Dan Croak, Joe Ferris)
139   -* Raise custom ActionController::Forbidden error internally. (Joe Ferris, Mike Burns, Jason Morrison)
140   -* Test ActionController::Forbidden error is raised in functional test. (Joe Ferris, Mike Burns, Dan Croak)
141   -* [#45] Fixed bug that allowed anyone to edit another user's password (Marcel Görner)
142   -* Required Factory Girl >= 1.2.0. (Dan Croak)
143   -
144   -h2. 0.4.8 (2/16/2009)
145   -
146   -* Added support paths for Cucumber. (Ben Mabey)
147   -* Added documentation for the flash. (Ben Mabey)
148   -* Generators require "test_helper" instead of File.join. for rr compatibility. (Joe Ferris)
149   -* Removed interpolated email address from flash message to make i18n easier. (Bence Nagy)
150   -* Standardized flash messages that refer to email delivery. (Dan Croak)
151   -
152   -h2. 0.4.7 (2/12/2009)
153   -
154   -* Removed Clearance::Test::TestHelper so there is one less setup step. (Dan Croak)
155   -* All test helpers now in shoulda_macros. (Dan Croak)
156   -
157   -h2. 0.4.6 (2/11/2009)
158   -
159   -* Made the modules behave like mixins again. (hat-tip Eloy Duran)
160   -* Created Actions and PrivateMethods modules on controllers for future RDoc reasons. (Dan Croak, Joe Ferris)
161   -
162   -h2. 0.4.5 (2/9/2009)
163   -
164   -* [#43] Removed email downcasing because local-part is case sensitive per RFC5321. (Dan Croak)
165   -* [#42] Removed dependency on Mocha. (Dan Croak)
166   -* Required Shoulda >= 2.9.1. (Dan Croak)
167   -* Added password reset feature to clearance_features generator. (Eugene Bolshakov, Dan Croak)
168   -* Removed unnecessary session[:salt]. (Dan Croak)
169   -* [#41] Only store location for session[:return_to] for GET requests. (Dan Croak)
170   -* Audited "sign up" naming convention. "Register" had slipped in a few places. (Dan Croak)
171   -* 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)
172   -
173   -h2. 0.4.4 (2/2/2009)
174   -
175   -* Added a generator for Cucumber features. (Joe Ferris, Dan Croak)
176   -* Standarized naming for "Sign up," "Sign in," and "Sign out". (Dan Croak)
vendor/gems/thoughtbot-clearance-0.7.0/LICENSE
... ... @@ -1,21 +0,0 @@
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.
vendor/gems/thoughtbot-clearance-0.7.0/README.textile
... ... @@ -1,123 +0,0 @@
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. Wiki
8   -
9   -Most information regarding Clearance is on the "Github Wiki":http://wiki.github.com/thoughtbot/clearance.
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.6.9'
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   -@script/generate clearance@
34   -
35   -A number of files will be created and instructions will be printed.
36   -
37   -You may already have some of these files. Don't worry. You'll be asked if you want to overwrite them.
38   -
39   -Run the migration:
40   -
41   -@rake db:migrate@
42   -
43   -Define a HOST constant in your environment files.
44   -In config/environments/test.rb and config/environments/development.rb it can be:
45   -
46   -@HOST = "localhost"@
47   -
48   -In production.rb it must be the actual host your application is deployed to.
49   -The constant is used by mailers to generate URLs in emails.
50   -
51   -In config/environment.rb:
52   -
53   -@DO_NOT_REPLY = "donotreply@example.com"@
54   -
55   -Define root_url to *something* in your config/routes.rb:
56   -
57   -@map.root :controller => 'home'@
58   -
59   -h2. Cucumber Features
60   -
61   -As your app evolves, you want to know that authentication still works. Clearance's opinion is that you should test its integration with your app using "Cucumber":http://cukes.info/.
62   -
63   -In config/environments/test.rb:
64   -
65   -<pre>
66   -config.gem 'webrat',
67   - :version => '= 0.4.4'
68   -config.gem 'cucumber',
69   - :version => '= 0.3.0'
70   -config.gem 'thoughtbot-factory_girl',
71   - :lib => 'factory_girl',
72   - :source => "http://gems.github.com",
73   - :version => '1.2.1'
74   -</pre>
75   -
76   -Vendor the gems:
77   -
78   -<pre>
79   -rake gems:install RAILS_ENV=test
80   -rake gems:unpack RAILS_ENV=test
81   -</pre>
82   -
83   -We don't vendor nokogiri due to its native extensions, so install it normally on your machine:
84   -
85   -@sudo gem install nokogiri@
86   -
87   -Run the Cucumber generator (if you haven't already) and Clearance's feature generator:
88   -
89   -<pre>
90   -script/generate cucumber
91   -script/generate clearance_features
92   -</pre>
93   -
94   -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:
95   -
96   -<pre>
97   -def path_to(page_name)
98   - case page_name
99   - ...
100   - when /the sign up page/i
101   - new_user_path
102   - when /the sign in page/i
103   - new_session_path
104   - when /the password reset request page/i
105   - new_password_path
106   - ...
107   -end
108   -</pre>
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.
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   -
vendor/gems/thoughtbot-clearance-0.7.0/Rakefile
... ... @@ -1,103 +0,0 @@
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.7.0"
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"]
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   -
vendor/gems/thoughtbot-clearance-0.7.0/TODO.textile
... ... @@ -1,6 +0,0 @@
1   -h1. To-do
2   -
3   -* Make insertion of Clearance::User into User model automatic from the generator.
4   -* Change generated README to include instruction about running the migration.
5   -* DO_NOT_REPLY, HOST refactoring.
6   -
vendor/gems/thoughtbot-clearance-0.7.0/app/controllers/clearance/confirmations_controller.rb
... ... @@ -1,73 +0,0 @@
1   -class Clearance::ConfirmationsController < ApplicationController
2   - unloadable
3   -
4   - before_filter :redirect_signed_in_confirmed_user, :only => [:new, :create]
5   - before_filter :redirect_signed_out_confirmed_user, :only => [:new, :create]
6   - before_filter :forbid_missing_token, :only => [:new, :create]
7   - before_filter :forbid_non_existent_user, :only => [:new, :create]
8   -
9   - filter_parameter_logging :token
10   -
11   - def new
12   - create
13   - end
14   -
15   - def create
16   - @user = ::User.find_by_id_and_token(params[:user_id], params[:token])
17   - @user.confirm_email!
18   -
19   - sign_in(@user)
20   - flash_success_after_create
21   - redirect_to(url_after_create)
22   - end
23   -
24   - private
25   -
26   - def redirect_signed_in_confirmed_user
27   - user = ::User.find_by_id(params[:user_id])
28   - if user && user.email_confirmed? && current_user == user
29   - flash_success_after_create
30   - redirect_to(url_after_create)
31   - end
32   - end
33   -
34   - def redirect_signed_out_confirmed_user
35   - user = ::User.find_by_id(params[:user_id])
36   - if user && user.email_confirmed? && signed_out?
37   - flash_already_confirmed
38   - redirect_to(url_already_confirmed)
39   - end
40   - end
41   -
42   - def forbid_missing_token
43   - if params[:token].blank?
44   - raise ActionController::Forbidden, "missing token"
45   - end
46   - end
47   -
48   - def forbid_non_existent_user
49   - unless ::User.find_by_id_and_token(params[:user_id], params[:token])
50   - raise ActionController::Forbidden, "non-existent user"
51   - end
52   - end
53   -
54   - def flash_success_after_create
55   - flash[:success] = translate(:confirmed_email,
56   - :scope => [:clearance, :controllers, :confirmations],
57   - :default => "Confirmed email and signed in.")
58   - end
59   -
60   - def flash_already_confirmed
61   - flash[:success] = translate(:already_confirmed_email,
62   - :scope => [:clearance, :controllers, :confirmations],
63   - :default => "Already confirmed email. Please sign in.")
64   - end
65   -
66   - def url_after_create
67   - root_url
68   - end
69   -
70   - def url_already_confirmed
71   - sign_in_url
72   - end
73   -end
vendor/gems/thoughtbot-clearance-0.7.0/app/controllers/clearance/passwords_controller.rb
... ... @@ -1,81 +0,0 @@
1   -class Clearance::PasswordsController < ApplicationController
2   - unloadable
3   -
4   - before_filter :forbid_missing_token, :only => [:edit, :update]
5   - before_filter :forbid_non_existent_user, :only => [:edit, :update]
6   - filter_parameter_logging :password, :password_confirmation
7   -
8   - def new
9   - render :template => 'passwords/new'
10   - end
11   -
12   - def create
13   - if user = ::User.find_by_email(params[:password][:email])
14   - user.forgot_password!
15   - ::ClearanceMailer.deliver_change_password user
16   - flash_notice_after_create
17   - redirect_to(url_after_create)
18   - else
19   - flash_failure_after_create
20   - render :template => 'passwords/new'
21   - end
22   - end
23   -
24   - def edit
25   - @user = ::User.find_by_id_and_token(params[:user_id], params[:token])
26   - render :template => 'passwords/edit'
27   - end
28   -
29   - def update
30   - @user = ::User.find_by_id_and_token(params[:user_id], params[:token])
31   -
32   - if @user.update_password(params[:user][:password],
33   - params[:user][:password_confirmation])
34   - @user.confirm_email!
35   - sign_in(@user)
36   - flash_success_after_update
37   - redirect_to(url_after_update)
38   - else
39   - render :template => 'passwords/edit'
40   - end
41   - end
42   -
43   - private
44   -
45   - def forbid_missing_token
46   - if params[:token].blank?
47   - raise ActionController::Forbidden, "missing token"
48   - end
49   - end
50   -
51   - def forbid_non_existent_user
52   - unless ::User.find_by_id_and_token(params[:user_id], params[:token])
53   - raise ActionController::Forbidden, "non-existent user"
54   - end
55   - end
56   -
57   - def flash_notice_after_create
58   - flash[:notice] = translate(:deliver_change_password,
59   - :scope => [:clearance, :controllers, :passwords],
60   - :default => "You will receive an email within the next few minutes. " <<
61   - "It contains instructions for changing your password.")
62   - end
63   -
64   - def flash_failure_after_create
65   - flash.now[:failure] = translate(:unknown_email,
66   - :scope => [:clearance, :controllers, :passwords],
67   - :default => "Unknown email.")
68   - end
69   -
70   - def url_after_create
71   - new_session_url
72   - end
73   -
74   - def flash_success_after_update
75   - flash[:success] = translate(:signed_in, :default => "Signed in.")
76   - end
77   -
78   - def url_after_update
79   - root_url
80   - end
81   -end
vendor/gems/thoughtbot-clearance-0.7.0/app/controllers/clearance/sessions_controller.rb
... ... @@ -1,67 +0,0 @@
1   -class Clearance::SessionsController < ApplicationController
2   - unloadable
3   -
4   - protect_from_forgery :except => :create
5   - filter_parameter_logging :password
6   -
7   - def new
8   - render :template => 'sessions/new'
9   - end
10   -
11   - def create
12   - @user = ::User.authenticate(params[:session][:email],
13   - params[:session][:password])
14   - if @user.nil?
15   - flash_failure_after_create
16   - render :template => 'sessions/new', :status => :unauthorized
17   - else
18   - if @user.email_confirmed?
19   - sign_in(@user)
20   - remember(@user) if remember?
21   - flash_success_after_create
22   - redirect_back_or(url_after_create)
23   - else
24   - ::ClearanceMailer.deliver_confirmation(@user)
25   - flash_notice_after_create
26   - redirect_to(new_session_url)
27   - end
28   - end
29   - end
30   -
31   - def destroy
32   - forget(current_user)
33   - flash_success_after_destroy
34   - redirect_to(url_after_destroy)
35   - end
36   -
37   - private
38   -
39   - def flash_failure_after_create
40   - flash.now[:failure] = translate(:bad_email_or_password,
41   - :scope => [:clearance, :controllers, :sessions],
42   - :default => "Bad email or password.")
43   - end
44   -
45   - def flash_success_after_create
46   - flash[:success] = translate(:signed_in, :default => "Signed in.")
47   - end
48   -
49   - def flash_notice_after_create
50   - flash[:notice] = translate(:unconfirmed_email,
51   - :scope => [:clearance, :controllers, :sessions],
52   - :default => "User has not confirmed email. " <<
53   - "Confirmation email will be resent.")
54   - end
55   -
56   - def url_after_create
57   - root_url
58   - end
59   -
60   - def flash_success_after_destroy
61   - flash[:success] = translate(:signed_out, :default => "Signed out.")
62   - end
63   -
64   - def url_after_destroy
65   - new_session_url
66   - end
67   -end
vendor/gems/thoughtbot-clearance-0.7.0/app/controllers/clearance/users_controller.rb
... ... @@ -1,35 +0,0 @@
1   -class Clearance::UsersController < ApplicationController
2   - unloadable
3   -
4   - before_filter :redirect_to_root, :only => [:new, :create], :if => :signed_in?
5   - filter_parameter_logging :password
6   -
7   - def new
8   - @user = ::User.new(params[:user])
9   - render :template => 'users/new'
10   - end
11   -
12   - def create
13   - @user = ::User.new params[:user]
14   - if @user.save
15   - ::ClearanceMailer.deliver_confirmation @user
16   - flash_notice_after_create
17   - redirect_to(url_after_create)
18   - else
19   - render :template => 'users/new'
20   - end
21   - end
22   -
23   - private
24   -
25   - def flash_notice_after_create
26   - flash[:notice] = translate(:deliver_confirmation,
27   - :scope => [:clearance, :controllers, :users],
28   - :default => "You will receive an email within the next few minutes. " <<
29   - "It contains instructions for confirming your account.")
30   - end
31   -
32   - def url_after_create
33   - new_session_url
34   - end
35   -end
vendor/gems/thoughtbot-clearance-0.7.0/app/models/clearance_mailer.rb
... ... @@ -1,23 +0,0 @@
1   -class ClearanceMailer < ActionMailer::Base
2   -
3   - default_url_options[:host] = HOST
4   -
5   - def change_password(user)
6   - from DO_NOT_REPLY
7   - recipients user.email
8   - subject I18n.t(:change_password,
9   - :scope => [:clearance, :models, :clearance_mailer],
10   - :default => "Change your password")
11   - body :user => user
12   - end
13   -
14   - def confirmation(user)
15   - from DO_NOT_REPLY
16   - recipients user.email
17   - subject I18n.t(:confirmation,
18   - :scope => [:clearance, :models, :clearance_mailer],
19   - :default => "Account confirmation")
20   - body :user => user
21   - end
22   -
23   -end
vendor/gems/thoughtbot-clearance-0.7.0/app/views/clearance_mailer/change_password.html.erb
... ... @@ -1,7 +0,0 @@
1   -Someone, hopefully you, has requested that we send you a link to change your password.
2   -
3   -Here's the link:
4   -
5   -<%= edit_user_password_url(@user, :token => @user.token, :escape => false) %>
6   -
7   -If you didn't request this, ignore this email. Don't worry. Your password hasn't been changed.
vendor/gems/thoughtbot-clearance-0.7.0/app/views/clearance_mailer/confirmation.html.erb
... ... @@ -1,2 +0,0 @@
1   -
2   -<%= new_user_confirmation_url :user_id => @user, :token => @user.token, :encode => false %>
vendor/gems/thoughtbot-clearance-0.7.0/app/views/passwords/edit.html.erb
... ... @@ -1,23 +0,0 @@
1   -<h2>Change your password</h2>
2   -
3   -<p>
4   - Your password has been reset. Choose a new password below.
5   -</p>
6   -
7   -<%= error_messages_for :user %>
8   -
9   -<% form_for(:user,
10   - :url => user_password_path(@user, :token => @user.token),
11   - :html => { :method => :put }) do |form| %>
12   - <div class="password_field">
13   - <%= form.label :password, "Choose password" %>
14   - <%= form.password_field :password %>
15   - </div>
16   - <div class="password_field">
17   - <%= form.label :password_confirmation, "Confirm password" %>
18   - <%= form.password_field :password_confirmation %>
19   - </div>
20   - <div class="submit_field">
21   - <%= form.submit "Save this password", :disable_with => "Please wait..." %>
22   - </div>
23   -<% end %>
vendor/gems/thoughtbot-clearance-0.7.0/app/views/passwords/new.html.erb
... ... @@ -1,15 +0,0 @@
1   -<h2>Change your password</h2>
2   -
3   -<p>
4   - We will email you a link to change your password.
5   -</p>
6   -
7   -<% form_for :password, :url => passwords_path do |form| %>
8   - <div class="text_field">
9   - <%= form.label :email, "Email address" %>
10   - <%= form.text_field :email %>
11   - </div>
12   - <div class="submit_field">
13   - <%= form.submit "Reset password", :disable_with => "Please wait..." %>
14   - </div>
15   -<% end %>
16 0 \ No newline at end of file
vendor/gems/thoughtbot-clearance-0.7.0/app/views/sessions/new.html.erb
... ... @@ -1,28 +0,0 @@
1   -<h2>Sign in</h2>
2   -
3   -<% form_for :session, :url => session_path do |form| %>
4   - <div class="text_field">
5   - <%= form.label :email %>
6   - <%= form.text_field :email %>
7   - </div>
8   - <div class="text_field">
9   - <%= form.label :password %>
10   - <%= form.password_field :password %>
11   - </div>
12   - <div class="text_field">
13   - <%= form.check_box :remember_me %>
14   - <%= form.label :remember_me %>
15   - </div>
16   - <div class="submit_field">
17   - <%= form.submit "Sign in", :disable_with => "Please wait..." %>
18   - </div>
19   -<% end %>
20   -
21   -<ul>
22   - <li>
23   - <%= link_to "Sign up", new_user_path %>
24   - </li>
25   - <li>
26   - <%= link_to "Forgot password?", new_password_path %>
27   - </li>
28   -</ul>
29 0 \ No newline at end of file
vendor/gems/thoughtbot-clearance-0.7.0/app/views/users/_form.html.erb
... ... @@ -1,13 +0,0 @@
1   -<%= form.error_messages %>
2   -<div class="text_field">
3   - <%= form.label :email %>
4   - <%= form.text_field :email %>
5   -</div>
6   -<div class="password_field">
7   - <%= form.label :password %>
8   - <%= form.password_field :password %>
9   -</div>
10   -<div class="password_field">
11   - <%= form.label :password_confirmation, "Confirm password" %>
12   - <%= form.password_field :password_confirmation %>
13   -</div>
14 0 \ No newline at end of file
vendor/gems/thoughtbot-clearance-0.7.0/app/views/users/new.html.erb
... ... @@ -1,6 +0,0 @@
1   -<h2>Sign up</h2>
2   -
3   -<% form_for @user do |form| %>
4   - <%= render :partial => '/users/form', :object => form %>
5   - <%= form.submit 'Sign up', :disable_with => 'Please wait...' %>
6   -<% end %>
vendor/gems/thoughtbot-clearance-0.7.0/config/clearance_routes.rb
... ... @@ -1,30 +0,0 @@
1   -ActionController::Routing::Routes.draw do |map|
2   - map.resources :passwords,
3   - :controller => 'clearance/passwords',
4   - :only => [:new, :create]
5   -
6   - map.resource :session,
7   - :controller => 'clearance/sessions',
8   - :only => [:new, :create, :destroy]
9   -
10   - map.resources :users, :controller => 'clearance/users' do |users|
11   - users.resource :password,
12   - :controller => 'clearance/passwords',
13   - :only => [:create, :edit, :update]
14   -
15   - users.resource :confirmation,
16   - :controller => 'clearance/confirmations',
17   - :only => [:new, :create]
18   - end
19   -
20   - map.sign_up 'sign_up',
21   - :controller => 'clearance/users',
22   - :action => 'new'
23   - map.sign_in 'sign_in',
24   - :controller => 'clearance/sessions',
25   - :action => 'new'
26   - map.sign_out 'sign_out',
27   - :controller => 'clearance/sessions',
28   - :action => 'destroy',
29   - :method => :delete
30   -end
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance/USAGE
... ... @@ -1 +0,0 @@
1   -script/generate clearance
2 0 \ No newline at end of file
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance/clearance_generator.rb
... ... @@ -1,41 +0,0 @@
1   -require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
2   -require File.expand_path(File.dirname(__FILE__) + "/lib/rake_commands.rb")
3   -require 'factory_girl'
4   -
5   -class ClearanceGenerator < Rails::Generator::Base
6   -
7   - def manifest
8   - record do |m|
9   - m.insert_into "app/controllers/application_controller.rb",
10   - "include Clearance::Authentication"
11   -
12   - user_model = "app/models/user.rb"
13   - if File.exists?(user_model)
14   - m.insert_into user_model, "include Clearance::User"
15   - else
16   - m.directory File.join("app", "models")
17   - m.file "user.rb", user_model
18   - end
19   -
20   - m.directory File.join("test", "factories")
21   - m.file "factories.rb", "test/factories/clearance.rb"
22   -
23   - m.migration_template "migrations/#{migration_name}.rb",
24   - 'db/migrate',
25   - :migration_file_name => "clearance_#{migration_name}"
26   -
27   - m.readme "README"
28   - end
29   - end
30   -
31   - private
32   -
33   - def migration_name
34   - if ActiveRecord::Base.connection.table_exists?(:users)
35   - 'update_users'
36   - else
37   - 'create_users'
38   - end
39   - end
40   -
41   -end
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance/lib/insert_commands.rb
... ... @@ -1,33 +0,0 @@
1   -# Mostly pinched from http://github.com/ryanb/nifty-generators/tree/master
2   -
3   -Rails::Generator::Commands::Base.class_eval do
4   - def file_contains?(relative_destination, line)
5   - File.read(destination_path(relative_destination)).include?(line)
6   - end
7   -end
8   -
9   -Rails::Generator::Commands::Create.class_eval do
10   - def insert_into(file, line)
11   - logger.insert "#{line} into #{file}"
12   - unless options[:pretend] || file_contains?(file, line)
13   - gsub_file file, /^(class|module) .+$/ do |match|
14   - "#{match}\n #{line}"
15   - end
16   - end
17   - end
18   -end
19   -
20   -Rails::Generator::Commands::Destroy.class_eval do
21   - def insert_into(file, line)
22   - logger.remove "#{line} from #{file}"
23   - unless options[:pretend]
24   - gsub_file file, "\n #{line}", ''
25   - end
26   - end
27   -end
28   -
29   -Rails::Generator::Commands::List.class_eval do
30   - def insert_into(file, line)
31   - logger.insert "#{line} into #{file}"
32   - end
33   -end
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance/lib/rake_commands.rb
... ... @@ -1,22 +0,0 @@
1   -Rails::Generator::Commands::Create.class_eval do
2   - def rake_db_migrate
3   - logger.rake "db:migrate"
4   - unless system("rake db:migrate")
5   - logger.rake "db:migrate failed. Rolling back"
6   - command(:destroy).invoke!
7   - end
8   - end
9   -end
10   -
11   -Rails::Generator::Commands::Destroy.class_eval do
12   - def rake_db_migrate
13   - logger.rake "db:rollback"
14   - system "rake db:rollback"
15   - end
16   -end
17   -
18   -Rails::Generator::Commands::List.class_eval do
19   - def rake_db_migrate
20   - logger.rake "db:migrate"
21   - end
22   -end
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance/templates/README
... ... @@ -1,22 +0,0 @@
1   -
2   -*******************************************************************************
3   -
4   -Ok, enough fancy automatic stuff. Time for some old school monkey copy-pasting.
5   -
6   -1. Define a HOST constant in your environments files.
7   -In config/environments/test.rb and config/environments/development.rb it can be:
8   -
9   - HOST = "localhost"
10   -
11   -In production.rb it must be the actual host your application is deployed to.
12   -The constant is used by mailers to generate URLs in emails.
13   -
14   -2. In config/environment.rb:
15   -
16   - DO_NOT_REPLY = "donotreply@example.com"
17   -
18   -3. Define root_url to *something* in your config/routes.rb:
19   -
20   - map.root :controller => 'home'
21   -
22   -*******************************************************************************
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance/templates/factories.rb
... ... @@ -1,13 +0,0 @@
1   -Factory.sequence :email do |n|
2   - "user#{n}@example.com"
3   -end
4   -
5   -Factory.define :user do |user|
6   - user.email { Factory.next :email }
7   - user.password { "password" }
8   - user.password_confirmation { "password" }
9   -end
10   -
11   -Factory.define :email_confirmed_user, :parent => :user do |user|
12   - user.email_confirmed { true }
13   -end
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance/templates/migrations/create_users.rb
... ... @@ -1,21 +0,0 @@
1   -class ClearanceCreateUsers < ActiveRecord::Migration
2   - def self.up
3   - create_table(:users) do |t|
4   - t.string :email
5   - t.string :encrypted_password, :limit => 128
6   - t.string :salt, :limit => 128
7   - t.string :token, :limit => 128
8   - t.datetime :token_expires_at
9   - t.boolean :email_confirmed, :default => false, :null => false
10   - t.timestamps
11   - end
12   -
13   - add_index :users, [:id, :token]
14   - add_index :users, :email
15   - add_index :users, :token
16   - end
17   -
18   - def self.down
19   - drop_table :users
20   - end
21   -end
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance/templates/migrations/update_users.rb
... ... @@ -1,41 +0,0 @@
1   -class ClearanceUpdateUsers < ActiveRecord::Migration
2   - def self.up
3   -<%
4   - existing_columns = ActiveRecord::Base.connection.columns(:users).collect { |each| each.name }
5   - columns = [
6   - [:email, 't.string :email'],
7   - [:encrypted_password, 't.string :encrypted_password, :limit => 128'],
8   - [:salt, 't.string :salt, :limit => 128'],
9   - [:token, 't.string :token, :limit => 128'],
10   - [:token_expires_at, 't.datetime :token_expires_at'],
11   - [:email_confirmed, 't.boolean :email_confirmed, :default => false, :null => false']
12   - ].delete_if {|c| existing_columns.include?(c.first.to_s)}
13   --%>
14   - change_table(:users) do |t|
15   -<% columns.each do |c| -%>
16   - <%= c.last %>
17   -<% end -%>
18   - end
19   -
20   -<%
21   - existing_indexes = ActiveRecord::Base.connection.indexes(:users)
22   - index_names = existing_indexes.collect { |each| each.name }
23   - new_indexes = [
24   - [:index_users_on_id_and_token, 'add_index :users, [:id, :token]'],
25   - [:index_users_on_email, 'add_index :users, :email'],
26   - [:index_users_on_token, 'add_index :users, :token']
27   - ].delete_if { |each| index_names.include?(each.first.to_s) }
28   --%>
29   -<% new_indexes.each do |each| -%>
30   - <%= each.last %>
31   -<% end -%>
32   - end
33   -
34   - def self.down
35   - change_table(:users) do |t|
36   -<% unless columns.empty? -%>
37   - t.remove <%= columns.collect { |each| ":#{each.first}" }.join(',') %>
38   -<% end -%>
39   - end
40   - end
41   -end
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance/templates/user.rb
... ... @@ -1,3 +0,0 @@
1   -class User < ActiveRecord::Base
2   - include Clearance::User
3   -end
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_features/USAGE
... ... @@ -1 +0,0 @@
1   -script/generate clearance_features
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_features/clearance_features_generator.rb
... ... @@ -1,20 +0,0 @@
1   -class ClearanceFeaturesGenerator < Rails::Generator::Base
2   -
3   - def manifest
4   - record do |m|
5   - m.directory File.join("features", "step_definitions")
6   - m.directory File.join("features", "support")
7   -
8   - ["features/step_definitions/clearance_steps.rb",
9   - "features/step_definitions/factory_girl_steps.rb",
10   - "features/support/paths.rb",
11   - "features/sign_in.feature",
12   - "features/sign_out.feature",
13   - "features/sign_up.feature",
14   - "features/password_reset.feature"].each do |file|
15   - m.file file, file
16   - end
17   - end
18   - end
19   -
20   -end
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_features/templates/features/password_reset.feature
... ... @@ -1,33 +0,0 @@
1   -Feature: Password reset
2   - In order to sign in even if user forgot their password
3   - A user
4   - Should be able to reset it
5   -
6   - Scenario: User is not signed up
7   - Given no user exists with an email of "email@person.com"
8   - When I request password reset link to be sent to "email@person.com"
9   - Then I should see "Unknown email"
10   -
11   - Scenario: User is signed up and requests password reset
12   - Given I signed up with "email@person.com/password"
13   - When I request password reset link to be sent to "email@person.com"
14   - Then I should see "instructions for changing your password"
15   - And a password reset message should be sent to "email@person.com"
16   -
17   - Scenario: User is signed up updated his password and types wrong confirmation
18   - Given I signed up with "email@person.com/password"
19   - When I follow the password reset link sent to "email@person.com"
20   - And I update my password with "newpassword/wrongconfirmation"
21   - Then I should see error messages
22   - And I should be signed out
23   -
24   - Scenario: User is signed up and updates his password
25   - Given I signed up with "email@person.com/password"
26   - When I follow the password reset link sent to "email@person.com"
27   - And I update my password with "newpassword/newpassword"
28   - Then I should be signed in
29   - When I sign out
30   - Then I should be signed out
31   - And I sign in as "email@person.com/newpassword"
32   - Then I should be signed in
33   -
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_features/templates/features/sign_in.feature
... ... @@ -1,42 +0,0 @@
1   -Feature: Sign in
2   - In order to get access to protected sections of the site
3   - A user
4   - Should be able to sign in
5   -
6   - Scenario: User is not signed up
7   - Given no user exists with an email of "email@person.com"
8   - When I go to the sign in page
9   - And I sign in as "email@person.com/password"
10   - Then I should see "Bad email or password"
11   - And I should be signed out
12   -
13   - Scenario: User is not confirmed
14   - Given I signed up with "email@person.com/password"
15   - When I go to the sign in page
16   - And I sign in as "email@person.com/password"
17   - Then I should see "User has not confirmed email"
18   - And I should be signed out
19   -
20   - Scenario: User enters wrong password
21   - Given I am signed up and confirmed as "email@person.com/password"
22   - When I go to the sign in page
23   - And I sign in as "email@person.com/wrongpassword"
24   - Then I should see "Bad email or password"
25   - And I should be signed out
26   -
27   - Scenario: User signs in successfully
28   - Given I am signed up and confirmed as "email@person.com/password"
29   - When I go to the sign in page
30   - And I sign in as "email@person.com/password"
31   - Then I should see "Signed in"
32   - And I should be signed in
33   -
34   - Scenario: User signs in and checks "remember me"
35   - Given I am signed up and confirmed as "email@person.com/password"
36   - When I go to the sign in page
37   - And I sign in with "remember me" as "email@person.com/password"
38   - Then I should see "Signed in"
39   - And I should be signed in
40   - When I return next time
41   - Then I should be signed in
42   -
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_features/templates/features/sign_out.feature
... ... @@ -1,23 +0,0 @@
1   -Feature: Sign out
2   - To protect my account from unauthorized access
3   - A signed in user
4   - Should be able to sign out
5   -
6   - Scenario: User signs out
7   - Given I am signed up and confirmed as "email@person.com/password"
8   - When I sign in as "email@person.com/password"
9   - Then I should be signed in
10   - And I sign out
11   - Then I should see "Signed out"
12   - And I should be signed out
13   -
14   - Scenario: User who was remembered signs out
15   - Given I am signed up and confirmed as "email@person.com/password"
16   - When I sign in with "remember me" as "email@person.com/password"
17   - Then I should be signed in
18   - And I sign out
19   - Then I should see "Signed out"
20   - And I should be signed out
21   - When I return next time
22   - Then I should be signed out
23   -
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_features/templates/features/sign_up.feature
... ... @@ -1,45 +0,0 @@
1   -Feature: Sign up
2   - In order to get access to protected sections of the site
3   - A user
4   - Should be able to sign up
5   -
6   - Scenario: User signs up with invalid data
7   - When I go to the sign up page
8   - And I fill in "Email" with "invalidemail"
9   - And I fill in "Password" with "password"
10   - And I fill in "Confirm password" with ""
11   - And I press "Sign Up"
12   - Then I should see error messages
13   -
14   - Scenario: User signs up with valid data
15   - When I go to the sign up page
16   - And I fill in "Email" with "email@person.com"
17   - And I fill in "Password" with "password"
18   - And I fill in "Confirm password" with "password"
19   - And I press "Sign Up"
20   - Then I should see "instructions for confirming"
21   - And a confirmation message should be sent to "email@person.com"
22   -
23   - Scenario: User confirms his account
24   - Given I signed up with "email@person.com/password"
25   - When I follow the confirmation link sent to "email@person.com"
26   - Then I should see "Confirmed email and signed in"
27   - And I should be signed in
28   -
29   - Scenario: Signed in user clicks confirmation link again
30   - Given I signed up with "email@person.com/password"
31   - When I follow the confirmation link sent to "email@person.com"
32   - Then I should be signed in
33   - When I follow the confirmation link sent to "email@person.com"
34   - Then I should see "Confirmed email and signed in"
35   - And I should be signed in
36   -
37   - Scenario: Signed out user clicks confirmation link again
38   - Given I signed up with "email@person.com/password"
39   - When I follow the confirmation link sent to "email@person.com"
40   - Then I should be signed in
41   - When I sign out
42   - And I follow the confirmation link sent to "email@person.com"
43   - Then I should see "Already confirmed email. Please sign in."
44   - And I should be signed out
45   -
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_features/templates/features/step_definitions/clearance_steps.rb
... ... @@ -1,110 +0,0 @@
1   -# General
2   -
3   -Then /^I should see error messages$/ do
4   - assert_match /error(s)? prohibited/m, response.body
5   -end
6   -
7   -# Database
8   -
9   -Given /^no user exists with an email of "(.*)"$/ do |email|
10   - assert_nil User.find_by_email(email)
11   -end
12   -
13   -Given /^I signed up with "(.*)\/(.*)"$/ do |email, password|
14   - user = Factory :user,
15   - :email => email,
16   - :password => password,
17   - :password_confirmation => password
18   -end
19   -
20   -Given /^I am signed up and confirmed as "(.*)\/(.*)"$/ do |email, password|
21   - user = Factory :email_confirmed_user,
22   - :email => email,
23   - :password => password,
24   - :password_confirmation => password
25   -end
26   -
27   -# Session
28   -
29   -Then /^I should be signed in$/ do
30   - assert controller.signed_in?
31   -end
32   -
33   -Then /^I should be signed out$/ do
34   - assert ! controller.signed_in?
35   -end
36   -
37   -When /^session is cleared$/ do
38   - request.reset_session
39   - controller.instance_variable_set(:@_current_user, nil)
40   -end
41   -
42   -# Emails
43   -
44   -Then /^a confirmation message should be sent to "(.*)"$/ do |email|
45   - user = User.find_by_email(email)
46   - sent = ActionMailer::Base.deliveries.first
47   - assert_equal [user.email], sent.to
48   - assert_match /confirm/i, sent.subject
49   - assert !user.token.blank?
50   - assert_match /#{user.token}/, sent.body
51   -end
52   -
53   -When /^I follow the confirmation link sent to "(.*)"$/ do |email|
54   - user = User.find_by_email(email)
55   - visit new_user_confirmation_path(:user_id => user, :token => user.token)
56   -end
57   -
58   -Then /^a password reset message should be sent to "(.*)"$/ do |email|
59   - user = User.find_by_email(email)
60   - sent = ActionMailer::Base.deliveries.first
61   - assert_equal [user.email], sent.to
62   - assert_match /password/i, sent.subject
63   - assert !user.token.blank?
64   - assert_match /#{user.token}/, sent.body
65   -end
66   -
67   -When /^I follow the password reset link sent to "(.*)"$/ do |email|
68   - user = User.find_by_email(email)
69   - visit edit_user_password_path(:user_id => user, :token => user.token)
70   -end
71   -
72   -When /^I try to change the password of "(.*)" without token$/ do |email|
73   - user = User.find_by_email(email)
74   - visit edit_user_password_path(:user_id => user)
75   -end
76   -
77   -Then /^I should be forbidden$/ do
78   - assert_response :forbidden
79   -end
80   -
81   -# Actions
82   -
83   -When /^I sign in( with "remember me")? as "(.*)\/(.*)"$/ do |remember, email, password|
84   - When %{I go to the sign in page}
85   - And %{I fill in "Email" with "#{email}"}
86   - And %{I fill in "Password" with "#{password}"}
87   - And %{I check "Remember me"} if remember
88   - And %{I press "Sign In"}
89   -end
90   -
91   -When /^I sign out$/ do
92   - visit '/session', :delete
93   -end
94   -
95   -When /^I request password reset link to be sent to "(.*)"$/ do |email|
96   - When %{I go to the password reset request page}
97   - And %{I fill in "Email address" with "#{email}"}
98   - And %{I press "Reset password"}
99   -end
100   -
101   -When /^I update my password with "(.*)\/(.*)"$/ do |password, confirmation|
102   - And %{I fill in "Choose password" with "#{password}"}
103   - And %{I fill in "Confirm password" with "#{confirmation}"}
104   - And %{I press "Save this password"}
105   -end
106   -
107   -When /^I return next time$/ do
108   - When %{session is cleared}
109   - And %{I go to the homepage}
110   -end
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_features/templates/features/step_definitions/factory_girl_steps.rb
... ... @@ -1,5 +0,0 @@
1   -Factory.factories.each do |name, factory|
2   - Given /^an? #{name} exists with an? (.*) of "([^"]*)"$/ do |attr, value|
3   - Factory(name, attr.gsub(' ', '_') => value)
4   - end
5   -end
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_features/templates/features/support/paths.rb
... ... @@ -1,22 +0,0 @@
1   -module NavigationHelpers
2   - def path_to(page_name)
3   - case page_name
4   -
5   - when /the homepage/i
6   - root_path
7   - when /the sign up page/i
8   - new_user_path
9   - when /the sign in page/i
10   - new_session_path
11   - when /the password reset request page/i
12   - new_password_path
13   -
14   - # Add more page name => path mappings here
15   -
16   - else
17   - raise "Can't find mapping from \"#{page_name}\" to a path."
18   - end
19   - end
20   -end
21   -
22   -World(NavigationHelpers)
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_views/USAGE
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_views/clearance_views_generator.rb
... ... @@ -1,27 +0,0 @@
1   -class ClearanceViewsGenerator < Rails::Generator::Base
2   -
3   - def manifest
4   - record do |m|
5   - strategy = "formtastic"
6   - template_strategy = "erb"
7   -
8   - m.directory File.join("app", "views", "users")
9   - m.file "#{strategy}/users/new.html.#{template_strategy}",
10   - "app/views/users/new.html.#{template_strategy}"
11   - m.file "#{strategy}/users/_inputs.html.#{template_strategy}",
12   - "app/views/users/_inputs.html.#{template_strategy}"
13   -
14   - m.directory File.join("app", "views", "sessions")
15   - m.file "#{strategy}/sessions/new.html.#{template_strategy}",
16   - "app/views/sessions/new.html.#{template_strategy}"
17   -
18   - m.directory File.join("app", "views", "passwords")
19   - m.file "#{strategy}/passwords/new.html.#{template_strategy}",
20   - "app/views/passwords/new.html.#{template_strategy}"
21   - m.file "#{strategy}/passwords/edit.html.#{template_strategy}",
22   - "app/views/passwords/edit.html.#{template_strategy}"
23   - end
24   - end
25   -
26   -end
27   -
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_views/templates/formtastic/passwords/edit.html.erb
... ... @@ -1,21 +0,0 @@
1   -<h2>Change your password</h2>
2   -
3   -<p>
4   - Your password has been reset. Choose a new password below.
5   -</p>
6   -
7   -<% semantic_form_for(:user,
8   - :url => user_password_path(@user, :token => @user.token),
9   - :html => { :method => :put }) do |form| %>
10   - <%= form.error_messages %>
11   - <% form.inputs do -%>
12   - <%= form.input :password, :as => :password,
13   - :label => "Choose password" %>
14   - <%= form.input :password_confirmation, :as => :password,
15   - :label => "Confirm password" %>
16   - <% end -%>
17   - <% form.buttons do -%>
18   - <%= form.commit_button "Save this password" %>
19   - <% end -%>
20   -<% end %>
21   -
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_views/templates/formtastic/passwords/new.html.erb
... ... @@ -1,15 +0,0 @@
1   -<h2>Reset your password</h2>
2   -
3   -<p>
4   - We will email you a link to reset your password.
5   -</p>
6   -
7   -<% semantic_form_for :password, :url => passwords_path do |form| -%>
8   - <% form.inputs do -%>
9   - <%= form.input :email, :label => "Email address" %>
10   - <% end -%>
11   - <% form.buttons do -%>
12   - <%= form.commit_button "Reset password" %>
13   - <% end -%>
14   -<% end -%>
15   -
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_views/templates/formtastic/sessions/new.html.erb
... ... @@ -1,22 +0,0 @@
1   -<h2>Sign in</h2>
2   -
3   -<% semantic_form_for :session, :url => session_path do |form| %>
4   - <% form.inputs do %>
5   - <%= form.input :email %>
6   - <%= form.input :password, :as => :password %>
7   - <%= form.input :remember_me, :as => :boolean, :required => false %>
8   - <% end %>
9   - <% form.buttons do %>
10   - <%= form.commit_button "Sign in" %>
11   - <% end %>
12   -<% end %>
13   -
14   -<ul>
15   - <li>
16   - <%= link_to "Sign up", new_user_path %>
17   - </li>
18   - <li>
19   - <%= link_to "Forgot password?", new_password_path %>
20   - </li>
21   -</ul>
22   -
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_views/templates/formtastic/users/_inputs.html.erb
... ... @@ -1,6 +0,0 @@
1   -<% form.inputs do %>
2   - <%= form.input :email %>
3   - <%= form.input :password %>
4   - <%= form.input :password_confirmation, :label => "Confirm password" %>
5   -<% end %>
6   -
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_views/templates/formtastic/users/new.html.erb
... ... @@ -1,10 +0,0 @@
1   -<h2>Sign up</h2>
2   -
3   -<% semantic_form_for @user do |form| %>
4   - <%= form.error_messages %>
5   - <%= render :partial => "/users/inputs", :locals => { :form => form } %>
6   - <% form.buttons do %>
7   - <%= form.commit_button "Sign up" %>
8   - <% end %>
9   -<% end %>
10   -
vendor/gems/thoughtbot-clearance-0.7.0/lib/clearance.rb
... ... @@ -1,6 +0,0 @@
1   -require 'clearance/extensions/errors'
2   -require 'clearance/extensions/rescue'
3   -require 'clearance/extensions/routes'
4   -
5   -require 'clearance/authentication'
6   -require 'clearance/user'
vendor/gems/thoughtbot-clearance-0.7.0/lib/clearance/authentication.rb
... ... @@ -1,102 +0,0 @@
1   -module Clearance
2   - module Authentication
3   -
4   - def self.included(controller)
5   - controller.send(:include, InstanceMethods)
6   -
7   - controller.class_eval do
8   - helper_method :current_user, :signed_in?, :signed_out?
9   - hide_action :current_user, :signed_in?, :signed_out?
10   - end
11   - end
12   -
13   - module InstanceMethods
14   - def current_user
15   - @_current_user ||= (user_from_cookie || user_from_session)
16   - end
17   -
18   - def signed_in?
19   - ! current_user.nil?
20   - end
21   -
22   - def signed_out?
23   - current_user.nil?
24   - end
25   -
26   - protected
27   -
28   - def authenticate
29   - deny_access unless signed_in?
30   - end
31   -
32   - def user_from_session
33   - if session[:user_id]
34   - return nil unless user = ::User.find_by_id(session[:user_id])
35   - return user if user.email_confirmed?
36   - end
37   - end
38   -
39   - def user_from_cookie
40   - if token = cookies[:remember_token]
41   - return nil unless user = ::User.find_by_token(token)
42   - return user if user.remember?
43   - end
44   - end
45   -
46   - def sign_user_in(user)
47   - warn "[DEPRECATION] sign_user_in: unnecessary. use sign_in(user) instead."
48   - sign_in(user)
49   - end
50   -
51   - def sign_in(user)
52   - if user
53   - session[:user_id] = user.id
54   - end
55   - end
56   -
57   - def remember?
58   - params[:session] && params[:session][:remember_me] == "1"
59   - end
60   -
61   - def remember(user)
62   - user.remember_me!
63   - cookies[:remember_token] = { :value => user.token,
64   - :expires => user.token_expires_at }
65   - end
66   -
67   - def forget(user)
68   - user.forget_me! if user
69   - cookies.delete(:remember_token)
70   - reset_session
71   - end
72   -
73   - def redirect_back_or(default)
74   - redirect_to(return_to || default)
75   - clear_return_to
76   - end
77   -
78   - def return_to
79   - session[:return_to] || params[:return_to]
80   - end
81   -
82   - def clear_return_to
83   - session[:return_to] = nil
84   - end
85   -
86   - def redirect_to_root
87   - redirect_to(root_url)
88   - end
89   -
90   - def store_location
91   - session[:return_to] = request.request_uri if request.get?
92   - end
93   -
94   - def deny_access(flash_message = nil, opts = {})
95   - store_location
96   - flash[:failure] = flash_message if flash_message
97   - redirect_to(new_session_url)
98   - end
99   - end
100   -
101   - end
102   -end
vendor/gems/thoughtbot-clearance-0.7.0/lib/clearance/extensions/errors.rb
... ... @@ -1,6 +0,0 @@
1   -if defined?(ActionController)
2   - module ActionController
3   - class Forbidden < StandardError
4   - end
5   - end
6   -end
vendor/gems/thoughtbot-clearance-0.7.0/lib/clearance/extensions/rescue.rb
... ... @@ -1,3 +0,0 @@
1   -if defined?(ActionController::Base)
2   - ActionController::Base.rescue_responses.update('ActionController::Forbidden' => :forbidden)
3   -end
vendor/gems/thoughtbot-clearance-0.7.0/lib/clearance/extensions/routes.rb
... ... @@ -1,14 +0,0 @@
1   -if defined?(ActionController::Routing::RouteSet)
2   - class ActionController::Routing::RouteSet
3   - def load_routes_with_clearance!
4   - lib_path = File.dirname(__FILE__)
5   - clearance_routes = File.join(lib_path, *%w[.. .. .. config clearance_routes.rb])
6   - unless configuration_files.include?(clearance_routes)
7   - add_configuration_file(clearance_routes)
8   - end
9   - load_routes_without_clearance!
10   - end
11   -
12   - alias_method_chain :load_routes!, :clearance
13   - end
14   -end
vendor/gems/thoughtbot-clearance-0.7.0/lib/clearance/user.rb
... ... @@ -1,143 +0,0 @@
1   -require 'digest/sha1'
2   -
3   -module Clearance
4   - module User
5   -
6   - def self.included(model)
7   - model.extend(ClassMethods)
8   -
9   - model.send(:include, InstanceMethods)
10   - model.send(:include, AttrAccessible)
11   - model.send(:include, AttrAccessor)
12   - model.send(:include, Validations)
13   - model.send(:include, Callbacks)
14   - end
15   -
16   - module AttrAccessible
17   - def self.included(model)
18   - model.class_eval do
19   - attr_accessible :email, :password, :password_confirmation
20   - end
21   - end
22   - end
23   -
24   - module AttrAccessor
25   - def self.included(model)
26   - model.class_eval do
27   - attr_accessor :password, :password_confirmation
28   - end
29   - end
30   - end
31   -
32   - module Validations
33   - def self.included(model)
34   - model.class_eval do
35   - validates_presence_of :email
36   - validates_uniqueness_of :email, :case_sensitive => false
37   - validates_format_of :email, :with => %r{.+@.+\..+}
38   -
39   - validates_presence_of :password, :if => :password_required?
40   - validates_confirmation_of :password, :if => :password_required?
41   - end
42   - end
43   - end
44   -
45   - module Callbacks
46   - def self.included(model)
47   - model.class_eval do
48   - before_save :initialize_salt, :encrypt_password, :initialize_token
49   - end
50   - end
51   - end
52   -
53   - module InstanceMethods
54   - def authenticated?(password)
55   - encrypted_password == encrypt(password)
56   - end
57   -
58   - def encrypt(string)
59   - generate_hash("--#{salt}--#{string}--")
60   - end
61   -
62   - def remember?
63   - token_expires_at && Time.now.utc < token_expires_at
64   - end
65   -
66   - def remember_me!
67   - remember_me_until! 2.weeks.from_now.utc
68   - end
69   -
70   - def forget_me!
71   - clear_token
72   - save(false)
73   - end
74   -
75   - def confirm_email!
76   - self.email_confirmed = true
77   - self.token = nil
78   - save(false)
79   - end
80   -
81   - def forgot_password!
82   - generate_token
83   - save(false)
84   - end
85   -
86   - def update_password(new_password, new_password_confirmation)
87   - self.password = new_password
88   - self.password_confirmation = new_password_confirmation
89   - clear_token if valid?
90   - save
91   - end
92   -
93   - protected
94   -
95   - def generate_hash(string)
96   - Digest::SHA1.hexdigest(string)
97   - end
98   -
99   - def initialize_salt
100   - if new_record?
101   - self.salt = generate_hash("--#{Time.now.utc.to_s}--#{password}--")
102   - end
103   - end
104   -
105   - def encrypt_password
106   - return if password.blank?
107   - self.encrypted_password = encrypt(password)
108   - end
109   -
110   - def generate_token
111   - self.token = encrypt("--#{Time.now.utc.to_s}--#{password}--")
112   - self.token_expires_at = nil
113   - end
114   -
115   - def clear_token
116   - self.token = nil
117   - self.token_expires_at = nil
118   - end
119   -
120   - def initialize_token
121   - generate_token if new_record?
122   - end
123   -
124   - def password_required?
125   - encrypted_password.blank? || !password.blank?
126   - end
127   -
128   - def remember_me_until!(time)
129   - self.token_expires_at = time
130   - self.token = encrypt("--#{token_expires_at}--#{password}--")
131   - save(false)
132   - end
133   - end
134   -
135   - module ClassMethods
136   - def authenticate(email, password)
137   - return nil unless user = find_by_email(email)
138   - return user if user.authenticated?(password)
139   - end
140   - end
141   -
142   - end
143   -end
vendor/gems/thoughtbot-clearance-0.7.0/rails/init.rb
... ... @@ -1 +0,0 @@
1   -require 'clearance'
2 0 \ No newline at end of file
vendor/gems/thoughtbot-clearance-0.7.0/shoulda_macros/clearance.rb
... ... @@ -1,268 +0,0 @@
1   -module Clearance
2   - module Shoulda
3   -
4   - # STATE OF AUTHENTICATION
5   -
6   - def should_be_signed_in_as(&block)
7   - should "be signed in as #{block.bind(self).call}" do
8   - user = block.bind(self).call
9   - assert_not_nil user,
10   - "please pass a User. try: should_be_signed_in_as { @user }"
11   - assert_equal user, @controller.send(:current_user),
12   - "#{user.inspect} is not the current_user, " <<
13   - "which is #{@controller.send(:current_user).inspect}"
14   - end
15   - end
16   -
17   - def should_be_signed_in_and_email_confirmed_as(&block)
18   - warn "[DEPRECATION] should_be_signed_in_and_email_confirmed_as: questionable usefulness"
19   - should_be_signed_in_as &block
20   -
21   - should "have confirmed email" do
22   - user = block.bind(self).call
23   -
24   - assert_not_nil user
25   - assert_equal user, assigns(:user)
26   - assert assigns(:user).email_confirmed?
27   - end
28   - end
29   -
30   - def should_not_be_signed_in
31   - should "not be signed in" do
32   - assert_nil session[:user_id]
33   - end
34   - end
35   -
36   - def should_deny_access_on(http_method, action, opts = {})
37   - warn "[DEPRECATION] should_deny_access_on: use a setup & should_deny_access(:flash => ?)"
38   - flash_message = opts.delete(:flash)
39   - context "on #{http_method} to #{action}" do
40   - setup do
41   - send(http_method, action, opts)
42   - end
43   -
44   - should_deny_access(:flash => flash_message)
45   - end
46   - end
47   -
48   - def should_deny_access(opts = {})
49   - if opts[:flash]
50   - should_set_the_flash_to opts[:flash]
51   - else
52   - should_not_set_the_flash
53   - end
54   -
55   - should_redirect_to('new_session_url') { new_session_url }
56   - end
57   -
58   - # HTTP FLUENCY
59   -
60   - def should_forbid(description, &block)
61   - should "forbid #{description}" do
62   - assert_raises ActionController::Forbidden do
63   - instance_eval(&block)
64   - end
65   - end
66   - end
67   -
68   - # CONTEXTS
69   -
70   - def signed_in_user_context(&blk)
71   - warn "[DEPRECATION] signed_in_user_context: creates a Mystery Guest, causes Obscure Test"
72   - context "A signed in user" do
73   - setup do
74   - @user = Factory(:user)
75   - @user.confirm_email!
76   - sign_in_as @user
77   - end
78   - merge_block(&blk)
79   - end
80   - end
81   -
82   - def public_context(&blk)
83   - warn "[DEPRECATION] public_context: common case is no-op. call sign_out otherwise"
84   - context "The public" do
85   - setup { sign_out }
86   - merge_block(&blk)
87   - end
88   - end
89   -
90   - # CREATING USERS
91   -
92   - def should_create_user_successfully
93   - warn "[DEPRECATION] should_create_user_successfully: not meant to be public, no longer used internally"
94   - should_assign_to :user
95   - should_change 'User.count', :by => 1
96   -
97   - should "send the confirmation email" do
98   - assert_sent_email do |email|
99   - email.subject =~ /account confirmation/i
100   - end
101   - end
102   -
103   - should_set_the_flash_to /confirm/i
104   - should_redirect_to_url_after_create
105   - end
106   -
107   - # RENDERING
108   -
109   - def should_render_nothing
110   - should "render nothing" do
111   - assert @response.body.blank?
112   - end
113   - end
114   -
115   - # REDIRECTS
116   -
117   - def should_redirect_to_url_after_create
118   - should_redirect_to("the post-create url") do
119   - @controller.send(:url_after_create)
120   - end
121   - end
122   -
123   - def should_redirect_to_url_after_update
124   - should_redirect_to("the post-update url") do
125   - @controller.send(:url_after_update)
126   - end
127   - end
128   -
129   - def should_redirect_to_url_after_destroy
130   - should_redirect_to("the post-destroy url") do
131   - @controller.send(:url_after_destroy)
132   - end
133   - end
134   -
135   - def should_redirect_to_url_already_confirmed
136   - should_redirect_to("the already confirmed url") do
137   - @controller.send(:url_already_confirmed)
138   - end
139   - end
140   -
141   - # VALIDATIONS
142   -
143   - def should_validate_confirmation_of(attribute, opts = {})
144   - warn "[DEPRECATION] should_validate_confirmation_of: not meant to be public, no longer used internally"
145   - raise ArgumentError if opts[:factory].nil?
146   -
147   - context "on save" do
148   - should_validate_confirmation_is_not_blank opts[:factory], attribute
149   - should_validate_confirmation_is_not_bad opts[:factory], attribute
150   - end
151   - end
152   -
153   - def should_validate_confirmation_is_not_blank(factory, attribute, opts = {})
154   - warn "[DEPRECATION] should_validate_confirmation_is_not_blank: not meant to be public, no longer used internally"
155   - should "validate #{attribute}_confirmation is not blank" do
156   - model = Factory.build(factory, blank_confirmation_options(attribute))
157   - model.save
158   - assert_confirmation_error(model, attribute,
159   - "#{attribute}_confirmation cannot be blank")
160   - end
161   - end
162   -
163   - def should_validate_confirmation_is_not_bad(factory, attribute, opts = {})
164   - warn "[DEPRECATION] should_validate_confirmation_is_not_bad: not meant to be public, no longer used internally"
165   - should "validate #{attribute}_confirmation is different than #{attribute}" do
166   - model = Factory.build(factory, bad_confirmation_options(attribute))
167   - model.save
168   - assert_confirmation_error(model, attribute,
169   - "#{attribute}_confirmation cannot be different than #{attribute}")
170   - end
171   - end
172   -
173   - # FORMS
174   -
175   - def should_display_a_password_update_form
176   - warn "[DEPRECATION] should_display_a_password_update_form: not meant to be public, no longer used internally"
177   - should "have a form for the user's token, password, and password confirm" do
178   - update_path = ERB::Util.h(
179   - user_password_path(@user, :token => @user.token)
180   - )
181   -
182   - assert_select 'form[action=?]', update_path do
183   - assert_select 'input[name=_method][value=?]', 'put'
184   - assert_select 'input[name=?]', 'user[password]'
185   - assert_select 'input[name=?]', 'user[password_confirmation]'
186   - end
187   - end
188   - end
189   -
190   - def should_display_a_sign_up_form
191   - warn "[DEPRECATION] should_display_a_sign_up_form: not meant to be public, no longer used internally"
192   - should "display a form to sign up" do
193   - assert_select "form[action=#{users_path}][method=post]",
194   - true, "There must be a form to sign up" do
195   - assert_select "input[type=text][name=?]",
196   - "user[email]", true, "There must be an email field"
197   - assert_select "input[type=password][name=?]",
198   - "user[password]", true, "There must be a password field"
199   - assert_select "input[type=password][name=?]",
200   - "user[password_confirmation]", true, "There must be a password confirmation field"
201   - assert_select "input[type=submit]", true,
202   - "There must be a submit button"
203   - end
204   - end
205   - end
206   -
207   - def should_display_a_sign_in_form
208   - warn "[DEPRECATION] should_display_a_sign_in_form: not meant to be public, no longer used internally"
209   - should 'display a "sign in" form' do
210   - assert_select "form[action=#{session_path}][method=post]",
211   - true, "There must be a form to sign in" do
212   - assert_select "input[type=text][name=?]",
213   - "session[email]", true, "There must be an email field"
214   - assert_select "input[type=password][name=?]",
215   - "session[password]", true, "There must be a password field"
216   - assert_select "input[type=checkbox][name=?]",
217   - "session[remember_me]", true, "There must be a 'remember me' check box"
218   - assert_select "input[type=submit]", true,
219   - "There must be a submit button"
220   - end
221   - end
222   - end
223   - end
224   -end
225   -
226   -module Clearance
227   - module Shoulda
228   - module Helpers
229   - def sign_in_as(user)
230   - @controller.class_eval { attr_accessor :current_user }
231   - @controller.current_user = user
232   - return user
233   - end
234   -
235   - def sign_in
236   - sign_in_as Factory(:email_confirmed_user)
237   - end
238   -
239   - def sign_out
240   - @controller.class_eval { attr_accessor :current_user }
241   - @controller.current_user = nil
242   - end
243   -
244   - def blank_confirmation_options(attribute)
245   - warn "[DEPRECATION] blank_confirmation_options: not meant to be public, no longer used internally"
246   - opts = { attribute => attribute.to_s }
247   - opts.merge("#{attribute}_confirmation".to_sym => "")
248   - end
249   -
250   - def bad_confirmation_options(attribute)
251   - warn "[DEPRECATION] bad_confirmation_options: not meant to be public, no longer used internally"
252   - opts = { attribute => attribute.to_s }
253   - opts.merge("#{attribute}_confirmation".to_sym => "not_#{attribute}")
254   - end
255   -
256   - def assert_confirmation_error(model, attribute, message = "confirmation error")
257   - warn "[DEPRECATION] assert_confirmation_error: not meant to be public, no longer used internally"
258   - assert model.errors.on(attribute).include?("doesn't match confirmation"),
259   - message
260   - end
261   - end
262   - end
263   -end
264   -
265   -class Test::Unit::TestCase
266   - include Clearance::Shoulda::Helpers
267   -end
268   -Test::Unit::TestCase.extend(Clearance::Shoulda)
vendor/gems/thoughtbot-clearance-0.8.2/CHANGELOG.textile 0 → 100644
... ... @@ -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)
... ...
vendor/gems/thoughtbot-clearance-0.8.2/LICENSE 0 → 100644
... ... @@ -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.
... ...
vendor/gems/thoughtbot-clearance-0.8.2/README.textile 0 → 100644
... ... @@ -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 +
... ...
vendor/gems/thoughtbot-clearance-0.8.2/Rakefile 0 → 100644
... ... @@ -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 +
... ...
vendor/gems/thoughtbot-clearance-0.8.2/TODO.textile 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +h1. To-do
  2 +
  3 +* Make insertion of Clearance::User into User model automatic from the generator.
  4 +* Change generated README to include instruction about running the migration.
  5 +* DO_NOT_REPLY, HOST refactoring.
  6 +
... ...
vendor/gems/thoughtbot-clearance-0.8.2/app/controllers/clearance/confirmations_controller.rb 0 → 100644
... ... @@ -0,0 +1,75 @@
  1 +class Clearance::ConfirmationsController < ApplicationController
  2 + unloadable
  3 +
  4 + before_filter :redirect_signed_in_confirmed_user, :only => [:new, :create]
  5 + before_filter :redirect_signed_out_confirmed_user, :only => [:new, :create]
  6 + before_filter :forbid_missing_token, :only => [:new, :create]
  7 + before_filter :forbid_non_existent_user, :only => [:new, :create]
  8 +
  9 + filter_parameter_logging :token
  10 +
  11 + def new
  12 + create
  13 + end
  14 +
  15 + def create
  16 + @user = ::User.find_by_id_and_confirmation_token(
  17 + params[:user_id], params[:token])
  18 + @user.confirm_email!
  19 +
  20 + sign_in(@user)
  21 + flash_success_after_create
  22 + redirect_to(url_after_create)
  23 + end
  24 +
  25 + private
  26 +
  27 + def redirect_signed_in_confirmed_user
  28 + user = ::User.find_by_id(params[:user_id])
  29 + if user && user.email_confirmed? && current_user == user
  30 + flash_success_after_create
  31 + redirect_to(url_after_create)
  32 + end
  33 + end
  34 +
  35 + def redirect_signed_out_confirmed_user
  36 + user = ::User.find_by_id(params[:user_id])
  37 + if user && user.email_confirmed? && signed_out?
  38 + flash_already_confirmed
  39 + redirect_to(url_already_confirmed)
  40 + end
  41 + end
  42 +
  43 + def forbid_missing_token
  44 + if params[:token].blank?
  45 + raise ActionController::Forbidden, "missing token"
  46 + end
  47 + end
  48 +
  49 + def forbid_non_existent_user
  50 + unless ::User.find_by_id_and_confirmation_token(
  51 + params[:user_id], params[:token])
  52 + raise ActionController::Forbidden, "non-existent user"
  53 + end
  54 + end
  55 +
  56 + def flash_success_after_create
  57 + flash[:success] = translate(:confirmed_email,
  58 + :scope => [:clearance, :controllers, :confirmations],
  59 + :default => "Confirmed email and signed in.")
  60 + end
  61 +
  62 + def flash_already_confirmed
  63 + flash[:success] = translate(:already_confirmed_email,
  64 + :scope => [:clearance, :controllers, :confirmations],
  65 + :default => "Already confirmed email. Please sign in.")
  66 + end
  67 +
  68 + def url_after_create
  69 + root_url
  70 + end
  71 +
  72 + def url_already_confirmed
  73 + sign_in_url
  74 + end
  75 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/app/controllers/clearance/passwords_controller.rb 0 → 100644
... ... @@ -0,0 +1,84 @@
  1 +class Clearance::PasswordsController < ApplicationController
  2 + unloadable
  3 +
  4 + before_filter :forbid_missing_token, :only => [:edit, :update]
  5 + before_filter :forbid_non_existent_user, :only => [:edit, :update]
  6 + filter_parameter_logging :password, :password_confirmation
  7 +
  8 + def new
  9 + render :template => 'passwords/new'
  10 + end
  11 +
  12 + def create
  13 + if user = ::User.find_by_email(params[:password][:email])
  14 + user.forgot_password!
  15 + ::ClearanceMailer.deliver_change_password user
  16 + flash_notice_after_create
  17 + redirect_to(url_after_create)
  18 + else
  19 + flash_failure_after_create
  20 + render :template => 'passwords/new'
  21 + end
  22 + end
  23 +
  24 + def edit
  25 + @user = ::User.find_by_id_and_confirmation_token(
  26 + params[:user_id], params[:token])
  27 + render :template => 'passwords/edit'
  28 + end
  29 +
  30 + def update
  31 + @user = ::User.find_by_id_and_confirmation_token(
  32 + params[:user_id], params[:token])
  33 +
  34 + if @user.update_password(params[:user][:password],
  35 + params[:user][:password_confirmation])
  36 + @user.confirm_email!
  37 + sign_in(@user)
  38 + flash_success_after_update
  39 + redirect_to(url_after_update)
  40 + else
  41 + render :template => 'passwords/edit'
  42 + end
  43 + end
  44 +
  45 + private
  46 +
  47 + def forbid_missing_token
  48 + if params[:token].blank?
  49 + raise ActionController::Forbidden, "missing token"
  50 + end
  51 + end
  52 +
  53 + def forbid_non_existent_user
  54 + unless ::User.find_by_id_and_confirmation_token(
  55 + params[:user_id], params[:token])
  56 + raise ActionController::Forbidden, "non-existent user"
  57 + end
  58 + end
  59 +
  60 + def flash_notice_after_create
  61 + flash[:notice] = translate(:deliver_change_password,
  62 + :scope => [:clearance, :controllers, :passwords],
  63 + :default => "You will receive an email within the next few minutes. " <<
  64 + "It contains instructions for changing your password.")
  65 + end
  66 +
  67 + def flash_failure_after_create
  68 + flash.now[:failure] = translate(:unknown_email,
  69 + :scope => [:clearance, :controllers, :passwords],
  70 + :default => "Unknown email.")
  71 + end
  72 +
  73 + def url_after_create
  74 + new_session_url
  75 + end
  76 +
  77 + def flash_success_after_update
  78 + flash[:success] = translate(:signed_in, :default => "Signed in.")
  79 + end
  80 +
  81 + def url_after_update
  82 + root_url
  83 + end
  84 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/app/controllers/clearance/sessions_controller.rb 0 → 100644
... ... @@ -0,0 +1,66 @@
  1 +class Clearance::SessionsController < ApplicationController
  2 + unloadable
  3 +
  4 + protect_from_forgery :except => :create
  5 + filter_parameter_logging :password
  6 +
  7 + def new
  8 + render :template => 'sessions/new'
  9 + end
  10 +
  11 + def create
  12 + @user = ::User.authenticate(params[:session][:email],
  13 + params[:session][:password])
  14 + if @user.nil?
  15 + flash_failure_after_create
  16 + render :template => 'sessions/new', :status => :unauthorized
  17 + else
  18 + if @user.email_confirmed?
  19 + sign_in(@user)
  20 + flash_success_after_create
  21 + redirect_back_or(url_after_create)
  22 + else
  23 + ::ClearanceMailer.deliver_confirmation(@user)
  24 + flash_notice_after_create
  25 + redirect_to(new_session_url)
  26 + end
  27 + end
  28 + end
  29 +
  30 + def destroy
  31 + sign_out
  32 + flash_success_after_destroy
  33 + redirect_to(url_after_destroy)
  34 + end
  35 +
  36 + private
  37 +
  38 + def flash_failure_after_create
  39 + flash.now[:failure] = translate(:bad_email_or_password,
  40 + :scope => [:clearance, :controllers, :sessions],
  41 + :default => "Bad email or password.")
  42 + end
  43 +
  44 + def flash_success_after_create
  45 + flash[:success] = translate(:signed_in, :default => "Signed in.")
  46 + end
  47 +
  48 + def flash_notice_after_create
  49 + flash[:notice] = translate(:unconfirmed_email,
  50 + :scope => [:clearance, :controllers, :sessions],
  51 + :default => "User has not confirmed email. " <<
  52 + "Confirmation email will be resent.")
  53 + end
  54 +
  55 + def url_after_create
  56 + root_url
  57 + end
  58 +
  59 + def flash_success_after_destroy
  60 + flash[:success] = translate(:signed_out, :default => "Signed out.")
  61 + end
  62 +
  63 + def url_after_destroy
  64 + new_session_url
  65 + end
  66 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/app/controllers/clearance/users_controller.rb 0 → 100644
... ... @@ -0,0 +1,35 @@
  1 +class Clearance::UsersController < ApplicationController
  2 + unloadable
  3 +
  4 + before_filter :redirect_to_root, :only => [:new, :create], :if => :signed_in?
  5 + filter_parameter_logging :password
  6 +
  7 + def new
  8 + @user = ::User.new(params[:user])
  9 + render :template => 'users/new'
  10 + end
  11 +
  12 + def create
  13 + @user = ::User.new params[:user]
  14 + if @user.save
  15 + ::ClearanceMailer.deliver_confirmation @user
  16 + flash_notice_after_create
  17 + redirect_to(url_after_create)
  18 + else
  19 + render :template => 'users/new'
  20 + end
  21 + end
  22 +
  23 + private
  24 +
  25 + def flash_notice_after_create
  26 + flash[:notice] = translate(:deliver_confirmation,
  27 + :scope => [:clearance, :controllers, :users],
  28 + :default => "You will receive an email within the next few minutes. " <<
  29 + "It contains instructions for confirming your account.")
  30 + end
  31 +
  32 + def url_after_create
  33 + new_session_url
  34 + end
  35 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/app/models/clearance_mailer.rb 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +class ClearanceMailer < ActionMailer::Base
  2 +
  3 + default_url_options[:host] = HOST
  4 +
  5 + def change_password(user)
  6 + from DO_NOT_REPLY
  7 + recipients user.email
  8 + subject I18n.t(:change_password,
  9 + :scope => [:clearance, :models, :clearance_mailer],
  10 + :default => "Change your password")
  11 + body :user => user
  12 + end
  13 +
  14 + def confirmation(user)
  15 + from DO_NOT_REPLY
  16 + recipients user.email
  17 + subject I18n.t(:confirmation,
  18 + :scope => [:clearance, :models, :clearance_mailer],
  19 + :default => "Account confirmation")
  20 + body :user => user
  21 + end
  22 +
  23 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/app/views/clearance_mailer/change_password.html.erb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +Someone, hopefully you, has requested that we send you a link to change your password.
  2 +
  3 +Here's the link:
  4 +
  5 +<%= edit_user_password_url(@user,
  6 + :token => @user.confirmation_token,
  7 + :escape => false) %>
  8 +
  9 +If you didn't request this, ignore this email. Don't worry. Your password hasn't been changed.
... ...
vendor/gems/thoughtbot-clearance-0.8.2/app/views/clearance_mailer/confirmation.html.erb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +
  2 +<%= new_user_confirmation_url(
  3 + :user_id => @user,
  4 + :token => @user.confirmation_token,
  5 + :encode => false) %>
... ...
vendor/gems/thoughtbot-clearance-0.8.2/app/views/passwords/edit.html.erb 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +<h2>Change your password</h2>
  2 +
  3 +<p>
  4 + Your password has been reset. Choose a new password below.
  5 +</p>
  6 +
  7 +<%= error_messages_for :user %>
  8 +
  9 +<% form_for(:user,
  10 + :url => user_password_path(@user, :token => @user.confirmation_token),
  11 + :html => { :method => :put }) do |form| %>
  12 + <div class="password_field">
  13 + <%= form.label :password, "Choose password" %>
  14 + <%= form.password_field :password %>
  15 + </div>
  16 + <div class="password_field">
  17 + <%= form.label :password_confirmation, "Confirm password" %>
  18 + <%= form.password_field :password_confirmation %>
  19 + </div>
  20 + <div class="submit_field">
  21 + <%= form.submit "Save this password", :disable_with => "Please wait..." %>
  22 + </div>
  23 +<% end %>
... ...
vendor/gems/thoughtbot-clearance-0.8.2/app/views/passwords/new.html.erb 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +<h2>Change your password</h2>
  2 +
  3 +<p>
  4 + We will email you a link to change your password.
  5 +</p>
  6 +
  7 +<% form_for :password, :url => passwords_path do |form| %>
  8 + <div class="text_field">
  9 + <%= form.label :email, "Email address" %>
  10 + <%= form.text_field :email %>
  11 + </div>
  12 + <div class="submit_field">
  13 + <%= form.submit "Reset password", :disable_with => "Please wait..." %>
  14 + </div>
  15 +<% end %>
0 16 \ No newline at end of file
... ...
vendor/gems/thoughtbot-clearance-0.8.2/app/views/sessions/new.html.erb 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +<h2>Sign in</h2>
  2 +
  3 +<% form_for :session, :url => session_path do |form| %>
  4 + <div class="text_field">
  5 + <%= form.label :email %>
  6 + <%= form.text_field :email %>
  7 + </div>
  8 + <div class="text_field">
  9 + <%= form.label :password %>
  10 + <%= form.password_field :password %>
  11 + </div>
  12 + <div class="submit_field">
  13 + <%= form.submit "Sign in", :disable_with => "Please wait..." %>
  14 + </div>
  15 +<% end %>
  16 +
  17 +<ul>
  18 + <li>
  19 + <%= link_to "Sign up", new_user_path %>
  20 + </li>
  21 + <li>
  22 + <%= link_to "Forgot password?", new_password_path %>
  23 + </li>
  24 +</ul>
... ...
vendor/gems/thoughtbot-clearance-0.8.2/app/views/users/_form.html.erb 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +<%= form.error_messages %>
  2 +<div class="text_field">
  3 + <%= form.label :email %>
  4 + <%= form.text_field :email %>
  5 +</div>
  6 +<div class="password_field">
  7 + <%= form.label :password %>
  8 + <%= form.password_field :password %>
  9 +</div>
  10 +<div class="password_field">
  11 + <%= form.label :password_confirmation, "Confirm password" %>
  12 + <%= form.password_field :password_confirmation %>
  13 +</div>
0 14 \ No newline at end of file
... ...
vendor/gems/thoughtbot-clearance-0.8.2/app/views/users/new.html.erb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<h2>Sign up</h2>
  2 +
  3 +<% form_for @user do |form| %>
  4 + <%= render :partial => '/users/form', :object => form %>
  5 + <%= form.submit 'Sign up', :disable_with => 'Please wait...' %>
  6 +<% end %>
... ...
vendor/gems/thoughtbot-clearance-0.8.2/config/clearance_routes.rb 0 → 100644
... ... @@ -0,0 +1,30 @@
  1 +ActionController::Routing::Routes.draw do |map|
  2 + map.resources :passwords,
  3 + :controller => 'clearance/passwords',
  4 + :only => [:new, :create]
  5 +
  6 + map.resource :session,
  7 + :controller => 'clearance/sessions',
  8 + :only => [:new, :create, :destroy]
  9 +
  10 + map.resources :users, :controller => 'clearance/users' do |users|
  11 + users.resource :password,
  12 + :controller => 'clearance/passwords',
  13 + :only => [:create, :edit, :update]
  14 +
  15 + users.resource :confirmation,
  16 + :controller => 'clearance/confirmations',
  17 + :only => [:new, :create]
  18 + end
  19 +
  20 + map.sign_up 'sign_up',
  21 + :controller => 'clearance/users',
  22 + :action => 'new'
  23 + map.sign_in 'sign_in',
  24 + :controller => 'clearance/sessions',
  25 + :action => 'new'
  26 + map.sign_out 'sign_out',
  27 + :controller => 'clearance/sessions',
  28 + :action => 'destroy',
  29 + :method => :delete
  30 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance/USAGE 0 → 100644
... ... @@ -0,0 +1 @@
  1 +script/generate clearance
0 2 \ No newline at end of file
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance/clearance_generator.rb 0 → 100644
... ... @@ -0,0 +1,41 @@
  1 +require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
  2 +require File.expand_path(File.dirname(__FILE__) + "/lib/rake_commands.rb")
  3 +require 'factory_girl'
  4 +
  5 +class ClearanceGenerator < Rails::Generator::Base
  6 +
  7 + def manifest
  8 + record do |m|
  9 + m.insert_into "app/controllers/application_controller.rb",
  10 + "include Clearance::Authentication"
  11 +
  12 + user_model = "app/models/user.rb"
  13 + if File.exists?(user_model)
  14 + m.insert_into user_model, "include Clearance::User"
  15 + else
  16 + m.directory File.join("app", "models")
  17 + m.file "user.rb", user_model
  18 + end
  19 +
  20 + m.directory File.join("test", "factories")
  21 + m.file "factories.rb", "test/factories/clearance.rb"
  22 +
  23 + m.migration_template "migrations/#{migration_name}.rb",
  24 + 'db/migrate',
  25 + :migration_file_name => "clearance_#{migration_name}"
  26 +
  27 + m.readme "README"
  28 + end
  29 + end
  30 +
  31 + private
  32 +
  33 + def migration_name
  34 + if ActiveRecord::Base.connection.table_exists?(:users)
  35 + 'update_users'
  36 + else
  37 + 'create_users'
  38 + end
  39 + end
  40 +
  41 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance/lib/insert_commands.rb 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +# Mostly pinched from http://github.com/ryanb/nifty-generators/tree/master
  2 +
  3 +Rails::Generator::Commands::Base.class_eval do
  4 + def file_contains?(relative_destination, line)
  5 + File.read(destination_path(relative_destination)).include?(line)
  6 + end
  7 +end
  8 +
  9 +Rails::Generator::Commands::Create.class_eval do
  10 + def insert_into(file, line)
  11 + logger.insert "#{line} into #{file}"
  12 + unless options[:pretend] || file_contains?(file, line)
  13 + gsub_file file, /^(class|module) .+$/ do |match|
  14 + "#{match}\n #{line}"
  15 + end
  16 + end
  17 + end
  18 +end
  19 +
  20 +Rails::Generator::Commands::Destroy.class_eval do
  21 + def insert_into(file, line)
  22 + logger.remove "#{line} from #{file}"
  23 + unless options[:pretend]
  24 + gsub_file file, "\n #{line}", ''
  25 + end
  26 + end
  27 +end
  28 +
  29 +Rails::Generator::Commands::List.class_eval do
  30 + def insert_into(file, line)
  31 + logger.insert "#{line} into #{file}"
  32 + end
  33 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance/lib/rake_commands.rb 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +Rails::Generator::Commands::Create.class_eval do
  2 + def rake_db_migrate
  3 + logger.rake "db:migrate"
  4 + unless system("rake db:migrate")
  5 + logger.rake "db:migrate failed. Rolling back"
  6 + command(:destroy).invoke!
  7 + end
  8 + end
  9 +end
  10 +
  11 +Rails::Generator::Commands::Destroy.class_eval do
  12 + def rake_db_migrate
  13 + logger.rake "db:rollback"
  14 + system "rake db:rollback"
  15 + end
  16 +end
  17 +
  18 +Rails::Generator::Commands::List.class_eval do
  19 + def rake_db_migrate
  20 + logger.rake "db:migrate"
  21 + end
  22 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance/templates/README 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +
  2 +*******************************************************************************
  3 +
  4 +Ok, enough fancy automatic stuff. Time for some old school monkey copy-pasting.
  5 +
  6 +1. Define a HOST constant in your environments files.
  7 +In config/environments/test.rb and config/environments/development.rb it can be:
  8 +
  9 + HOST = "localhost"
  10 +
  11 +In production.rb it must be the actual host your application is deployed to.
  12 +The constant is used by mailers to generate URLs in emails.
  13 +
  14 +2. In config/environment.rb:
  15 +
  16 + DO_NOT_REPLY = "donotreply@example.com"
  17 +
  18 +3. Define root_url to *something* in your config/routes.rb:
  19 +
  20 + map.root :controller => 'home'
  21 +
  22 +*******************************************************************************
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance/templates/factories.rb 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +Factory.sequence :email do |n|
  2 + "user#{n}@example.com"
  3 +end
  4 +
  5 +Factory.define :user do |user|
  6 + user.email { Factory.next :email }
  7 + user.password { "password" }
  8 + user.password_confirmation { "password" }
  9 +end
  10 +
  11 +Factory.define :email_confirmed_user, :parent => :user do |user|
  12 + user.email_confirmed { true }
  13 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance/templates/migrations/create_users.rb 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +class ClearanceCreateUsers < ActiveRecord::Migration
  2 + def self.up
  3 + create_table(:users) do |t|
  4 + t.string :email
  5 + t.string :encrypted_password, :limit => 128
  6 + t.string :salt, :limit => 128
  7 + t.string :confirmation_token, :limit => 128
  8 + t.string :remember_token, :limit => 128
  9 + t.boolean :email_confirmed, :default => false, :null => false
  10 + t.timestamps
  11 + end
  12 +
  13 + add_index :users, [:id, :confirmation_token]
  14 + add_index :users, :email
  15 + add_index :users, :remember_token
  16 + end
  17 +
  18 + def self.down
  19 + drop_table :users
  20 + end
  21 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance/templates/migrations/update_users.rb 0 → 100644
... ... @@ -0,0 +1,41 @@
  1 +class ClearanceUpdateUsers < ActiveRecord::Migration
  2 + def self.up
  3 +<%
  4 + existing_columns = ActiveRecord::Base.connection.columns(:users).collect { |each| each.name }
  5 + columns = [
  6 + [:email, 't.string :email'],
  7 + [:encrypted_password, 't.string :encrypted_password, :limit => 128'],
  8 + [:salt, 't.string :salt, :limit => 128'],
  9 + [:confirmation_token, 't.string :confirmation_token, :limit => 128'],
  10 + [:remember_token, 't.string :remember_token, :limit => 128'],
  11 + [:email_confirmed, 't.boolean :email_confirmed, :default => false, :null => false']
  12 + ].delete_if {|c| existing_columns.include?(c.first.to_s)}
  13 +-%>
  14 + change_table(:users) do |t|
  15 +<% columns.each do |c| -%>
  16 + <%= c.last %>
  17 +<% end -%>
  18 + end
  19 +
  20 +<%
  21 + existing_indexes = ActiveRecord::Base.connection.indexes(:users)
  22 + index_names = existing_indexes.collect { |each| each.name }
  23 + new_indexes = [
  24 + [:index_users_on_id_and_confirmation_token, 'add_index :users, [:id, :confirmation_token]'],
  25 + [:index_users_on_email, 'add_index :users, :email'],
  26 + [:index_users_on_remember_token, 'add_index :users, :remember_token']
  27 + ].delete_if { |each| index_names.include?(each.first.to_s) }
  28 +-%>
  29 +<% new_indexes.each do |each| -%>
  30 + <%= each.last %>
  31 +<% end -%>
  32 + end
  33 +
  34 + def self.down
  35 + change_table(:users) do |t|
  36 +<% unless columns.empty? -%>
  37 + t.remove <%= columns.collect { |each| ":#{each.first}" }.join(',') %>
  38 +<% end -%>
  39 + end
  40 + end
  41 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance/templates/user.rb 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +class User < ActiveRecord::Base
  2 + include Clearance::User
  3 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_features/USAGE 0 → 100644
... ... @@ -0,0 +1 @@
  1 +script/generate clearance_features
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_features/clearance_features_generator.rb 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +class ClearanceFeaturesGenerator < Rails::Generator::Base
  2 +
  3 + def manifest
  4 + record do |m|
  5 + m.directory File.join("features", "step_definitions")
  6 + m.directory File.join("features", "support")
  7 +
  8 + ["features/step_definitions/clearance_steps.rb",
  9 + "features/step_definitions/factory_girl_steps.rb",
  10 + "features/support/paths.rb",
  11 + "features/sign_in.feature",
  12 + "features/sign_out.feature",
  13 + "features/sign_up.feature",
  14 + "features/password_reset.feature"].each do |file|
  15 + m.file file, file
  16 + end
  17 + end
  18 + end
  19 +
  20 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_features/templates/features/password_reset.feature 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +Feature: Password reset
  2 + In order to sign in even if user forgot their password
  3 + A user
  4 + Should be able to reset it
  5 +
  6 + Scenario: User is not signed up
  7 + Given no user exists with an email of "email@person.com"
  8 + When I request password reset link to be sent to "email@person.com"
  9 + Then I should see "Unknown email"
  10 +
  11 + Scenario: User is signed up and requests password reset
  12 + Given I signed up with "email@person.com/password"
  13 + When I request password reset link to be sent to "email@person.com"
  14 + Then I should see "instructions for changing your password"
  15 + And a password reset message should be sent to "email@person.com"
  16 +
  17 + Scenario: User is signed up updated his password and types wrong confirmation
  18 + Given I signed up with "email@person.com/password"
  19 + When I follow the password reset link sent to "email@person.com"
  20 + And I update my password with "newpassword/wrongconfirmation"
  21 + Then I should see error messages
  22 + And I should be signed out
  23 +
  24 + Scenario: User is signed up and updates his password
  25 + Given I signed up with "email@person.com/password"
  26 + When I follow the password reset link sent to "email@person.com"
  27 + And I update my password with "newpassword/newpassword"
  28 + Then I should be signed in
  29 + When I sign out
  30 + Then I should be signed out
  31 + And I sign in as "email@person.com/newpassword"
  32 + Then I should be signed in
  33 +
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_features/templates/features/sign_in.feature 0 → 100644
... ... @@ -0,0 +1,35 @@
  1 +Feature: Sign in
  2 + In order to get access to protected sections of the site
  3 + A user
  4 + Should be able to sign in
  5 +
  6 + Scenario: User is not signed up
  7 + Given no user exists with an email of "email@person.com"
  8 + When I go to the sign in page
  9 + And I sign in as "email@person.com/password"
  10 + Then I should see "Bad email or password"
  11 + And I should be signed out
  12 +
  13 + Scenario: User is not confirmed
  14 + Given I signed up with "email@person.com/password"
  15 + When I go to the sign in page
  16 + And I sign in as "email@person.com/password"
  17 + Then I should see "User has not confirmed email"
  18 + And I should be signed out
  19 +
  20 + Scenario: User enters wrong password
  21 + Given I am signed up and confirmed as "email@person.com/password"
  22 + When I go to the sign in page
  23 + And I sign in as "email@person.com/wrongpassword"
  24 + Then I should see "Bad email or password"
  25 + And I should be signed out
  26 +
  27 + Scenario: User signs in successfully
  28 + Given I am signed up and confirmed as "email@person.com/password"
  29 + When I go to the sign in page
  30 + And I sign in as "email@person.com/password"
  31 + Then I should see "Signed in"
  32 + And I should be signed in
  33 + When I return next time
  34 + Then I should be signed in
  35 +
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_features/templates/features/sign_out.feature 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +Feature: Sign out
  2 + To protect my account from unauthorized access
  3 + A signed in user
  4 + Should be able to sign out
  5 +
  6 + Scenario: User signs out
  7 + Given I am signed up and confirmed as "email@person.com/password"
  8 + When I sign in as "email@person.com/password"
  9 + Then I should be signed in
  10 + And I sign out
  11 + Then I should see "Signed out"
  12 + And I should be signed out
  13 + When I return next time
  14 + Then I should be signed out
  15 +
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_features/templates/features/sign_up.feature 0 → 100644
... ... @@ -0,0 +1,45 @@
  1 +Feature: Sign up
  2 + In order to get access to protected sections of the site
  3 + A user
  4 + Should be able to sign up
  5 +
  6 + Scenario: User signs up with invalid data
  7 + When I go to the sign up page
  8 + And I fill in "Email" with "invalidemail"
  9 + And I fill in "Password" with "password"
  10 + And I fill in "Confirm password" with ""
  11 + And I press "Sign Up"
  12 + Then I should see error messages
  13 +
  14 + Scenario: User signs up with valid data
  15 + When I go to the sign up page
  16 + And I fill in "Email" with "email@person.com"
  17 + And I fill in "Password" with "password"
  18 + And I fill in "Confirm password" with "password"
  19 + And I press "Sign Up"
  20 + Then I should see "instructions for confirming"
  21 + And a confirmation message should be sent to "email@person.com"
  22 +
  23 + Scenario: User confirms his account
  24 + Given I signed up with "email@person.com/password"
  25 + When I follow the confirmation link sent to "email@person.com"
  26 + Then I should see "Confirmed email and signed in"
  27 + And I should be signed in
  28 +
  29 + Scenario: Signed in user clicks confirmation link again
  30 + Given I signed up with "email@person.com/password"
  31 + When I follow the confirmation link sent to "email@person.com"
  32 + Then I should be signed in
  33 + When I follow the confirmation link sent to "email@person.com"
  34 + Then I should see "Confirmed email and signed in"
  35 + And I should be signed in
  36 +
  37 + Scenario: Signed out user clicks confirmation link again
  38 + Given I signed up with "email@person.com/password"
  39 + When I follow the confirmation link sent to "email@person.com"
  40 + Then I should be signed in
  41 + When I sign out
  42 + And I follow the confirmation link sent to "email@person.com"
  43 + Then I should see "Already confirmed email. Please sign in."
  44 + And I should be signed out
  45 +
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_features/templates/features/step_definitions/clearance_steps.rb 0 → 100644
... ... @@ -0,0 +1,116 @@
  1 +# General
  2 +
  3 +Then /^I should see error messages$/ do
  4 + assert_match /error(s)? prohibited/m, response.body
  5 +end
  6 +
  7 +# Database
  8 +
  9 +Given /^no user exists with an email of "(.*)"$/ do |email|
  10 + assert_nil User.find_by_email(email)
  11 +end
  12 +
  13 +Given /^I signed up with "(.*)\/(.*)"$/ do |email, password|
  14 + user = Factory :user,
  15 + :email => email,
  16 + :password => password,
  17 + :password_confirmation => password
  18 +end
  19 +
  20 +Given /^I am signed up and confirmed as "(.*)\/(.*)"$/ do |email, password|
  21 + user = Factory :email_confirmed_user,
  22 + :email => email,
  23 + :password => password,
  24 + :password_confirmation => password
  25 +end
  26 +
  27 +# Session
  28 +
  29 +Then /^I should be signed in$/ do
  30 + assert controller.signed_in?
  31 +end
  32 +
  33 +Then /^I should be signed out$/ do
  34 + assert ! controller.signed_in?
  35 +end
  36 +
  37 +When /^session is cleared$/ do
  38 + request.reset_session
  39 + controller.instance_variable_set(:@_current_user, nil)
  40 +end
  41 +
  42 +Given /^I have signed in with "(.*)\/(.*)"$/ do |email, password|
  43 + Given %{I am signed up and confirmed as "#{email}/#{password}"}
  44 + And %{I sign in as "#{email}/#{password}"}
  45 +end
  46 +
  47 +# Emails
  48 +
  49 +Then /^a confirmation message should be sent to "(.*)"$/ do |email|
  50 + user = User.find_by_email(email)
  51 + sent = ActionMailer::Base.deliveries.first
  52 + assert_equal [user.email], sent.to
  53 + assert_match /confirm/i, sent.subject
  54 + assert !user.confirmation_token.blank?
  55 + assert_match /#{user.confirmation_token}/, sent.body
  56 +end
  57 +
  58 +When /^I follow the confirmation link sent to "(.*)"$/ do |email|
  59 + user = User.find_by_email(email)
  60 + visit new_user_confirmation_path(:user_id => user,
  61 + :token => user.confirmation_token)
  62 +end
  63 +
  64 +Then /^a password reset message should be sent to "(.*)"$/ do |email|
  65 + user = User.find_by_email(email)
  66 + sent = ActionMailer::Base.deliveries.first
  67 + assert_equal [user.email], sent.to
  68 + assert_match /password/i, sent.subject
  69 + assert !user.confirmation_token.blank?
  70 + assert_match /#{user.confirmation_token}/, sent.body
  71 +end
  72 +
  73 +When /^I follow the password reset link sent to "(.*)"$/ do |email|
  74 + user = User.find_by_email(email)
  75 + visit edit_user_password_path(:user_id => user,
  76 + :token => user.confirmation_token)
  77 +end
  78 +
  79 +When /^I try to change the password of "(.*)" without token$/ do |email|
  80 + user = User.find_by_email(email)
  81 + visit edit_user_password_path(:user_id => user)
  82 +end
  83 +
  84 +Then /^I should be forbidden$/ do
  85 + assert_response :forbidden
  86 +end
  87 +
  88 +# Actions
  89 +
  90 +When /^I sign in as "(.*)\/(.*)"$/ do |email, password|
  91 + When %{I go to the sign in page}
  92 + And %{I fill in "Email" with "#{email}"}
  93 + And %{I fill in "Password" with "#{password}"}
  94 + And %{I press "Sign In"}
  95 +end
  96 +
  97 +When /^I sign out$/ do
  98 + visit '/session', :delete
  99 +end
  100 +
  101 +When /^I request password reset link to be sent to "(.*)"$/ do |email|
  102 + When %{I go to the password reset request page}
  103 + And %{I fill in "Email address" with "#{email}"}
  104 + And %{I press "Reset password"}
  105 +end
  106 +
  107 +When /^I update my password with "(.*)\/(.*)"$/ do |password, confirmation|
  108 + And %{I fill in "Choose password" with "#{password}"}
  109 + And %{I fill in "Confirm password" with "#{confirmation}"}
  110 + And %{I press "Save this password"}
  111 +end
  112 +
  113 +When /^I return next time$/ do
  114 + When %{session is cleared}
  115 + And %{I go to the homepage}
  116 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_features/templates/features/step_definitions/factory_girl_steps.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +Factory.factories.each do |name, factory|
  2 + Given /^an? #{name} exists with an? (.*) of "([^"]*)"$/ do |attr, value|
  3 + Factory(name, attr.gsub(' ', '_') => value)
  4 + end
  5 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_features/templates/features/support/paths.rb 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +module NavigationHelpers
  2 + def path_to(page_name)
  3 + case page_name
  4 +
  5 + when /the homepage/i
  6 + root_path
  7 + when /the sign up page/i
  8 + new_user_path
  9 + when /the sign in page/i
  10 + new_session_path
  11 + when /the password reset request page/i
  12 + new_password_path
  13 +
  14 + # Add more page name => path mappings here
  15 +
  16 + else
  17 + raise "Can't find mapping from \"#{page_name}\" to a path."
  18 + end
  19 + end
  20 +end
  21 +
  22 +World(NavigationHelpers)
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_views/USAGE 0 → 100644
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_views/clearance_views_generator.rb 0 → 100644
... ... @@ -0,0 +1,27 @@
  1 +class ClearanceViewsGenerator < Rails::Generator::Base
  2 +
  3 + def manifest
  4 + record do |m|
  5 + strategy = "formtastic"
  6 + template_strategy = "erb"
  7 +
  8 + m.directory File.join("app", "views", "users")
  9 + m.file "#{strategy}/users/new.html.#{template_strategy}",
  10 + "app/views/users/new.html.#{template_strategy}"
  11 + m.file "#{strategy}/users/_inputs.html.#{template_strategy}",
  12 + "app/views/users/_inputs.html.#{template_strategy}"
  13 +
  14 + m.directory File.join("app", "views", "sessions")
  15 + m.file "#{strategy}/sessions/new.html.#{template_strategy}",
  16 + "app/views/sessions/new.html.#{template_strategy}"
  17 +
  18 + m.directory File.join("app", "views", "passwords")
  19 + m.file "#{strategy}/passwords/new.html.#{template_strategy}",
  20 + "app/views/passwords/new.html.#{template_strategy}"
  21 + m.file "#{strategy}/passwords/edit.html.#{template_strategy}",
  22 + "app/views/passwords/edit.html.#{template_strategy}"
  23 + end
  24 + end
  25 +
  26 +end
  27 +
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_views/templates/formtastic/passwords/edit.html.erb 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +<h2>Change your password</h2>
  2 +
  3 +<p>
  4 + Your password has been reset. Choose a new password below.
  5 +</p>
  6 +
  7 +<% semantic_form_for(:user,
  8 + :url => user_password_path(@user, :token => @user.confirmation_token),
  9 + :html => { :method => :put }) do |form| %>
  10 + <%= form.error_messages %>
  11 + <% form.inputs do -%>
  12 + <%= form.input :password, :as => :password,
  13 + :label => "Choose password" %>
  14 + <%= form.input :password_confirmation, :as => :password,
  15 + :label => "Confirm password" %>
  16 + <% end -%>
  17 + <% form.buttons do -%>
  18 + <%= form.commit_button "Save this password" %>
  19 + <% end -%>
  20 +<% end %>
  21 +
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_views/templates/formtastic/passwords/new.html.erb 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +<h2>Reset your password</h2>
  2 +
  3 +<p>
  4 + We will email you a link to reset your password.
  5 +</p>
  6 +
  7 +<% semantic_form_for :password, :url => passwords_path do |form| -%>
  8 + <% form.inputs do -%>
  9 + <%= form.input :email, :label => "Email address" %>
  10 + <% end -%>
  11 + <% form.buttons do -%>
  12 + <%= form.commit_button "Reset password" %>
  13 + <% end -%>
  14 +<% end -%>
  15 +
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_views/templates/formtastic/sessions/new.html.erb 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +<h2>Sign in</h2>
  2 +
  3 +<% semantic_form_for :session, :url => session_path do |form| %>
  4 + <% form.inputs do %>
  5 + <%= form.input :email %>
  6 + <%= form.input :password, :as => :password %>
  7 + <% end %>
  8 + <% form.buttons do %>
  9 + <%= form.commit_button "Sign in" %>
  10 + <% end %>
  11 +<% end %>
  12 +
  13 +<ul>
  14 + <li>
  15 + <%= link_to "Sign up", new_user_path %>
  16 + </li>
  17 + <li>
  18 + <%= link_to "Forgot password?", new_password_path %>
  19 + </li>
  20 +</ul>
  21 +
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_views/templates/formtastic/users/_inputs.html.erb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<% form.inputs do %>
  2 + <%= form.input :email %>
  3 + <%= form.input :password %>
  4 + <%= form.input :password_confirmation, :label => "Confirm password" %>
  5 +<% end %>
  6 +
... ...
vendor/gems/thoughtbot-clearance-0.8.2/generators/clearance_views/templates/formtastic/users/new.html.erb 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +<h2>Sign up</h2>
  2 +
  3 +<% semantic_form_for @user do |form| %>
  4 + <%= form.error_messages %>
  5 + <%= render :partial => "/users/inputs", :locals => { :form => form } %>
  6 + <% form.buttons do %>
  7 + <%= form.commit_button "Sign up" %>
  8 + <% end %>
  9 +<% end %>
  10 +
... ...
vendor/gems/thoughtbot-clearance-0.8.2/lib/clearance.rb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +require 'clearance/extensions/errors'
  2 +require 'clearance/extensions/rescue'
  3 +require 'clearance/extensions/routes'
  4 +
  5 +require 'clearance/authentication'
  6 +require 'clearance/user'
... ...
vendor/gems/thoughtbot-clearance-0.8.2/lib/clearance/authentication.rb 0 → 100644
... ... @@ -0,0 +1,125 @@
  1 +module Clearance
  2 + module Authentication
  3 +
  4 + def self.included(controller) # :nodoc:
  5 + controller.send(:include, InstanceMethods)
  6 +
  7 + controller.class_eval do
  8 + helper_method :current_user, :signed_in?, :signed_out?
  9 + hide_action :current_user, :signed_in?, :signed_out?
  10 + end
  11 + end
  12 +
  13 + module InstanceMethods
  14 + # User in the current cookie
  15 + #
  16 + # @return [User, nil]
  17 + def current_user
  18 + @_current_user ||= user_from_cookie
  19 + end
  20 +
  21 + # Set the current user
  22 + #
  23 + # @param [User]
  24 + def current_user=(user)
  25 + @_current_user = user
  26 + end
  27 +
  28 + # Is the current user signed in?
  29 + #
  30 + # @return [true, false]
  31 + def signed_in?
  32 + ! current_user.nil?
  33 + end
  34 +
  35 + # Is the current user signed out?
  36 + #
  37 + # @return [true, false]
  38 + def signed_out?
  39 + current_user.nil?
  40 + end
  41 +
  42 + # Deny the user access if they are signed out.
  43 + #
  44 + # @example
  45 + # before_filter :authenticate
  46 + def authenticate
  47 + deny_access unless signed_in?
  48 + end
  49 +
  50 + # Sign user in to cookie.
  51 + #
  52 + # @param [User]
  53 + #
  54 + # @example
  55 + # sign_in(@user)
  56 + def sign_in(user)
  57 + if user
  58 + user.remember_me!
  59 + cookies[:remember_token] = {
  60 + :value => user.remember_token,
  61 + :expires => 1.year.from_now.utc
  62 + }
  63 + current_user = user
  64 + end
  65 + end
  66 +
  67 + # Sign user out of cookie.
  68 + #
  69 + # @example
  70 + # sign_out
  71 + def sign_out
  72 + cookies.delete(:remember_token)
  73 + current_user = nil
  74 + end
  75 +
  76 + # Store the current location.
  77 + # Display a flash message if included.
  78 + # Redirect to sign in.
  79 + #
  80 + # @param [String] optional flash message to display to denied user
  81 + def deny_access(flash_message = nil)
  82 + store_location
  83 + flash[:failure] = flash_message if flash_message
  84 + redirect_to(new_session_url)
  85 + end
  86 +
  87 + protected
  88 +
  89 + def user_from_cookie
  90 + if token = cookies[:remember_token]
  91 + ::User.find_by_remember_token(token)
  92 + end
  93 + end
  94 +
  95 + def sign_user_in(user)
  96 + warn "[DEPRECATION] sign_user_in: unnecessary. use sign_in(user) instead."
  97 + sign_in(user)
  98 + end
  99 +
  100 + def store_location
  101 + if request.get?
  102 + session[:return_to] = request.request_uri
  103 + end
  104 + end
  105 +
  106 + def redirect_back_or(default)
  107 + redirect_to(return_to || default)
  108 + clear_return_to
  109 + end
  110 +
  111 + def return_to
  112 + session[:return_to] || params[:return_to]
  113 + end
  114 +
  115 + def clear_return_to
  116 + session[:return_to] = nil
  117 + end
  118 +
  119 + def redirect_to_root
  120 + redirect_to(root_url)
  121 + end
  122 + end
  123 +
  124 + end
  125 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/lib/clearance/extensions/errors.rb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +if defined?(ActionController)
  2 + module ActionController
  3 + class Forbidden < StandardError
  4 + end
  5 + end
  6 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/lib/clearance/extensions/rescue.rb 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +if defined?(ActionController::Base)
  2 + ActionController::Base.rescue_responses.update('ActionController::Forbidden' => :forbidden)
  3 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/lib/clearance/extensions/routes.rb 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +if defined?(ActionController::Routing::RouteSet)
  2 + class ActionController::Routing::RouteSet
  3 + def load_routes_with_clearance!
  4 + lib_path = File.dirname(__FILE__)
  5 + clearance_routes = File.join(lib_path, *%w[.. .. .. config clearance_routes.rb])
  6 + unless configuration_files.include?(clearance_routes)
  7 + add_configuration_file(clearance_routes)
  8 + end
  9 + load_routes_without_clearance!
  10 + end
  11 +
  12 + alias_method_chain :load_routes!, :clearance
  13 + end
  14 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/lib/clearance/user.rb 0 → 100644
... ... @@ -0,0 +1,199 @@
  1 +require 'digest/sha1'
  2 +
  3 +module Clearance
  4 + module User
  5 +
  6 + # Hook for all Clearance::User modules.
  7 + #
  8 + # If you need to override parts of Clearance::User,
  9 + # extend and include à la carte.
  10 + #
  11 + # @example
  12 + # extend ClassMethods
  13 + # include InstanceMethods
  14 + # include AttrAccessor
  15 + # include Callbacks
  16 + #
  17 + # @see ClassMethods
  18 + # @see InstanceMethods
  19 + # @see AttrAccessible
  20 + # @see AttrAccessor
  21 + # @see Validations
  22 + # @see Callbacks
  23 + def self.included(model)
  24 + model.extend(ClassMethods)
  25 +
  26 + model.send(:include, InstanceMethods)
  27 + model.send(:include, AttrAccessible)
  28 + model.send(:include, AttrAccessor)
  29 + model.send(:include, Validations)
  30 + model.send(:include, Callbacks)
  31 + end
  32 +
  33 + module AttrAccessible
  34 + # Hook for attr_accessible white list.
  35 + #
  36 + # :email, :password, :password_confirmation
  37 + #
  38 + # Append other attributes that must be mass-assigned in your model.
  39 + #
  40 + # @example
  41 + # include Clearance::User
  42 + # attr_accessible :location, :gender
  43 + def self.included(model)
  44 + model.class_eval do
  45 + attr_accessible :email, :password, :password_confirmation
  46 + end
  47 + end
  48 + end
  49 +
  50 + module AttrAccessor
  51 + # Hook for attr_accessor virtual attributes.
  52 + #
  53 + # :password, :password_confirmation
  54 + def self.included(model)
  55 + model.class_eval do
  56 + attr_accessor :password, :password_confirmation
  57 + end
  58 + end
  59 + end
  60 +
  61 + module Validations
  62 + # Hook for validations.
  63 + #
  64 + # :email must be present, unique, formatted
  65 + #
  66 + # If password is required,
  67 + # :password must be present, confirmed
  68 + def self.included(model)
  69 + model.class_eval do
  70 + validates_presence_of :email
  71 + validates_uniqueness_of :email, :case_sensitive => false
  72 + validates_format_of :email, :with => %r{.+@.+\..+}
  73 +
  74 + validates_presence_of :password, :if => :password_required?
  75 + validates_confirmation_of :password, :if => :password_required?
  76 + end
  77 + end
  78 + end
  79 +
  80 + module Callbacks
  81 + # Hook for callbacks.
  82 + #
  83 + # salt, token, password encryption are handled before_save.
  84 + def self.included(model)
  85 + model.class_eval do
  86 + before_save :initialize_salt,
  87 + :encrypt_password,
  88 + :initialize_confirmation_token
  89 + end
  90 + end
  91 + end
  92 +
  93 + module InstanceMethods
  94 + # Am I authenticated with given password?
  95 + #
  96 + # @param [String] plain-text password
  97 + # @return [true, false]
  98 + # @example
  99 + # user.authenticated?('password')
  100 + def authenticated?(password)
  101 + encrypted_password == encrypt(password)
  102 + end
  103 +
  104 + # Remember me for a year.
  105 + #
  106 + # @example
  107 + # user.remember_me!
  108 + # cookies[:remember_token] = {
  109 + # :value => user.remember_token,
  110 + # :expires => user.remember_token_expires_at
  111 + # }
  112 + def remember_me!
  113 + self.remember_token = encrypt("--#{Time.now.utc}--#{password}--")
  114 + save(false)
  115 + end
  116 +
  117 + # Confirm my email.
  118 + #
  119 + # @example
  120 + # user.confirm_email!
  121 + def confirm_email!
  122 + self.email_confirmed = true
  123 + self.confirmation_token = nil
  124 + save(false)
  125 + end
  126 +
  127 + # Mark my account as forgotten password.
  128 + #
  129 + # @example
  130 + # user.forgot_password!
  131 + def forgot_password!
  132 + generate_confirmation_token
  133 + save(false)
  134 + end
  135 +
  136 + # Update my password.
  137 + #
  138 + # @param [String, String] password and password confirmation
  139 + # @return [true, false] password was updated or not
  140 + # @example
  141 + # user.update_password('new-password', 'new-password')
  142 + def update_password(new_password, new_password_confirmation)
  143 + self.password = new_password
  144 + self.password_confirmation = new_password_confirmation
  145 + if valid?
  146 + self.confirmation_token = nil
  147 + end
  148 + save
  149 + end
  150 +
  151 + protected
  152 +
  153 + def generate_hash(string)
  154 + Digest::SHA1.hexdigest(string)
  155 + end
  156 +
  157 + def initialize_salt
  158 + if new_record?
  159 + self.salt = generate_hash("--#{Time.now.utc}--#{password}--")
  160 + end
  161 + end
  162 +
  163 + def encrypt_password
  164 + return if password.blank?
  165 + self.encrypted_password = encrypt(password)
  166 + end
  167 +
  168 + def encrypt(string)
  169 + generate_hash("--#{salt}--#{string}--")
  170 + end
  171 +
  172 + def generate_confirmation_token
  173 + self.confirmation_token = encrypt("--#{Time.now.utc}--#{password}--")
  174 + end
  175 +
  176 + def initialize_confirmation_token
  177 + generate_confirmation_token if new_record?
  178 + end
  179 +
  180 + def password_required?
  181 + encrypted_password.blank? || !password.blank?
  182 + end
  183 + end
  184 +
  185 + module ClassMethods
  186 + # Authenticate with email and password.
  187 + #
  188 + # @param [String, String] email and password
  189 + # @return [User, nil] authenticated user or nil
  190 + # @example
  191 + # User.authenticate("email@example.com", "password")
  192 + def authenticate(email, password)
  193 + return nil unless user = find_by_email(email)
  194 + return user if user.authenticated?(password)
  195 + end
  196 + end
  197 +
  198 + end
  199 +end
... ...
vendor/gems/thoughtbot-clearance-0.8.2/rails/init.rb 0 → 100644
... ... @@ -0,0 +1 @@
  1 +require 'clearance'
0 2 \ No newline at end of file
... ...
vendor/gems/thoughtbot-clearance-0.8.2/shoulda_macros/clearance.rb 0 → 100644
... ... @@ -0,0 +1,266 @@
  1 +module Clearance
  2 + module Shoulda
  3 +
  4 + # STATE OF AUTHENTICATION
  5 +
  6 + def should_be_signed_in_as(&block)
  7 + warn "[DEPRECATION] should_be_signed_in_as cannot be used in functional tests anymore now that it depends on cookies, which are unavailable until the next request."
  8 + should "be signed in as #{block.bind(self).call}" do
  9 + user = block.bind(self).call
  10 + assert_not_nil user,
  11 + "please pass a User. try: should_be_signed_in_as { @user }"
  12 + assert_equal user, @controller.send(:current_user),
  13 + "#{user.inspect} is not the current_user, " <<
  14 + "which is #{@controller.send(:current_user).inspect}"
  15 + end
  16 + end
  17 +
  18 + def should_be_signed_in_and_email_confirmed_as(&block)
  19 + warn "[DEPRECATION] should_be_signed_in_and_email_confirmed_as: questionable usefulness"
  20 + should_be_signed_in_as &block
  21 +
  22 + should "have confirmed email" do
  23 + user = block.bind(self).call
  24 +
  25 + assert_not_nil user
  26 + assert_equal user, assigns(:user)
  27 + assert assigns(:user).email_confirmed?
  28 + end
  29 + end
  30 +
  31 + def should_not_be_signed_in
  32 + warn "[DEPRECATION] should_not_be_signed_in is no longer a valid test since we now store a remember_token in cookies, not user_id in session"
  33 + should "not be signed in" do
  34 + assert_nil session[:user_id]
  35 + end
  36 + end
  37 +
  38 + def should_deny_access_on(http_method, action, opts = {})
  39 + warn "[DEPRECATION] should_deny_access_on: use a setup & should_deny_access(:flash => ?)"
  40 + flash_message = opts.delete(:flash)
  41 + context "on #{http_method} to #{action}" do
  42 + setup do
  43 + send(http_method, action, opts)
  44 + end
  45 +
  46 + should_deny_access(:flash => flash_message)
  47 + end
  48 + end
  49 +
  50 + def should_deny_access(opts = {})
  51 + if opts[:flash]
  52 + should_set_the_flash_to opts[:flash]
  53 + else
  54 + should_not_set_the_flash
  55 + end
  56 +
  57 + should_redirect_to('new_session_url') { new_session_url }
  58 + end
  59 +
  60 + # HTTP FLUENCY
  61 +
  62 + def should_forbid(description, &block)
  63 + should "forbid #{description}" do
  64 + assert_raises ActionController::Forbidden do
  65 + instance_eval(&block)
  66 + end
  67 + end
  68 + end
  69 +
  70 + # CONTEXTS
  71 +
  72 + def signed_in_user_context(&blk)
  73 + warn "[DEPRECATION] signed_in_user_context: creates a Mystery Guest, causes Obscure Test"
  74 + context "A signed in user" do
  75 + setup do
  76 + @user = Factory(:user)
  77 + @user.confirm_email!
  78 + sign_in_as @user
  79 + end
  80 + merge_block(&blk)
  81 + end
  82 + end
  83 +
  84 + def public_context(&blk)
  85 + warn "[DEPRECATION] public_context: common case is no-op. call sign_out otherwise"
  86 + context "The public" do
  87 + setup { sign_out }
  88 + merge_block(&blk)
  89 + end
  90 + end
  91 +
  92 + # CREATING USERS
  93 +
  94 + def should_create_user_successfully
  95 + warn "[DEPRECATION] should_create_user_successfully: not meant to be public, no longer used internally"
  96 + should_assign_to :user
  97 + should_change 'User.count', :by => 1
  98 +
  99 + should "send the confirmation email" do
  100 + assert_sent_email do |email|
  101 + email.subject =~ /account confirmation/i
  102 + end
  103 + end
  104 +
  105 + should_set_the_flash_to /confirm/i
  106 + should_redirect_to_url_after_create
  107 + end
  108 +
  109 + # RENDERING
  110 +
  111 + def should_render_nothing
  112 + should "render nothing" do
  113 + assert @response.body.blank?
  114 + end
  115 + end
  116 +
  117 + # REDIRECTS
  118 +
  119 + def should_redirect_to_url_after_create
  120 + should_redirect_to("the post-create url") do
  121 + @controller.send(:url_after_create)
  122 + end
  123 + end
  124 +
  125 + def should_redirect_to_url_after_update
  126 + should_redirect_to("the post-update url") do
  127 + @controller.send(:url_after_update)
  128 + end
  129 + end
  130 +
  131 + def should_redirect_to_url_after_destroy
  132 + should_redirect_to("the post-destroy url") do
  133 + @controller.send(:url_after_destroy)
  134 + end
  135 + end
  136 +
  137 + def should_redirect_to_url_already_confirmed
  138 + should_redirect_to("the already confirmed url") do
  139 + @controller.send(:url_already_confirmed)
  140 + end
  141 + end
  142 +
  143 + # VALIDATIONS
  144 +
  145 + def should_validate_confirmation_of(attribute, opts = {})
  146 + warn "[DEPRECATION] should_validate_confirmation_of: not meant to be public, no longer used internally"
  147 + raise ArgumentError if opts[:factory].nil?
  148 +
  149 + context "on save" do
  150 + should_validate_confirmation_is_not_blank opts[:factory], attribute
  151 + should_validate_confirmation_is_not_bad opts[:factory], attribute
  152 + end
  153 + end
  154 +
  155 + def should_validate_confirmation_is_not_blank(factory, attribute, opts = {})
  156 + warn "[DEPRECATION] should_validate_confirmation_is_not_blank: not meant to be public, no longer used internally"
  157 + should "validate #{attribute}_confirmation is not blank" do
  158 + model = Factory.build(factory, blank_confirmation_options(attribute))
  159 + model.save
  160 + assert_confirmation_error(model, attribute,
  161 + "#{attribute}_confirmation cannot be blank")
  162 + end
  163 + end
  164 +
  165 + def should_validate_confirmation_is_not_bad(factory, attribute, opts = {})
  166 + warn "[DEPRECATION] should_validate_confirmation_is_not_bad: not meant to be public, no longer used internally"
  167 + should "validate #{attribute}_confirmation is different than #{attribute}" do
  168 + model = Factory.build(factory, bad_confirmation_options(attribute))
  169 + model.save
  170 + assert_confirmation_error(model, attribute,
  171 + "#{attribute}_confirmation cannot be different than #{attribute}")
  172 + end
  173 + end
  174 +
  175 + # FORMS
  176 +
  177 + def should_display_a_password_update_form
  178 + warn "[DEPRECATION] should_display_a_password_update_form: not meant to be public, no longer used internally"
  179 + should "have a form for the user's token, password, and password confirm" do
  180 + update_path = ERB::Util.h(
  181 + user_password_path(@user, :token => @user.confirmation_token)
  182 + )
  183 +
  184 + assert_select 'form[action=?]', update_path do
  185 + assert_select 'input[name=_method][value=?]', 'put'
  186 + assert_select 'input[name=?]', 'user[password]'
  187 + assert_select 'input[name=?]', 'user[password_confirmation]'
  188 + end
  189 + end
  190 + end
  191 +
  192 + def should_display_a_sign_up_form
  193 + warn "[DEPRECATION] should_display_a_sign_up_form: not meant to be public, no longer used internally"
  194 + should "display a form to sign up" do
  195 + assert_select "form[action=#{users_path}][method=post]",
  196 + true, "There must be a form to sign up" do
  197 + assert_select "input[type=text][name=?]",
  198 + "user[email]", true, "There must be an email field"
  199 + assert_select "input[type=password][name=?]",
  200 + "user[password]", true, "There must be a password field"
  201 + assert_select "input[type=password][name=?]",
  202 + "user[password_confirmation]", true, "There must be a password confirmation field"
  203 + assert_select "input[type=submit]", true,
  204 + "There must be a submit button"
  205 + end
  206 + end
  207 + end
  208 +
  209 + def should_display_a_sign_in_form
  210 + warn "[DEPRECATION] should_display_a_sign_in_form: not meant to be public, no longer used internally"
  211 + should 'display a "sign in" form' do
  212 + assert_select "form[action=#{session_path}][method=post]",
  213 + true, "There must be a form to sign in" do
  214 + assert_select "input[type=text][name=?]",
  215 + "session[email]", true, "There must be an email field"
  216 + assert_select "input[type=password][name=?]",
  217 + "session[password]", true, "There must be a password field"
  218 + assert_select "input[type=submit]", true,
  219 + "There must be a submit button"
  220 + end
  221 + end
  222 + end
  223 + end
  224 +end
  225 +
  226 +module Clearance
  227 + module Shoulda
  228 + module Helpers
  229 + def sign_in_as(user)
  230 + @controller.current_user = user
  231 + return user
  232 + end
  233 +
  234 + def sign_in
  235 + sign_in_as Factory(:email_confirmed_user)
  236 + end
  237 +
  238 + def sign_out
  239 + @controller.current_user = nil
  240 + end
  241 +
  242 + def blank_confirmation_options(attribute)
  243 + warn "[DEPRECATION] blank_confirmation_options: not meant to be public, no longer used internally"
  244 + opts = { attribute => attribute.to_s }
  245 + opts.merge("#{attribute}_confirmation".to_sym => "")
  246 + end
  247 +
  248 + def bad_confirmation_options(attribute)
  249 + warn "[DEPRECATION] bad_confirmation_options: not meant to be public, no longer used internally"
  250 + opts = { attribute => attribute.to_s }
  251 + opts.merge("#{attribute}_confirmation".to_sym => "not_#{attribute}")
  252 + end
  253 +
  254 + def assert_confirmation_error(model, attribute, message = "confirmation error")
  255 + warn "[DEPRECATION] assert_confirmation_error: not meant to be public, no longer used internally"
  256 + assert model.errors.on(attribute).include?("doesn't match confirmation"),
  257 + message
  258 + end
  259 + end
  260 + end
  261 +end
  262 +
  263 +class Test::Unit::TestCase
  264 + include Clearance::Shoulda::Helpers
  265 +end
  266 +Test::Unit::TestCase.extend(Clearance::Shoulda)
... ...