Commit 8a3201bc4322e1ef9190ad3f2dedca14daeff934

Authored by Dan Croak
1 parent 44e775fe

removing clearance plugin. adding clearance 0.7.0 gem.

Showing 175 changed files with 2119 additions and 11336 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 175 files displayed.

vendor/gems/thoughtbot-clearance-0.7.0/.specification 0 → 100644
... ... @@ -0,0 +1,145 @@
  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 0 → 100644
... ... @@ -0,0 +1,176 @@
  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 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.7.0/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. 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 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.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 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.7.0/app/controllers/clearance/confirmations_controller.rb 0 → 100644
... ... @@ -0,0 +1,73 @@
  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 0 → 100644
... ... @@ -0,0 +1,81 @@
  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 0 → 100644
... ... @@ -0,0 +1,67 @@
  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 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.7.0/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.7.0/app/views/clearance_mailer/change_password.html.erb 0 → 100644
... ... @@ -0,0 +1,7 @@
  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 0 → 100644
... ... @@ -0,0 +1,2 @@
  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 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.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 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.7.0/app/views/sessions/new.html.erb 0 → 100644
... ... @@ -0,0 +1,28 @@
  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>
0 29 \ No newline at end of file
... ...
vendor/gems/thoughtbot-clearance-0.7.0/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.7.0/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.7.0/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.7.0/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.7.0/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.7.0/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.7.0/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.7.0/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.7.0/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.7.0/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 :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 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 + [: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 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +class User < ActiveRecord::Base
  2 + include Clearance::User
  3 +end
... ...
vendor/gems/thoughtbot-clearance-0.7.0/generators/clearance_features/USAGE 0 → 100644
... ... @@ -0,0 +1 @@
  1 +script/generate clearance_features
... ...
vendor/gems/thoughtbot-clearance-0.7.0/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.7.0/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.7.0/generators/clearance_features/templates/features/sign_in.feature 0 → 100644
... ... @@ -0,0 +1,42 @@
  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 0 → 100644
... ... @@ -0,0 +1,23 @@
  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 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.7.0/generators/clearance_features/templates/features/step_definitions/clearance_steps.rb 0 → 100644
... ... @@ -0,0 +1,110 @@
  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 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.7.0/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.7.0/generators/clearance_views/USAGE 0 → 100644
vendor/gems/thoughtbot-clearance-0.7.0/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.7.0/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.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 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.7.0/generators/clearance_views/templates/formtastic/sessions/new.html.erb 0 → 100644
... ... @@ -0,0 +1,22 @@
  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 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.7.0/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.7.0/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.7.0/lib/clearance/authentication.rb 0 → 100644
... ... @@ -0,0 +1,102 @@
  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 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.7.0/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.7.0/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.7.0/lib/clearance/user.rb 0 → 100644
... ... @@ -0,0 +1,143 @@
  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 0 → 100644
... ... @@ -0,0 +1 @@
  1 +require 'clearance'
0 2 \ No newline at end of file
... ...
vendor/gems/thoughtbot-clearance-0.7.0/shoulda_macros/clearance.rb 0 → 100644
... ... @@ -0,0 +1,268 @@
  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/plugins/clearance/CHANGELOG.textile
... ... @@ -1,167 +0,0 @@
1   -h2. 0.6.9 (07/04/2009)
2   -
3   -* Added timestamps to create users migration. (Dan Croak)
4   -* Ready for Ruby 1.9. (Jason Morrison, Nick Quaranto)
5   -
6   -h2. 0.6.8 (06/24/2009)
7   -
8   -* Added defined? checks for various Rails constants such as ActionController
9   -for easier unit testing of Clearance extensions... particularly ActiveRecord
10   -extensions... particularly strong_password. (Dan Croak)
11   -
12   -h2. 0.6.7 (06/13/2009)
13   -
14   -* [#30] Added sign_up, sign_in, sign_out named routes. (Dan Croak)
15   -* [#22] Minimizing Reek smell: Duplication in redirect_back_or. (Dan Croak)
16   -* Deprecated sign_user_in. Told developers to use sign_in instead. (Dan
17   -Croak)
18   -* [#16] flash_success_after_create, flash_notice_after_create, flash_failure_after_create, flash_sucess_after_update, flash_success_after_destroy, etc. (Dan Croak)
19   -* [#17] bug. added #create to forbidden before_filters on confirmations controller. (Dan Croak)
20   -* [#24] should_be_signed_in_as shouldn't look in the session. (Dan Croak)
21   -* README improvements. (Dan Croak)
22   -* Move routes loading to separate file. (Joshua Clayton)
23   -
24   -h2. 0.6.6 (05/18/2009)
25   -
26   -* [#14] replaced class_eval in Clearance::User with modules. This was needed
27   -in a thoughtbot client app so we could write our own validations. (Dan Croak)
28   -
29   -h2. 0.6.5 (05/17/2009)
30   -
31   -* [#6] Make Clearance i18n aware. (Timur Vafin, Marcel Goerner, Eugene Bolshakov, Dan Croak)
32   -
33   -h2. 0.6.4 (05/12/2009)
34   -
35   -* Moved issue tracking to Github from Lighthouse. (Dan Croak)
36   -* [#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)
37   -* [#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)
38   -* [#13] move private methods on sessions controller into Clearance::Authentication module (Dan Croak)
39   -* [#9] audited flash keys. (Dan Croak)
40   -
41   -h2. 0.6.3 (04/23/2009)
42   -
43   -* Scoping ClearanceMailer properly within controllers so it works in production environments. (Nick Quaranto)
44   -
45   -h2. 0.6.2 (04/22/2009)
46   -
47   -* Insert Clearance::User into User model if it exists. (Nick Quaranto)
48   -* World(NavigationHelpers) Cucumber 3.0 style. (Shay Arnett & Mark Cornick)
49   -
50   -h2. 0.6.1 (04/21/2009)
51   -* Scope operators are necessary to keep Rails happy. Reverting the original
52   -revert so they're back in the library now for constants referenced inside of
53   -the gem. (Nick Quaranto)
54   -
55   -h2. 0.6.0 (04/21/2009)
56   -
57   -* Converted Clearance to a Rails engine. (Dan Croak & Joe Ferris)
58   -* Include Clearance::User in User model in app. (Dan Croak & Joe Ferris)
59   -* Include Clearance::Authentication in ApplicationController. (Dan Croak & Joe Ferris)
60   -* Namespace controllers under Clearance. (Dan Croak & Joe Ferris)
61   -* Routes move to engine, use namespaced controllers but publicly the same. (Dan Croak & Joe Ferris)
62   -* If you want to override a controller, subclass it like SessionsController <
63   -Clearance::SessionsController. This gives you access to usual hooks such as
64   -url_after_create. (Dan Croak & Joe Ferris)
65   -* Controllers, mailer, model, routes all unit tested inside engine. Use
66   -script/generate clearance_features to test integration of Clearance with your
67   -Rails app. No longer including modules in your app's test files. (Dan Croak & Joe Ferris)
68   -* Moved views to engine. (Joe Ferris)
69   -* Converted generated test/factories/clearance.rb to use inheritence for
70   -email_confirmed_user. (Dan Croak)
71   -* Corrected some spelling errors with methods (Nick Quaranto)
72   -* Converted "I should see error messages" to use a regex in the features (Nick
73   -Quaranto)
74   -* Loading clearance routes after rails routes via some monkeypatching (Nick
75   -Quaranto)
76   -* Made the clearance controllers unloadable to stop constant loading errors in
77   -development mode (Nick Quaranto)
78   -
79   -h2. 0.5.6 (4/11/2009)
80   -
81   -* [#57] Step definition changed for "User should see error messages" so
82   -features won't fail for certain validations. (Nick Quaranto)
83   -
84   -h2. 0.5.5 (3/23/2009)
85   -
86   -* Removing duplicate test to get rid of warning. (Nick Quaranto)
87   -
88   -h2. 0.5.4 (3/21/2009)
89   -
90   -* When users fail logging in, redirect them instead of rendering. (Matt
91   -Jankowski)
92   -
93   -h2. 0.5.3 (3/5/2009)
94   -
95   -* Clearance now works with (and requires) Shoulda 2.10.0. (Mark Cornick, Joe
96   -Ferris, Dan Croak)
97   -* Prefer flat over nested contexts in sessions_controller_test. (Joe Ferris,
98   -Dan Croak)
99   -
100   -h2. 0.5.2 (3/2/2009)
101   -
102   -* Fixed last remaining errors in Rails 2.3 tests. Now fully compatible. (Joe
103   -Ferris, Dan Croak)
104   -
105   -h2. 0.5.1 (2/27/2009)
106   -
107   -* [#46] A user with unconfirmed email who resets password now confirms email.
108   -(Marcel Görner)
109   -* Refactored user_from_cookie, user_from_session, User#authenticate to use
110   -more direct return code instead of ugly, harder to read ternary. (Dan Croak)
111   -* 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)
112   -* Altered generator to interact with application_controller.rb instead of
113   -application.rb in Rails 2.3 apps. (Dan Croak)
114   -* [#42] Bug fix. Rack-based session change altered how to test remember me
115   -cookie. (Mihai Anca)
116   -
117   -h2. 0.5.0 (2/27/2009)
118   -
119   -* Fixed problem with Cucumber features. (Dan Croak)
120   -* Fixed mising HTTP fluency use case. (Dan Croak)
121   -* Refactored User#update_password to take just parameters it needs. (Dan
122   -Croak)
123   -* Refactored User unit tests to be more readable. (Dan Croak)
124   -
125   -h2. 0.4.9 (2/20/2009)
126   -
127   -* Protect passwords & confirmations actions with forbidden filters. (Dan Croak)
128   -* Return 403 Forbidden status code in those cases. (Tim Pope)
129   -* Test 403 Forbidden status code in Cucumber feature. (Dan Croak, Joe Ferris)
130   -* Raise custom ActionController::Forbidden error internally. (Joe Ferris, Mike Burns, Jason Morrison)
131   -* Test ActionController::Forbidden error is raised in functional test. (Joe Ferris, Mike Burns, Dan Croak)
132   -* [#45] Fixed bug that allowed anyone to edit another user's password (Marcel Görner)
133   -* Required Factory Girl >= 1.2.0. (Dan Croak)
134   -
135   -h2. 0.4.8 (2/16/2009)
136   -
137   -* Added support paths for Cucumber. (Ben Mabey)
138   -* Added documentation for the flash. (Ben Mabey)
139   -* Generators require "test_helper" instead of File.join. for rr compatibility. (Joe Ferris)
140   -* Removed interpolated email address from flash message to make i18n easier. (Bence Nagy)
141   -* Standardized flash messages that refer to email delivery. (Dan Croak)
142   -
143   -h2. 0.4.7 (2/12/2009)
144   -
145   -* Removed Clearance::Test::TestHelper so there is one less setup step. (Dan Croak)
146   -* All test helpers now in shoulda_macros. (Dan Croak)
147   -
148   -h2. 0.4.6 (2/11/2009)
149   -
150   -* Made the modules behave like mixins again. (hat-tip Eloy Duran)
151   -* Created Actions and PrivateMethods modules on controllers for future RDoc reasons. (Dan Croak, Joe Ferris)
152   -
153   -h2. 0.4.5 (2/9/2009)
154   -
155   -* [#43] Removed email downcasing because local-part is case sensitive per RFC5321. (Dan Croak)
156   -* [#42] Removed dependency on Mocha. (Dan Croak)
157   -* Required Shoulda >= 2.9.1. (Dan Croak)
158   -* Added password reset feature to clearance_features generator. (Eugene Bolshakov, Dan Croak)
159   -* Removed unnecessary session[:salt]. (Dan Croak)
160   -* [#41] Only store location for session[:return_to] for GET requests. (Dan Croak)
161   -* Audited "sign up" naming convention. "Register" had slipped in a few places. (Dan Croak)
162   -* 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)
163   -
164   -h2. 0.4.4 (2/2/2009)
165   -
166   -* Added a generator for Cucumber features. (Joe Ferris, Dan Croak)
167   -* Standarized naming for "Sign up," "Sign in," and "Sign out". (Dan Croak)
vendor/plugins/clearance/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/plugins/clearance/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/plugins/clearance/Rakefile
... ... @@ -1,76 +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(:all => ["generator:cleanup",
9   - "generator:generate"]) do |task|
10   - task.libs << "lib"
11   - task.libs << "test"
12   - task.pattern = "test/**/*_test.rb"
13   - task.verbose = false
14   - end
15   -
16   - Cucumber::Rake::Task.new(:features) do |t|
17   - t.cucumber_opts = "--format progress"
18   - t.feature_pattern = "test/rails_root/features/*.feature"
19   - end
20   -end
21   -
22   -generators = %w(clearance clearance_features)
23   -
24   -namespace :generator do
25   - desc "Cleans up the test app before running the generator"
26   - task :cleanup do
27   - generators.each do |generator|
28   - FileList["generators/#{generator}/templates/**/*.*"].each do |each|
29   - file = "test/rails_root/#{each.gsub("generators/#{generator}/templates/",'')}"
30   - File.delete(file) if File.exists?(file)
31   - end
32   - end
33   -
34   - FileList["test/rails_root/db/**/*"].each do |each|
35   - FileUtils.rm_rf(each)
36   - end
37   - FileUtils.rm_rf("test/rails_root/vendor/plugins/clearance")
38   - FileUtils.mkdir_p("test/rails_root/vendor/plugins")
39   - clearance_root = File.expand_path(File.dirname(__FILE__))
40   - system("ln -s #{clearance_root} test/rails_root/vendor/plugins/clearance")
41   - end
42   -
43   - desc "Run the generator on the tests"
44   - task :generate do
45   - generators.each do |generator|
46   - system "cd test/rails_root && ./script/generate #{generator} && rake db:migrate db:test:prepare"
47   - end
48   - end
49   -end
50   -
51   -desc "Run the test suite"
52   -task :default => ['test:all', 'test:features']
53   -
54   -gem_spec = Gem::Specification.new do |gem_spec|
55   - gem_spec.name = "clearance"
56   - gem_spec.version = "0.6.9"
57   - gem_spec.summary = "Rails authentication with email & password."
58   - gem_spec.email = "support@thoughtbot.com"
59   - gem_spec.homepage = "http://github.com/thoughtbot/clearance"
60   - gem_spec.description = "Rails authentication with email & password."
61   - gem_spec.authors = ["Dan Croak", "Mike Burns", "Jason Morrison",
62   - "Joe Ferris", "Eugene Bolshakov", "Nick Quaranto",
63   - "Josh Nichols", "Mike Breen", "Marcel Görner",
64   - "Bence Nagy", "Ben Mabey", "Eloy Duran",
65   - "Tim Pope", "Mihai Anca", "Mark Cornick",
66   - "Shay Arnett"]
67   - gem_spec.files = FileList["[A-Z]*", "{app,config,generators,lib,shoulda_macros,rails}/**/*"]
68   -end
69   -
70   -desc "Generate a gemspec file"
71   -task :gemspec do
72   - File.open("#{gem_spec.name}.gemspec", 'w') do |f|
73   - f.write gem_spec.to_yaml
74   - end
75   -end
76   -
vendor/plugins/clearance/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/plugins/clearance/app/controllers/clearance/confirmations_controller.rb
... ... @@ -1,52 +0,0 @@
1   -class Clearance::ConfirmationsController < ApplicationController
2   - unloadable
3   -
4   - before_filter :forbid_confirmed_user, :only => [:new, :create]
5   - before_filter :forbid_missing_token, :only => [:new, :create]
6   - before_filter :forbid_non_existent_user, :only => [:new, :create]
7   - filter_parameter_logging :token
8   -
9   - def new
10   - create
11   - end
12   -
13   - def create
14   - @user = ::User.find_by_id_and_token(params[:user_id], params[:token])
15   - @user.confirm_email!
16   -
17   - sign_in(@user)
18   - flash_success_after_create
19   - redirect_to(url_after_create)
20   - end
21   -
22   - private
23   -
24   - def forbid_confirmed_user
25   - user = ::User.find_by_id(params[:user_id])
26   - if user && user.email_confirmed?
27   - raise ActionController::Forbidden, "confirmed user"
28   - end
29   - end
30   -
31   - def forbid_missing_token
32   - if params[:token].blank?
33   - raise ActionController::Forbidden, "missing token"
34   - end
35   - end
36   -
37   - def forbid_non_existent_user
38   - unless ::User.find_by_id_and_token(params[:user_id], params[:token])
39   - raise ActionController::Forbidden, "non-existent user"
40   - end
41   - end
42   -
43   - def flash_success_after_create
44   - flash[:success] = translate(:confirmed_email,
45   - :scope => [:clearance, :controllers, :confirmations],
46   - :default => "Confirmed email and signed in.")
47   - end
48   -
49   - def url_after_create
50   - root_url
51   - end
52   -end
vendor/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/clearance.gemspec
... ... @@ -1,132 +0,0 @@
1   ---- !ruby/object:Gem::Specification
2   -name: clearance
3   -version: !ruby/object:Gem::Version
4   - version: 0.6.9
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-07-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   -- lib/clearance
94   -- lib/clearance/authentication.rb
95   -- lib/clearance/extensions
96   -- lib/clearance/extensions/errors.rb
97   -- lib/clearance/extensions/rescue.rb
98   -- lib/clearance/extensions/routes.rb
99   -- lib/clearance/user.rb
100   -- lib/clearance.rb
101   -- shoulda_macros/clearance.rb
102   -- rails/init.rb
103   -has_rdoc: true
104   -homepage: http://github.com/thoughtbot/clearance
105   -licenses: []
106   -
107   -post_install_message:
108   -rdoc_options: []
109   -
110   -require_paths:
111   -- lib
112   -required_ruby_version: !ruby/object:Gem::Requirement
113   - requirements:
114   - - - ">="
115   - - !ruby/object:Gem::Version
116   - version: "0"
117   - version:
118   -required_rubygems_version: !ruby/object:Gem::Requirement
119   - requirements:
120   - - - ">="
121   - - !ruby/object:Gem::Version
122   - version: "0"
123   - version:
124   -requirements: []
125   -
126   -rubyforge_project:
127   -rubygems_version: 1.3.4
128   -signing_key:
129   -specification_version: 3
130   -summary: Rails authentication with email & password.
131   -test_files: []
132   -
vendor/plugins/clearance/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/plugins/clearance/generators/clearance/USAGE
... ... @@ -1 +0,0 @@
1   -script/generate clearance
2 0 \ No newline at end of file
vendor/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/generators/clearance/templates/user.rb
... ... @@ -1,3 +0,0 @@
1   -class User < ActiveRecord::Base
2   - include Clearance::User
3   -end
vendor/plugins/clearance/generators/clearance_features/USAGE
... ... @@ -1 +0,0 @@
1   -script/generate clearance_features
vendor/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/generators/clearance_features/templates/features/sign_up.feature
... ... @@ -1,28 +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   -
vendor/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/lib/clearance/authentication.rb
... ... @@ -1,100 +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
9   - helper_method :signed_in?
10   -
11   - hide_action :current_user, :signed_in?
12   - end
13   - end
14   -
15   - module InstanceMethods
16   - def current_user
17   - @_current_user ||= (user_from_cookie || user_from_session)
18   - end
19   -
20   - def signed_in?
21   - ! current_user.nil?
22   - end
23   -
24   - protected
25   -
26   - def authenticate
27   - deny_access unless signed_in?
28   - end
29   -
30   - def user_from_session
31   - if session[:user_id]
32   - return nil unless user = ::User.find_by_id(session[:user_id])
33   - return user if user.email_confirmed?
34   - end
35   - end
36   -
37   - def user_from_cookie
38   - if token = cookies[:remember_token]
39   - return nil unless user = ::User.find_by_token(token)
40   - return user if user.remember?
41   - end
42   - end
43   -
44   - def sign_user_in(user)
45   - warn "[DEPRECATION] sign_user_in: unnecessary. use sign_in(user) instead."
46   - sign_in(user)
47   - end
48   -
49   - def sign_in(user)
50   - if user
51   - session[:user_id] = user.id
52   - end
53   - end
54   -
55   - def remember?
56   - params[:session] && params[:session][:remember_me] == "1"
57   - end
58   -
59   - def remember(user)
60   - user.remember_me!
61   - cookies[:remember_token] = { :value => user.token,
62   - :expires => user.token_expires_at }
63   - end
64   -
65   - def forget(user)
66   - user.forget_me! if user
67   - cookies.delete(:remember_token)
68   - reset_session
69   - end
70   -
71   - def redirect_back_or(default)
72   - redirect_to(return_to || default)
73   - clear_return_to
74   - end
75   -
76   - def return_to
77   - session[:return_to] || params[:return_to]
78   - end
79   -
80   - def clear_return_to
81   - session[:return_to] = nil
82   - end
83   -
84   - def redirect_to_root
85   - redirect_to(root_url)
86   - end
87   -
88   - def store_location
89   - session[:return_to] = request.request_uri if request.get?
90   - end
91   -
92   - def deny_access(flash_message = nil, opts = {})
93   - store_location
94   - flash[:failure] = flash_message if flash_message
95   - redirect_to(new_session_url)
96   - end
97   - end
98   -
99   - end
100   -end
vendor/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/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/plugins/clearance/rails/init.rb
... ... @@ -1 +0,0 @@
1   -require 'clearance'
2 0 \ No newline at end of file
vendor/plugins/clearance/shoulda_macros/clearance.rb
... ... @@ -1,262 +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   - # VALIDATIONS
136   -
137   - def should_validate_confirmation_of(attribute, opts = {})
138   - warn "[DEPRECATION] should_validate_confirmation_of: not meant to be public, no longer used internally"
139   - raise ArgumentError if opts[:factory].nil?
140   -
141   - context "on save" do
142   - should_validate_confirmation_is_not_blank opts[:factory], attribute
143   - should_validate_confirmation_is_not_bad opts[:factory], attribute
144   - end
145   - end
146   -
147   - def should_validate_confirmation_is_not_blank(factory, attribute, opts = {})
148   - warn "[DEPRECATION] should_validate_confirmation_is_not_blank: not meant to be public, no longer used internally"
149   - should "validate #{attribute}_confirmation is not blank" do
150   - model = Factory.build(factory, blank_confirmation_options(attribute))
151   - model.save
152   - assert_confirmation_error(model, attribute,
153   - "#{attribute}_confirmation cannot be blank")
154   - end
155   - end
156   -
157   - def should_validate_confirmation_is_not_bad(factory, attribute, opts = {})
158   - warn "[DEPRECATION] should_validate_confirmation_is_not_bad: not meant to be public, no longer used internally"
159   - should "validate #{attribute}_confirmation is different than #{attribute}" do
160   - model = Factory.build(factory, bad_confirmation_options(attribute))
161   - model.save
162   - assert_confirmation_error(model, attribute,
163   - "#{attribute}_confirmation cannot be different than #{attribute}")
164   - end
165   - end
166   -
167   - # FORMS
168   -
169   - def should_display_a_password_update_form
170   - warn "[DEPRECATION] should_display_a_password_update_form: not meant to be public, no longer used internally"
171   - should "have a form for the user's token, password, and password confirm" do
172   - update_path = ERB::Util.h(
173   - user_password_path(@user, :token => @user.token)
174   - )
175   -
176   - assert_select 'form[action=?]', update_path do
177   - assert_select 'input[name=_method][value=?]', 'put'
178   - assert_select 'input[name=?]', 'user[password]'
179   - assert_select 'input[name=?]', 'user[password_confirmation]'
180   - end
181   - end
182   - end
183   -
184   - def should_display_a_sign_up_form
185   - warn "[DEPRECATION] should_display_a_sign_up_form: not meant to be public, no longer used internally"
186   - should "display a form to sign up" do
187   - assert_select "form[action=#{users_path}][method=post]",
188   - true, "There must be a form to sign up" do
189   - assert_select "input[type=text][name=?]",
190   - "user[email]", true, "There must be an email field"
191   - assert_select "input[type=password][name=?]",
192   - "user[password]", true, "There must be a password field"
193   - assert_select "input[type=password][name=?]",
194   - "user[password_confirmation]", true, "There must be a password confirmation field"
195   - assert_select "input[type=submit]", true,
196   - "There must be a submit button"
197   - end
198   - end
199   - end
200   -
201   - def should_display_a_sign_in_form
202   - warn "[DEPRECATION] should_display_a_sign_in_form: not meant to be public, no longer used internally"
203   - should 'display a "sign in" form' do
204   - assert_select "form[action=#{session_path}][method=post]",
205   - true, "There must be a form to sign in" do
206   - assert_select "input[type=text][name=?]",
207   - "session[email]", true, "There must be an email field"
208   - assert_select "input[type=password][name=?]",
209   - "session[password]", true, "There must be a password field"
210   - assert_select "input[type=checkbox][name=?]",
211   - "session[remember_me]", true, "There must be a 'remember me' check box"
212   - assert_select "input[type=submit]", true,
213   - "There must be a submit button"
214   - end
215   - end
216   - end
217   - end
218   -end
219   -
220   -module Clearance
221   - module Shoulda
222   - module Helpers
223   - def sign_in_as(user)
224   - @controller.class_eval { attr_accessor :current_user }
225   - @controller.current_user = user
226   - return user
227   - end
228   -
229   - def sign_in
230   - sign_in_as Factory(:email_confirmed_user)
231   - end
232   -
233   - def sign_out
234   - @controller.class_eval { attr_accessor :current_user }
235   - @controller.current_user = nil
236   - end
237   -
238   - def blank_confirmation_options(attribute)
239   - warn "[DEPRECATION] blank_confirmation_options: not meant to be public, no longer used internally"
240   - opts = { attribute => attribute.to_s }
241   - opts.merge("#{attribute}_confirmation".to_sym => "")
242   - end
243   -
244   - def bad_confirmation_options(attribute)
245   - warn "[DEPRECATION] bad_confirmation_options: not meant to be public, no longer used internally"
246   - opts = { attribute => attribute.to_s }
247   - opts.merge("#{attribute}_confirmation".to_sym => "not_#{attribute}")
248   - end
249   -
250   - def assert_confirmation_error(model, attribute, message = "confirmation error")
251   - warn "[DEPRECATION] assert_confirmation_error: not meant to be public, no longer used internally"
252   - assert model.errors.on(attribute).include?("doesn't match confirmation"),
253   - message
254   - end
255   - end
256   - end
257   -end
258   -
259   -class Test::Unit::TestCase
260   - include Clearance::Shoulda::Helpers
261   -end
262   -Test::Unit::TestCase.extend(Clearance::Shoulda)
vendor/plugins/clearance/test/controllers/confirmations_controller_test.rb
... ... @@ -1,64 +0,0 @@
1   -require 'test_helper'
2   -
3   -class ConfirmationsControllerTest < ActionController::TestCase
4   -
5   - tests Clearance::ConfirmationsController
6   -
7   - should_filter_params :token
8   -
9   - context "a user whose email has not been confirmed" do
10   - setup { @user = Factory(:user) }
11   -
12   - should "have a token" do
13   - assert_not_nil @user.token
14   - assert_not_equal "", @user.token
15   - end
16   -
17   - context "on GET to #new with correct id and token" do
18   - setup do
19   - get :new, :user_id => @user.to_param, :token => @user.token
20   - end
21   -
22   - should_set_the_flash_to /confirmed email/i
23   - should_set_the_flash_to /signed in/i
24   - should_be_signed_in_and_email_confirmed_as { @user }
25   - should_redirect_to_url_after_create
26   - end
27   -
28   - context "with an incorrect token" do
29   - setup do
30   - @bad_token = "bad token"
31   - assert_not_equal @bad_token, @user.token
32   - end
33   -
34   - should_forbid "on GET to #new with incorrect token" do
35   - get :new, :user_id => @user.to_param, :token => @bad_token
36   - end
37   - end
38   -
39   - should_forbid "on GET to #new with blank token" do
40   - get :new, :user_id => @user.to_param, :token => ""
41   - end
42   -
43   - should_forbid "on GET to #new with no token" do
44   - get :new, :user_id => @user.to_param
45   - end
46   - end
47   -
48   - context "a user with email confirmed" do
49   - setup { @user = Factory(:email_confirmed_user) }
50   -
51   - should_forbid "on GET to #new with correct id" do
52   - get :new, :user_id => @user.to_param
53   - end
54   - end
55   -
56   - context "no users" do
57   - setup { assert_equal 0, ::User.count }
58   -
59   - should_forbid "on GET to #new with nonexistent id and token" do
60   - get :new, :user_id => '123', :token => '123'
61   - end
62   - end
63   -
64   -end
vendor/plugins/clearance/test/controllers/passwords_controller_test.rb
... ... @@ -1,175 +0,0 @@
1   -require 'test_helper'
2   -
3   -class PasswordsControllerTest < ActionController::TestCase
4   -
5   - tests Clearance::PasswordsController
6   -
7   - should_route :get, '/users/1/password/edit',
8   - :controller => 'clearance/passwords', :action => 'edit', :user_id => '1'
9   -
10   - context "a signed up user" do
11   - setup do
12   - @user = Factory(:user)
13   - end
14   -
15   - context "on GET to #new" do
16   - setup { get :new, :user_id => @user.to_param }
17   -
18   - should_respond_with :success
19   - should_render_template "new"
20   - end
21   -
22   - context "on POST to #create" do
23   - context "with correct email address" do
24   - setup do
25   - ActionMailer::Base.deliveries.clear
26   - post :create, :password => { :email => @user.email }
27   - end
28   -
29   - should "generate a token for the change your password email" do
30   - assert_not_nil @user.reload.token
31   - end
32   -
33   - should "send the change your password email" do
34   - assert_sent_email do |email|
35   - email.subject =~ /change your password/i
36   - end
37   - end
38   -
39   - should_set_the_flash_to /password/i
40   - should_redirect_to_url_after_create
41   - end
42   -
43   - context "with incorrect email address" do
44   - setup do
45   - email = "user1@example.com"
46   - assert ! ::User.exists?(['email = ?', email])
47   - ActionMailer::Base.deliveries.clear
48   - assert_equal @user.token, @user.reload.token
49   -
50   - post :create, :password => { :email => email }
51   - end
52   -
53   - should "not generate a token for the change your password email" do
54   - assert_equal @user.token, @user.reload.token
55   - end
56   -
57   - should "not send a password reminder email" do
58   - assert ActionMailer::Base.deliveries.empty?
59   - end
60   -
61   - should "set the failure flash to Unknown email" do
62   - assert_match /unknown email/i, flash.now[:failure]
63   - end
64   -
65   - should_render_template :new
66   - end
67   - end
68   - end
69   -
70   - context "a signed up user and forgotten password" do
71   - setup do
72   - @user = Factory(:user)
73   - @user.forgot_password!
74   - end
75   -
76   - context "on GET to #edit with correct id and token" do
77   - setup do
78   - get :edit, :user_id => @user.to_param, :token => @user.token
79   - end
80   -
81   - should "find the user" do
82   - assert_equal @user, assigns(:user)
83   - end
84   -
85   - should_respond_with :success
86   - should_render_template "edit"
87   - should_display_a_password_update_form
88   - end
89   -
90   - should_forbid "on GET to #edit with correct id but blank token" do
91   - get :edit, :user_id => @user.to_param, :token => ""
92   - end
93   -
94   - should_forbid "on GET to #edit with correct id but no token" do
95   - get :edit, :user_id => @user.to_param
96   - end
97   -
98   - context "on PUT to #update with matching password and password confirmation" do
99   - setup do
100   - new_password = "new_password"
101   - @encrypted_new_password = @user.encrypt(new_password)
102   - assert_not_equal @encrypted_new_password, @user.encrypted_password
103   -
104   - put(:update,
105   - :user_id => @user,
106   - :token => @user.token,
107   - :user => {
108   - :password => new_password,
109   - :password_confirmation => new_password
110   - })
111   - @user.reload
112   - end
113   -
114   - should "update password" do
115   - assert_equal @encrypted_new_password, @user.encrypted_password
116   - end
117   -
118   - should "clear token" do
119   - assert_nil @user.token
120   - end
121   -
122   - should_be_signed_in_as { @user }
123   - should_set_the_flash_to(/signed in/i)
124   - should_redirect_to_url_after_update
125   - end
126   -
127   - context "on PUT to #update with password but blank password confirmation" do
128   - setup do
129   - new_password = "new_password"
130   - @encrypted_new_password = @user.encrypt(new_password)
131   -
132   - put(:update,
133   - :user_id => @user.to_param,
134   - :token => @user.token,
135   - :user => {
136   - :password => new_password,
137   - :password_confirmation => ''
138   - })
139   - @user.reload
140   - end
141   -
142   - should "not update password" do
143   - assert_not_equal @encrypted_new_password, @user.encrypted_password
144   - end
145   -
146   - should "not clear token" do
147   - assert_not_nil @user.token
148   - end
149   -
150   - should_not_be_signed_in
151   - should_not_set_the_flash
152   - should_respond_with :success
153   - should_render_template :edit
154   -
155   - should_display_a_password_update_form
156   - end
157   -
158   - should_forbid "on PUT to #update with id but no token" do
159   - put :update, :user_id => @user.to_param, :token => ""
160   - end
161   - end
162   -
163   - context "given two users and user one signs in" do
164   - setup do
165   - @user_one = Factory(:user)
166   - @user_two = Factory(:user)
167   - sign_in_as @user_one
168   - end
169   -
170   - should_forbid "when user one tries to change user two's password on GET with no token" do
171   - get :edit, :user_id => @user_two.to_param
172   - end
173   - end
174   -
175   -end
vendor/plugins/clearance/test/controllers/sessions_controller_test.rb
... ... @@ -1,178 +0,0 @@
1   -require 'test_helper'
2   -
3   -class SessionsControllerTest < ActionController::TestCase
4   -
5   - tests Clearance::SessionsController
6   -
7   - should_filter_params :password
8   -
9   - context "on GET to /sessions/new" do
10   - setup { get :new }
11   -
12   - should_respond_with :success
13   - should_render_template :new
14   - should_not_set_the_flash
15   - should_display_a_sign_in_form
16   - end
17   -
18   - context "on POST to #create with unconfirmed credentials" do
19   - setup do
20   - @user = Factory(:user)
21   - ActionMailer::Base.deliveries.clear
22   - post :create, :session => {
23   - :email => @user.email,
24   - :password => @user.password }
25   - end
26   -
27   - should_deny_access(:flash => /User has not confirmed email. Confirmation email will be resent./i)
28   -
29   - should "send the confirmation email" do
30   - assert_not_nil email = ActionMailer::Base.deliveries[0]
31   - assert_match /account confirmation/i, email.subject
32   - end
33   - end
34   -
35   - context "on POST to #create with good credentials" do
36   - setup do
37   - @user = Factory(:email_confirmed_user)
38   - post :create, :session => {
39   - :email => @user.email,
40   - :password => @user.password }
41   - end
42   -
43   - should_set_the_flash_to /signed in/i
44   - should_redirect_to_url_after_create
45   - should_be_signed_in_as { @user }
46   - end
47   -
48   - context "on POST to #create with good credentials and remember me" do
49   - setup do
50   - @user = Factory(:email_confirmed_user)
51   - post :create, :session => {
52   - :email => @user.email,
53   - :password => @user.password,
54   - :remember_me => '1' }
55   - end
56   -
57   - should_set_the_flash_to /signed in/i
58   - should_redirect_to_url_after_create
59   - should_be_signed_in_as { @user }
60   -
61   - should 'set the cookie' do
62   - assert ! cookies['remember_token'].empty?
63   - end
64   -
65   - should 'set the token in users table' do
66   - assert_not_nil @user.reload.token
67   - assert_not_nil @user.reload.token_expires_at
68   - end
69   - end
70   -
71   - context "on POST to #create with good credentials and a session return url" do
72   - setup do
73   - @user = Factory(:email_confirmed_user)
74   - @return_url = '/url_in_the_session'
75   - @request.session[:return_to] = @return_url
76   - post :create, :session => {
77   - :email => @user.email,
78   - :password => @user.password }
79   - end
80   -
81   - should_redirect_to("the return URL") { @return_url }
82   - end
83   -
84   - context "on POST to #create with good credentials and a request return url" do
85   - setup do
86   - @user = Factory(:email_confirmed_user)
87   - @return_url = '/url_in_the_request'
88   - post :create, :session => {
89   - :email => @user.email,
90   - :password => @user.password },
91   - :return_to => @return_url
92   - end
93   -
94   - should_redirect_to("the return URL") { @return_url }
95   - end
96   -
97   - context "on POST to #create with good credentials and a session return url and request return url" do
98   - setup do
99   - @user = Factory(:email_confirmed_user)
100   - @return_url = '/url_in_the_session'
101   - @request.session[:return_to] = @return_url
102   - post :create, :session => {
103   - :email => @user.email,
104   - :password => @user.password },
105   - :return_to => '/url_in_the_request'
106   - end
107   -
108   - should_redirect_to("the return URL") { @return_url }
109   - end
110   -
111   - context "on POST to #create with bad credentials" do
112   - setup do
113   - post :create, :session => {
114   - :email => 'bad.email@example.com',
115   - :password => "bad value" }
116   - end
117   -
118   - should_set_the_flash_to /bad/i
119   - should_respond_with :unauthorized
120   - should_render_template :new
121   - should_not_be_signed_in
122   - end
123   -
124   - context "on POST to #create with bad credentials and remember me" do
125   - setup do
126   - post :create, :session => {
127   - :email => 'bad.email@example.com',
128   - :password => "bad value",
129   - :remember_me => '1' }
130   - end
131   -
132   - should_set_the_flash_to /bad/i
133   - should_respond_with :unauthorized
134   - should_render_template :new
135   - should_not_be_signed_in
136   -
137   - should 'not create the cookie' do
138   - assert_nil cookies['remember_token']
139   - end
140   - end
141   -
142   - context "on DELETE to #destroy given a signed out user" do
143   - setup do
144   - sign_out
145   - delete :destroy
146   - end
147   - should_set_the_flash_to(/signed out/i)
148   - should_redirect_to_url_after_destroy
149   - end
150   -
151   - context "on DELETE to #destroy without a cookie" do
152   - setup do
153   - sign_in
154   - delete :destroy
155   - end
156   - should_set_the_flash_to(/signed out/i)
157   - should_redirect_to_url_after_destroy
158   - end
159   -
160   - context "on DELETE to #destroy with a cookie" do
161   - setup do
162   - @user = Factory(:email_confirmed_user)
163   - cookies['remember_token'] = CGI::Cookie.new('token', 'value')
164   - sign_in_as @user
165   - delete :destroy
166   - end
167   -
168   - should "delete the cookie token" do
169   - assert_nil cookies['remember_token']
170   - end
171   -
172   - should "delete the database token" do
173   - assert_nil @user.reload.token
174   - assert_nil @user.reload.token_expires_at
175   - end
176   - end
177   -
178   -end