Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Upgrade dependencies

* Support Rails 3.0.15, 3.1.6, 3.2.6.
* Apply style guidelines to test suite.
* Be more strict about development dependencies.
  • Loading branch information...
commit 2900d731ef08c35e2844fd82c0b17644fffc428a 1 parent 7184e7d
Dan Croak croaky authored
Showing with 643 additions and 699 deletions.
  1. +2 −2 Appraisals
  2. +1 −1  Gemfile
  3. +78 −81 Gemfile.lock
  4. +11 −12 README.md
  5. +29 −31 clearance.gemspec
  6. +0 −17 features/support/env.rb
  7. +1 −1  gemfiles/{3.0.12.gemfile → 3.0.15.gemfile}
  8. +71 −74 gemfiles/{3.0.12.gemfile.lock → 3.0.15.gemfile.lock}
  9. +1 −1  gemfiles/{3.2.3.gemfile → 3.1.6.gemfile}
  10. +75 −78 gemfiles/{3.1.4.gemfile.lock → 3.1.6.gemfile.lock}
  11. +1 −1  gemfiles/{3.1.4.gemfile → 3.2.6.gemfile}
  12. +76 −79 gemfiles/{3.2.3.gemfile.lock → 3.2.6.gemfile.lock}
  13. +1 −1  lib/clearance/user.rb
  14. +9 −10 spec/clearance/constraints/signed_in_spec.rb
  15. +2 −2 spec/clearance/constraints/signed_out_spec.rb
  16. +8 −7 spec/clearance/rack_session_spec.rb
  17. +26 −25 spec/clearance/session_spec.rb
  18. +11 −10 spec/controllers/denies_controller_spec.rb
  19. +5 −5 spec/controllers/flashes_controller_spec.rb
  20. +9 −9 spec/controllers/forgeries_controller_spec.rb
  21. +39 −51 spec/controllers/passwords_controller_spec.rb
  22. +26 −33 spec/controllers/sessions_controller_spec.rb
  23. +16 −14 spec/controllers/users_controller_spec.rb
  24. +1 −3 spec/factories.rb
  25. +4 −4 spec/mailers/clearance_mailer_spec.rb
  26. +18 −19 spec/models/bcrypt_migration_from_sha1_spec.rb
  27. +9 −10 spec/models/bcrypt_spec.rb
  28. +9 −11 spec/models/blowfish_spec.rb
  29. +7 −8 spec/models/sha1_spec.rb
  30. +60 −57 spec/models/user_spec.rb
  31. +5 −6 spec/spec_helper.rb
  32. +0 −4 spec/support/clearance.rb
  33. +25 −27 spec/support/cookies.rb
  34. +7 −5 spec/support/request_with_remember_token.rb
4 Appraisals
View
@@ -1,5 +1,5 @@
-['3.0.12', '3.1.4', '3.2.3'].each do |rails_version|
+['3.0.15', '3.1.6', '3.2.6'].each do |rails_version|
appraise "#{rails_version}" do
- gem "rails", rails_version
+ gem 'rails', rails_version
end
end
2  Gemfile
View
@@ -1,3 +1,3 @@
-source "http://rubygems.org"
+source 'http://rubygems.org'
gemspec
159 Gemfile.lock
View
@@ -3,40 +3,40 @@ PATH
specs:
clearance (0.16.2)
bcrypt-ruby
- diesel (~> 0.1.5)
+ diesel (= 0.1.5)
rails (>= 3.0)
GEM
remote: http://rubygems.org/
specs:
- actionmailer (3.2.1)
- actionpack (= 3.2.1)
- mail (~> 2.4.0)
- actionpack (3.2.1)
- activemodel (= 3.2.1)
- activesupport (= 3.2.1)
+ actionmailer (3.2.6)
+ actionpack (= 3.2.6)
+ mail (~> 2.4.4)
+ actionpack (3.2.6)
+ activemodel (= 3.2.6)
+ activesupport (= 3.2.6)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
- rack-cache (~> 1.1)
+ rack-cache (~> 1.2)
rack-test (~> 0.6.1)
- sprockets (~> 2.1.2)
- activemodel (3.2.1)
- activesupport (= 3.2.1)
+ sprockets (~> 2.1.3)
+ activemodel (3.2.6)
+ activesupport (= 3.2.6)
builder (~> 3.0.0)
- activerecord (3.2.1)
- activemodel (= 3.2.1)
- activesupport (= 3.2.1)
- arel (~> 3.0.0)
+ activerecord (3.2.6)
+ activemodel (= 3.2.6)
+ activesupport (= 3.2.6)
+ arel (~> 3.0.2)
tzinfo (~> 0.3.29)
- activeresource (3.2.1)
- activemodel (= 3.2.1)
- activesupport (= 3.2.1)
- activesupport (3.2.1)
+ activeresource (3.2.6)
+ activemodel (= 3.2.6)
+ activesupport (= 3.2.6)
+ activesupport (3.2.6)
i18n (~> 0.6)
multi_json (~> 1.0)
- addressable (2.2.6)
+ addressable (2.3.1)
appraisal (0.4.1)
bundler
rake
@@ -57,47 +57,46 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
- childprocess (0.3.0)
- ffi (~> 1.0.6)
- cucumber (1.1.4)
+ childprocess (0.3.4)
+ ffi (~> 1.0, >= 1.0.6)
+ cucumber (1.2.1)
builder (>= 2.1.2)
- diff-lcs (>= 1.1.2)
- gherkin (~> 2.7.1)
+ diff-lcs (>= 1.1.3)
+ gherkin (~> 2.11.0)
json (>= 1.4.6)
- term-ansicolor (>= 1.0.6)
cucumber-rails (1.1.1)
capybara (>= 1.1.1)
cucumber (>= 1.1.0)
nokogiri (>= 1.5.0)
- database_cleaner (0.7.1)
+ database_cleaner (0.8.0)
diesel (0.1.5)
railties
diff-lcs (1.1.3)
erubis (2.7.0)
- factory_girl (3.1.1)
+ factory_girl (3.5.0)
activesupport (>= 3.0.0)
- factory_girl_rails (3.1.0)
- factory_girl (~> 3.1.0)
+ factory_girl_rails (3.5.0)
+ factory_girl (~> 3.5.0)
railties (>= 3.0.0)
- ffi (1.0.11)
- gherkin (2.7.6)
+ ffi (1.1.0)
+ gherkin (2.11.1)
json (>= 1.4.6)
hike (1.2.1)
i18n (0.6.0)
- journey (1.0.3)
- json (1.6.6)
- launchy (2.0.5)
- addressable (~> 2.2.6)
+ journey (1.0.4)
+ json (1.7.3)
+ libwebsocket (0.1.4)
+ addressable
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
- mime-types (1.17.2)
+ mime-types (1.19)
mocha (0.10.5)
metaclass (~> 0.0.1)
- multi_json (1.0.4)
- nokogiri (1.5.0)
+ multi_json (1.3.6)
+ nokogiri (1.5.5)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
@@ -106,52 +105,51 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
- rails (3.2.1)
- actionmailer (= 3.2.1)
- actionpack (= 3.2.1)
- activerecord (= 3.2.1)
- activeresource (= 3.2.1)
- activesupport (= 3.2.1)
+ rails (3.2.6)
+ actionmailer (= 3.2.6)
+ actionpack (= 3.2.6)
+ activerecord (= 3.2.6)
+ activeresource (= 3.2.6)
+ activesupport (= 3.2.6)
bundler (~> 1.0)
- railties (= 3.2.1)
- railties (3.2.1)
- actionpack (= 3.2.1)
- activesupport (= 3.2.1)
+ railties (= 3.2.6)
+ railties (3.2.6)
+ actionpack (= 3.2.6)
+ activesupport (= 3.2.6)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
- thor (~> 0.14.6)
+ thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
- rspec (2.9.0)
- rspec-core (~> 2.9.0)
- rspec-expectations (~> 2.9.0)
- rspec-mocks (~> 2.9.0)
- rspec-core (2.9.0)
- rspec-expectations (2.9.1)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.1)
+ rspec-expectations (2.11.1)
diff-lcs (~> 1.1.3)
- rspec-mocks (2.9.0)
- rspec-rails (2.9.0)
+ rspec-mocks (2.11.1)
+ rspec-rails (2.11.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
- rspec (~> 2.9.0)
- rubyzip (0.9.5)
- selenium-webdriver (2.18.0)
+ rspec (~> 2.11.0)
+ rubyzip (0.9.9)
+ selenium-webdriver (2.25.0)
childprocess (>= 0.2.5)
- ffi (~> 1.0.9)
- multi_json (~> 1.0.4)
+ libwebsocket (~> 0.1.3)
+ multi_json (~> 1.0)
rubyzip
- shoulda-matchers (1.1.0)
+ shoulda-matchers (1.2.0)
activesupport (>= 3.0.0)
- sprockets (2.1.2)
+ sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.5)
- term-ansicolor (1.0.7)
- thor (0.14.6)
+ sqlite3 (1.3.6)
+ thor (0.15.4)
tilt (1.3.3)
timecop (0.3.5)
treetop (1.4.10)
@@ -165,17 +163,16 @@ PLATFORMS
ruby
DEPENDENCIES
- appraisal (~> 0.4.1)
- aruba (~> 0.4.11)
- bourne (~> 1.1.2)
- bundler (~> 1.1)
- capybara (~> 1.1.2)
+ appraisal (= 0.4.1)
+ aruba (= 0.4.11)
+ bourne (= 1.1.2)
+ bundler (= 1.1.3)
+ capybara (= 1.1.2)
clearance!
- cucumber-rails (~> 1.1.1)
- database_cleaner
- factory_girl_rails (~> 3.1.0)
- launchy
- rspec-rails (~> 2.9.0)
- shoulda-matchers (~> 1.1.0)
- sqlite3
- timecop
+ cucumber-rails (= 1.1.1)
+ database_cleaner (= 0.8.0)
+ factory_girl_rails (= 3.5.0)
+ rspec-rails (= 2.11.0)
+ shoulda-matchers (= 1.2.0)
+ sqlite3 (= 1.3.6)
+ timecop (= 0.3.5)
23 README.md
View
@@ -179,14 +179,14 @@ for the default behavior.
To override a view, create your own:
- app/views/clearance_mailer/change_password.html.erb
- app/views/passwords/create.html.erb
- app/views/passwords/edit.html.erb
- app/views/passwords/new.html.erb
- app/views/sessions/_form.html.erb
- app/views/sessions/new.html.erb
- app/views/users/_form.html.erb
- app/views/users/new.html.erb
+ app/views/clearance_mailer/change_password.html.erb
+ app/views/passwords/create.html.erb
+ app/views/passwords/edit.html.erb
+ app/views/passwords/new.html.erb
+ app/views/sessions/_form.html.erb
+ app/views/sessions/new.html.erb
+ app/views/users/_form.html.erb
+ app/views/users/new.html.erb
There is a shortcut to copy all Clearance views into your app:
@@ -350,13 +350,12 @@ Credits
![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
-Clearance is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community)
-
+Clearance is maintained by [thoughtbot, inc](http://thoughtbot.com/community).
Thank you to all [the contributors](https://github.com/thoughtbot/clearance/contributors)!
-The names and logos for thoughtbot are trademarks of thoughtbot, inc.
-
License
-------
Clearance is copyright © 2009-2012 thoughtbot. It is free software, and may be redistributed under the terms specified in the LICENSE file.
+
+The names and logos for thoughtbot are trademarks of thoughtbot, inc.
60 clearance.gemspec
View
@@ -3,37 +3,35 @@ require 'clearance/version'
require 'date'
Gem::Specification.new do |s|
- s.name = %q{clearance}
- s.version = Clearance::VERSION
- s.email = %q{support@thoughtbot.com}
- s.homepage = %q{http://github.com/thoughtbot/clearance}
-
- s.authors = ["Dan Croak", "Mike Burns", "Jason Morrison", "Joe Ferris", "Eugene Bolshakov", "Nick Quaranto", "Josh Nichols", "Mike Breen", "Jon Yurek", "Chad Pytel"]
- s.date = Date.today.to_s
- s.summary = %q{Rails authentication & authorization with email & password.}
+ s.add_dependency 'bcrypt-ruby'
+ s.add_dependency 'diesel', '0.1.5'
+ s.add_dependency 'rails', '>= 3.0'
+ s.add_development_dependency 'appraisal', '0.4.1'
+ s.add_development_dependency 'aruba', '0.4.11'
+ s.add_development_dependency 'bourne', '1.1.2'
+ s.add_development_dependency 'bundler', '1.1.3'
+ s.add_development_dependency 'capybara', '1.1.2'
+ s.add_development_dependency 'cucumber-rails', '1.1.1'
+ s.add_development_dependency 'database_cleaner', '0.8.0'
+ s.add_development_dependency 'factory_girl_rails', '3.5.0'
+ s.add_development_dependency 'rspec-rails', '2.11.0'
+ s.add_development_dependency 'shoulda-matchers', '1.2.0'
+ s.add_development_dependency 'sqlite3', '1.3.6'
+ s.add_development_dependency 'timecop', '0.3.5'
+ s.authors = [
+ 'Dan Croak', 'Mike Burns', 'Jason Morrison', 'Joe Ferris', 'Eugene Bolshakov',
+ 'Nick Quaranto', 'Josh Nichols', 'Mike Breen', 'Jon Yurek', 'Chad Pytel'
+ ]
+ s.date = Date.today.to_s
s.description = %q{Rails authentication & authorization with email & password.}
+ s.email = %q{support@thoughtbot.com}
s.extra_rdoc_files = %w(LICENSE README.md)
- s.files = `git ls-files`.split("\n")
- s.test_files = `git ls-files -- {test,features}/*`.split("\n")
-
- s.rdoc_options = ["--charset=UTF-8"]
- s.require_paths = ["lib"]
-
- s.add_dependency('rails', '>= 3.0')
- s.add_dependency('diesel', '~> 0.1.5')
- s.add_dependency('bcrypt-ruby')
-
- s.add_development_dependency('bundler', '~> 1.1')
- s.add_development_dependency('appraisal', '~> 0.4.1')
- s.add_development_dependency('cucumber-rails', '~> 1.1.1')
- s.add_development_dependency('rspec-rails', '~> 2.9.0')
- s.add_development_dependency('sqlite3')
- s.add_development_dependency('bourne', '~> 1.1.2')
- s.add_development_dependency('timecop')
- s.add_development_dependency('capybara', '~> 1.1.2')
- s.add_development_dependency('factory_girl_rails', '~> 3.1.0')
- s.add_development_dependency('shoulda-matchers', '~> 1.1.0')
- s.add_development_dependency('database_cleaner')
- s.add_development_dependency('launchy')
- s.add_development_dependency('aruba', '~> 0.4.11')
+ s.files = `git ls-files`.split('\n')
+ s.homepage = %q{http://github.com/thoughtbot/clearance}
+ s.name = %q{clearance}
+ s.rdoc_options = ['--charset=UTF-8']
+ s.require_paths = ['lib']
+ s.summary = %q{Rails authentication & authorization with email & password.}
+ s.test_files = `git ls-files -- {features,spec}/*`.split('\n')
+ s.version = Clearance::VERSION
end
17 features/support/env.rb
View
@@ -29,25 +29,8 @@
Capybara.default_selector = :css
Capybara.save_and_open_page_path = 'tmp'
-# By default, any exception happening in your Rails application will bubble up
-# to Cucumber so that your scenario will fail. This is a different from how
-# your application behaves in the production environment, where an error page will
-# be rendered instead.
-#
-# Sometimes we want to override this default behaviour and allow Rails to rescue
-# exceptions and display an error page (just like when the app is running in production).
-# Typical scenarios where you want to do this is when you test your error pages.
-# There are two ways to allow Rails to rescue exceptions:
-#
-# 1) Tag your scenario (or feature) with @allow-rescue
-#
-# 2) Set the value below to true. Beware that doing this globally is not
-# recommended as it will mask a lot of errors for you!
-#
ActionController::Base.allow_rescue = false
-# Remove/comment out the lines below if your app doesn't have a database.
-# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
begin
DatabaseCleaner.strategy = :transaction
rescue NameError
2  gemfiles/3.0.12.gemfile → gemfiles/3.0.15.gemfile
View
@@ -2,6 +2,6 @@
source "http://rubygems.org"
-gem "rails", "3.0.12"
+gem "rails", "3.0.15"
gemspec :path=>"../"
145 gemfiles/3.0.12.gemfile.lock → gemfiles/3.0.15.gemfile.lock
View
@@ -3,19 +3,19 @@ PATH
specs:
clearance (0.16.2)
bcrypt-ruby
- diesel (~> 0.1.5)
+ diesel (= 0.1.5)
rails (>= 3.0)
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
- actionmailer (3.0.12)
- actionpack (= 3.0.12)
+ actionmailer (3.0.15)
+ actionpack (= 3.0.15)
mail (~> 2.2.19)
- actionpack (3.0.12)
- activemodel (= 3.0.12)
- activesupport (= 3.0.12)
+ actionpack (3.0.15)
+ activemodel (= 3.0.15)
+ activesupport (= 3.0.15)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
@@ -23,20 +23,20 @@ GEM
rack-mount (~> 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
- activemodel (3.0.12)
- activesupport (= 3.0.12)
+ activemodel (3.0.15)
+ activesupport (= 3.0.15)
builder (~> 2.1.2)
i18n (~> 0.5.0)
- activerecord (3.0.12)
- activemodel (= 3.0.12)
- activesupport (= 3.0.12)
+ activerecord (3.0.15)
+ activemodel (= 3.0.15)
+ activesupport (= 3.0.15)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
- activeresource (3.0.12)
- activemodel (= 3.0.12)
- activesupport (= 3.0.12)
- activesupport (3.0.12)
- addressable (2.2.7)
+ activeresource (3.0.15)
+ activemodel (= 3.0.15)
+ activesupport (= 3.0.15)
+ activesupport (3.0.15)
+ addressable (2.3.1)
appraisal (0.4.1)
bundler
rake
@@ -57,99 +57,97 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
- childprocess (0.3.1)
- ffi (~> 1.0.6)
- cucumber (1.1.9)
+ childprocess (0.3.4)
+ ffi (~> 1.0, >= 1.0.6)
+ cucumber (1.2.1)
builder (>= 2.1.2)
- diff-lcs (>= 1.1.2)
- gherkin (~> 2.9.0)
+ diff-lcs (>= 1.1.3)
+ gherkin (~> 2.11.0)
json (>= 1.4.6)
- term-ansicolor (>= 1.0.6)
cucumber-rails (1.1.1)
capybara (>= 1.1.1)
cucumber (>= 1.1.0)
nokogiri (>= 1.5.0)
- database_cleaner (0.7.2)
+ database_cleaner (0.8.0)
diesel (0.1.5)
railties
diff-lcs (1.1.3)
erubis (2.6.6)
abstract (>= 1.0.0)
- factory_girl (3.1.1)
+ factory_girl (3.5.0)
activesupport (>= 3.0.0)
- factory_girl_rails (3.1.0)
- factory_girl (~> 3.1.0)
+ factory_girl_rails (3.5.0)
+ factory_girl (~> 3.5.0)
railties (>= 3.0.0)
- ffi (1.0.11)
- gherkin (2.9.3)
+ ffi (1.1.0)
+ gherkin (2.11.1)
json (>= 1.4.6)
i18n (0.5.0)
- json (1.6.6)
- launchy (2.1.0)
- addressable (~> 2.2.6)
+ json (1.7.3)
+ libwebsocket (0.1.4)
+ addressable
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
- mime-types (1.18)
+ mime-types (1.19)
mocha (0.10.5)
metaclass (~> 0.0.1)
- multi_json (1.2.0)
- nokogiri (1.5.2)
+ multi_json (1.3.6)
+ nokogiri (1.5.5)
polyglot (0.3.3)
rack (1.2.5)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
- rails (3.0.12)
- actionmailer (= 3.0.12)
- actionpack (= 3.0.12)
- activerecord (= 3.0.12)
- activeresource (= 3.0.12)
- activesupport (= 3.0.12)
+ rails (3.0.15)
+ actionmailer (= 3.0.15)
+ actionpack (= 3.0.15)
+ activerecord (= 3.0.15)
+ activeresource (= 3.0.15)
+ activesupport (= 3.0.15)
bundler (~> 1.0)
- railties (= 3.0.12)
- railties (3.0.12)
- actionpack (= 3.0.12)
- activesupport (= 3.0.12)
+ railties (= 3.0.15)
+ railties (3.0.15)
+ actionpack (= 3.0.15)
+ activesupport (= 3.0.15)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
- rspec (2.9.0)
- rspec-core (~> 2.9.0)
- rspec-expectations (~> 2.9.0)
- rspec-mocks (~> 2.9.0)
- rspec-core (2.9.0)
- rspec-expectations (2.9.1)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.1)
+ rspec-expectations (2.11.1)
diff-lcs (~> 1.1.3)
- rspec-mocks (2.9.0)
- rspec-rails (2.9.0)
+ rspec-mocks (2.11.1)
+ rspec-rails (2.11.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
- rspec (~> 2.9.0)
- rubyzip (0.9.6.1)
- selenium-webdriver (2.20.0)
+ rspec (~> 2.11.0)
+ rubyzip (0.9.9)
+ selenium-webdriver (2.25.0)
childprocess (>= 0.2.5)
- ffi (~> 1.0)
+ libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
- shoulda-matchers (1.1.0)
+ shoulda-matchers (1.2.0)
activesupport (>= 3.0.0)
- sqlite3 (1.3.5)
- term-ansicolor (1.0.7)
+ sqlite3 (1.3.6)
thor (0.14.6)
timecop (0.3.5)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.32)
+ tzinfo (0.3.33)
xpath (0.1.4)
nokogiri (~> 1.3)
@@ -157,18 +155,17 @@ PLATFORMS
ruby
DEPENDENCIES
- appraisal (~> 0.4.1)
- aruba (~> 0.4.11)
- bourne (~> 1.1.2)
- bundler (~> 1.1)
- capybara (~> 1.1.2)
+ appraisal (= 0.4.1)
+ aruba (= 0.4.11)
+ bourne (= 1.1.2)
+ bundler (= 1.1.3)
+ capybara (= 1.1.2)
clearance!
- cucumber-rails (~> 1.1.1)
- database_cleaner
- factory_girl_rails (~> 3.1.0)
- launchy
- rails (= 3.0.12)
- rspec-rails (~> 2.9.0)
- shoulda-matchers (~> 1.1.0)
- sqlite3
- timecop
+ cucumber-rails (= 1.1.1)
+ database_cleaner (= 0.8.0)
+ factory_girl_rails (= 3.5.0)
+ rails (= 3.0.15)
+ rspec-rails (= 2.11.0)
+ shoulda-matchers (= 1.2.0)
+ sqlite3 (= 1.3.6)
+ timecop (= 0.3.5)
2  gemfiles/3.2.3.gemfile → gemfiles/3.1.6.gemfile
View
@@ -2,6 +2,6 @@
source "http://rubygems.org"
-gem "rails", "3.2.3"
+gem "rails", "3.1.6"
gemspec :path=>"../"
153 gemfiles/3.1.4.gemfile.lock → gemfiles/3.1.6.gemfile.lock
View
@@ -3,41 +3,41 @@ PATH
specs:
clearance (0.16.2)
bcrypt-ruby
- diesel (~> 0.1.5)
+ diesel (= 0.1.5)
rails (>= 3.0)
GEM
remote: http://rubygems.org/
specs:
- actionmailer (3.1.4)
- actionpack (= 3.1.4)
- mail (~> 2.3.0)
- actionpack (3.1.4)
- activemodel (= 3.1.4)
- activesupport (= 3.1.4)
+ actionmailer (3.1.6)
+ actionpack (= 3.1.6)
+ mail (~> 2.3.3)
+ actionpack (3.1.6)
+ activemodel (= 3.1.6)
+ activesupport (= 3.1.6)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.6)
- rack-cache (~> 1.1)
+ rack-cache (~> 1.2)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
- sprockets (~> 2.0.3)
- activemodel (3.1.4)
- activesupport (= 3.1.4)
+ sprockets (~> 2.0.4)
+ activemodel (3.1.6)
+ activesupport (= 3.1.6)
builder (~> 3.0.0)
i18n (~> 0.6)
- activerecord (3.1.4)
- activemodel (= 3.1.4)
- activesupport (= 3.1.4)
+ activerecord (3.1.6)
+ activemodel (= 3.1.6)
+ activesupport (= 3.1.6)
arel (~> 2.2.3)
tzinfo (~> 0.3.29)
- activeresource (3.1.4)
- activemodel (= 3.1.4)
- activesupport (= 3.1.4)
- activesupport (3.1.4)
- multi_json (~> 1.0)
- addressable (2.2.7)
+ activeresource (3.1.6)
+ activemodel (= 3.1.6)
+ activesupport (= 3.1.6)
+ activesupport (3.1.6)
+ multi_json (>= 1.0, < 1.3)
+ addressable (2.3.1)
appraisal (0.4.1)
bundler
rake
@@ -58,46 +58,45 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
- childprocess (0.3.1)
- ffi (~> 1.0.6)
- cucumber (1.1.9)
+ childprocess (0.3.4)
+ ffi (~> 1.0, >= 1.0.6)
+ cucumber (1.2.1)
builder (>= 2.1.2)
- diff-lcs (>= 1.1.2)
- gherkin (~> 2.9.0)
+ diff-lcs (>= 1.1.3)
+ gherkin (~> 2.11.0)
json (>= 1.4.6)
- term-ansicolor (>= 1.0.6)
cucumber-rails (1.1.1)
capybara (>= 1.1.1)
cucumber (>= 1.1.0)
nokogiri (>= 1.5.0)
- database_cleaner (0.7.2)
+ database_cleaner (0.8.0)
diesel (0.1.5)
railties
diff-lcs (1.1.3)
erubis (2.7.0)
- factory_girl (3.1.1)
+ factory_girl (3.5.0)
activesupport (>= 3.0.0)
- factory_girl_rails (3.1.0)
- factory_girl (~> 3.1.0)
+ factory_girl_rails (3.5.0)
+ factory_girl (~> 3.5.0)
railties (>= 3.0.0)
- ffi (1.0.11)
- gherkin (2.9.3)
+ ffi (1.1.0)
+ gherkin (2.11.1)
json (>= 1.4.6)
hike (1.2.1)
i18n (0.6.0)
- json (1.6.6)
- launchy (2.1.0)
- addressable (~> 2.2.6)
+ json (1.7.3)
+ libwebsocket (0.1.4)
+ addressable
mail (2.3.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
- mime-types (1.18)
+ mime-types (1.19)
mocha (0.10.5)
metaclass (~> 0.0.1)
multi_json (1.2.0)
- nokogiri (1.5.2)
+ nokogiri (1.5.5)
polyglot (0.3.3)
rack (1.3.6)
rack-cache (1.2)
@@ -108,17 +107,17 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
- rails (3.1.4)
- actionmailer (= 3.1.4)
- actionpack (= 3.1.4)
- activerecord (= 3.1.4)
- activeresource (= 3.1.4)
- activesupport (= 3.1.4)
+ rails (3.1.6)
+ actionmailer (= 3.1.6)
+ actionpack (= 3.1.6)
+ activerecord (= 3.1.6)
+ activeresource (= 3.1.6)
+ activesupport (= 3.1.6)
bundler (~> 1.0)
- railties (= 3.1.4)
- railties (3.1.4)
- actionpack (= 3.1.4)
- activesupport (= 3.1.4)
+ railties (= 3.1.6)
+ railties (3.1.6)
+ actionpack (= 3.1.6)
+ activesupport (= 3.1.6)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
@@ -126,40 +125,39 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
- rspec (2.9.0)
- rspec-core (~> 2.9.0)
- rspec-expectations (~> 2.9.0)
- rspec-mocks (~> 2.9.0)
- rspec-core (2.9.0)
- rspec-expectations (2.9.1)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.1)
+ rspec-expectations (2.11.1)
diff-lcs (~> 1.1.3)
- rspec-mocks (2.9.0)
- rspec-rails (2.9.0)
+ rspec-mocks (2.11.1)
+ rspec-rails (2.11.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
- rspec (~> 2.9.0)
- rubyzip (0.9.6.1)
- selenium-webdriver (2.20.0)
+ rspec (~> 2.11.0)
+ rubyzip (0.9.9)
+ selenium-webdriver (2.25.0)
childprocess (>= 0.2.5)
- ffi (~> 1.0)
+ libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
- shoulda-matchers (1.1.0)
+ shoulda-matchers (1.2.0)
activesupport (>= 3.0.0)
- sprockets (2.0.3)
+ sprockets (2.0.4)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.5)
- term-ansicolor (1.0.7)
+ sqlite3 (1.3.6)
thor (0.14.6)
tilt (1.3.3)
timecop (0.3.5)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.32)
+ tzinfo (0.3.33)
xpath (0.1.4)
nokogiri (~> 1.3)
@@ -167,18 +165,17 @@ PLATFORMS
ruby
DEPENDENCIES
- appraisal (~> 0.4.1)
- aruba (~> 0.4.11)
- bourne (~> 1.1.2)
- bundler (~> 1.1)
- capybara (~> 1.1.2)
+ appraisal (= 0.4.1)
+ aruba (= 0.4.11)
+ bourne (= 1.1.2)
+ bundler (= 1.1.3)
+ capybara (= 1.1.2)
clearance!
- cucumber-rails (~> 1.1.1)
- database_cleaner
- factory_girl_rails (~> 3.1.0)
- launchy
- rails (= 3.1.4)
- rspec-rails (~> 2.9.0)
- shoulda-matchers (~> 1.1.0)
- sqlite3
- timecop
+ cucumber-rails (= 1.1.1)
+ database_cleaner (= 0.8.0)
+ factory_girl_rails (= 3.5.0)
+ rails (= 3.1.6)
+ rspec-rails (= 2.11.0)
+ shoulda-matchers (= 1.2.0)
+ sqlite3 (= 1.3.6)
+ timecop (= 0.3.5)
2  gemfiles/3.1.4.gemfile → gemfiles/3.2.6.gemfile
View
@@ -2,6 +2,6 @@
source "http://rubygems.org"
-gem "rails", "3.1.4"
+gem "rails", "3.2.6"
gemspec :path=>"../"
155 gemfiles/3.2.3.gemfile.lock → gemfiles/3.2.6.gemfile.lock
View
@@ -3,40 +3,40 @@ PATH
specs:
clearance (0.16.2)
bcrypt-ruby
- diesel (~> 0.1.5)
+ diesel (= 0.1.5)
rails (>= 3.0)
GEM
remote: http://rubygems.org/
specs:
- actionmailer (3.2.3)
- actionpack (= 3.2.3)
+ actionmailer (3.2.6)
+ actionpack (= 3.2.6)
mail (~> 2.4.4)
- actionpack (3.2.3)
- activemodel (= 3.2.3)
- activesupport (= 3.2.3)
+ actionpack (3.2.6)
+ activemodel (= 3.2.6)
+ activesupport (= 3.2.6)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
- sprockets (~> 2.1.2)
- activemodel (3.2.3)
- activesupport (= 3.2.3)
+ sprockets (~> 2.1.3)
+ activemodel (3.2.6)
+ activesupport (= 3.2.6)
builder (~> 3.0.0)
- activerecord (3.2.3)
- activemodel (= 3.2.3)
- activesupport (= 3.2.3)
+ activerecord (3.2.6)
+ activemodel (= 3.2.6)
+ activesupport (= 3.2.6)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
- activeresource (3.2.3)
- activemodel (= 3.2.3)
- activesupport (= 3.2.3)
- activesupport (3.2.3)
+ activeresource (3.2.6)
+ activemodel (= 3.2.6)
+ activesupport (= 3.2.6)
+ activesupport (3.2.6)
i18n (~> 0.6)
multi_json (~> 1.0)
- addressable (2.2.7)
+ addressable (2.3.1)
appraisal (0.4.1)
bundler
rake
@@ -57,47 +57,46 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
- childprocess (0.3.1)
- ffi (~> 1.0.6)
- cucumber (1.1.9)
+ childprocess (0.3.4)
+ ffi (~> 1.0, >= 1.0.6)
+ cucumber (1.2.1)
builder (>= 2.1.2)
- diff-lcs (>= 1.1.2)
- gherkin (~> 2.9.0)
+ diff-lcs (>= 1.1.3)
+ gherkin (~> 2.11.0)
json (>= 1.4.6)
- term-ansicolor (>= 1.0.6)
cucumber-rails (1.1.1)
capybara (>= 1.1.1)
cucumber (>= 1.1.0)
nokogiri (>= 1.5.0)
- database_cleaner (0.7.2)
+ database_cleaner (0.8.0)
diesel (0.1.5)
railties
diff-lcs (1.1.3)
erubis (2.7.0)
- factory_girl (3.1.1)
+ factory_girl (3.5.0)
activesupport (>= 3.0.0)
- factory_girl_rails (3.1.0)
- factory_girl (~> 3.1.0)
+ factory_girl_rails (3.5.0)
+ factory_girl (~> 3.5.0)
railties (>= 3.0.0)
- ffi (1.0.11)
- gherkin (2.9.3)
+ ffi (1.1.0)
+ gherkin (2.11.1)
json (>= 1.4.6)
hike (1.2.1)
i18n (0.6.0)
- journey (1.0.3)
- json (1.6.6)
- launchy (2.1.0)
- addressable (~> 2.2.6)
+ journey (1.0.4)
+ json (1.7.3)
+ libwebsocket (0.1.4)
+ addressable
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
- mime-types (1.18)
+ mime-types (1.19)
mocha (0.10.5)
metaclass (~> 0.0.1)
- multi_json (1.2.0)
- nokogiri (1.5.2)
+ multi_json (1.3.6)
+ nokogiri (1.5.5)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
@@ -106,58 +105,57 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
- rails (3.2.3)
- actionmailer (= 3.2.3)
- actionpack (= 3.2.3)
- activerecord (= 3.2.3)
- activeresource (= 3.2.3)
- activesupport (= 3.2.3)
+ rails (3.2.6)
+ actionmailer (= 3.2.6)
+ actionpack (= 3.2.6)
+ activerecord (= 3.2.6)
+ activeresource (= 3.2.6)
+ activesupport (= 3.2.6)
bundler (~> 1.0)
- railties (= 3.2.3)
- railties (3.2.3)
- actionpack (= 3.2.3)
- activesupport (= 3.2.3)
+ railties (= 3.2.6)
+ railties (3.2.6)
+ actionpack (= 3.2.6)
+ activesupport (= 3.2.6)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
- thor (~> 0.14.6)
+ thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
- rspec (2.9.0)
- rspec-core (~> 2.9.0)
- rspec-expectations (~> 2.9.0)
- rspec-mocks (~> 2.9.0)
- rspec-core (2.9.0)
- rspec-expectations (2.9.1)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.1)
+ rspec-expectations (2.11.1)
diff-lcs (~> 1.1.3)
- rspec-mocks (2.9.0)
- rspec-rails (2.9.0)
+ rspec-mocks (2.11.1)
+ rspec-rails (2.11.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
- rspec (~> 2.9.0)
- rubyzip (0.9.6.1)
- selenium-webdriver (2.20.0)
+ rspec (~> 2.11.0)
+ rubyzip (0.9.9)
+ selenium-webdriver (2.25.0)
childprocess (>= 0.2.5)
- ffi (~> 1.0)
+ libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
- shoulda-matchers (1.1.0)
+ shoulda-matchers (1.2.0)
activesupport (>= 3.0.0)
- sprockets (2.1.2)
+ sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.5)
- term-ansicolor (1.0.7)
- thor (0.14.6)
+ sqlite3 (1.3.6)
+ thor (0.15.4)
tilt (1.3.3)
timecop (0.3.5)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.32)
+ tzinfo (0.3.33)
xpath (0.1.4)
nokogiri (~> 1.3)
@@ -165,18 +163,17 @@ PLATFORMS
ruby
DEPENDENCIES
- appraisal (~> 0.4.1)
- aruba (~> 0.4.11)
- bourne (~> 1.1.2)
- bundler (~> 1.1)
- capybara (~> 1.1.2)
+ appraisal (= 0.4.1)
+ aruba (= 0.4.11)
+ bourne (= 1.1.2)
+ bundler (= 1.1.3)
+ capybara (= 1.1.2)
clearance!
- cucumber-rails (~> 1.1.1)
- database_cleaner
- factory_girl_rails (~> 3.1.0)
- launchy
- rails (= 3.2.3)
- rspec-rails (~> 2.9.0)
- shoulda-matchers (~> 1.1.0)
- sqlite3
- timecop
+ cucumber-rails (= 1.1.1)
+ database_cleaner (= 0.8.0)
+ factory_girl_rails (= 3.5.0)
+ rails (= 3.2.6)
+ rspec-rails (= 2.11.0)
+ shoulda-matchers (= 1.2.0)
+ sqlite3 (= 1.3.6)
+ timecop (= 0.3.5)
2  lib/clearance/user.rb
View
@@ -105,7 +105,7 @@ def password_optional?
end
def password_required?
- warn "[DEPRECATION] password_required?: use !password_optional? instead"
+ warn '[DEPRECATION] password_required?: use !password_optional? instead'
!password_optional?
end
end
19 spec/clearance/constraints/signed_in_spec.rb
View
@@ -3,9 +3,9 @@
describe Clearance::Constraints::SignedIn do
it 'returns true when user is signed in' do
user = create(:user)
-
signed_in_constraint = Clearance::Constraints::SignedIn.new
- signed_in_constraint.matches?(request_with_remember_token(user.remember_token)).should be_true
+ signed_in_constraint.matches?(request_with_remember_token(user.remember_token)).
+ should be_true
end
it 'returns false when user is not signed in' do
@@ -15,8 +15,9 @@
it 'yields a signed-in user to a provided block' do
user = create(:user, :email => 'before@example.com')
+
signed_in_constraint = Clearance::Constraints::SignedIn.new do |user|
- user.update_attribute(:email, 'after@example.com')
+ user.update_attribute :email, 'after@example.com'
end
signed_in_constraint.matches?(request_with_remember_token(user.remember_token))
@@ -27,7 +28,7 @@
user = create(:user, :email => 'before@example.com')
signed_in_constraint = Clearance::Constraints::SignedIn.new do |user|
- user.update_attribute(:email, 'after@example.com')
+ user.update_attribute :email, 'after@example.com'
end
signed_in_constraint.matches?(request_without_remember_token)
@@ -36,17 +37,15 @@
it 'matches if the user-provided block returns true' do
user = create(:user)
-
signed_in_constraint = Clearance::Constraints::SignedIn.new { |user| true }
-
- signed_in_constraint.matches?(request_with_remember_token(user.remember_token)).should be_true
+ signed_in_constraint.matches?(request_with_remember_token(user.remember_token)).
+ should be_true
end
it 'does not match if the user-provided block returns false' do
user = create(:user)
-
signed_in_constraint = Clearance::Constraints::SignedIn.new { |user| false }
-
- signed_in_constraint.matches?(request_with_remember_token(user.remember_token)).should be_false
+ signed_in_constraint.matches?(request_with_remember_token(user.remember_token)).
+ should be_false
end
end
4 spec/clearance/constraints/signed_out_spec.rb
View
@@ -8,8 +8,8 @@
it 'returns false when user is not signed out' do
user = create(:user)
-
signed_out_constraint = Clearance::Constraints::SignedOut.new
- signed_out_constraint.matches?(request_with_remember_token(user.remember_token)).should be_false
+ signed_out_constraint.matches?(request_with_remember_token(user.remember_token)).
+ should be_false
end
end
15 spec/clearance/rack_session_spec.rb
View
@@ -1,23 +1,24 @@
require 'spec_helper'
describe Clearance::RackSession do
- it "injects a clearance session into the environment" do
- expected_session = "the session"
- expected_session.stubs(:add_cookie_to_headers)
- Clearance::Session.stubs(:new => expected_session)
- headers = { "X-Roaring-Lobster" => "Red" }
+ it 'injects a clearance session into the environment' do
+ expected_session = 'the session'
+ expected_session.stubs :add_cookie_to_headers
+ Clearance::Session.stubs :new => expected_session
+ headers = { 'X-Roaring-Lobster' => 'Red' }
app = Rack::Builder.new do
use Clearance::RackSession
run lambda { |env| Rack::Response.new(env[:clearance], 200, headers).finish }
end
- env = Rack::MockRequest.env_for("/")
+ env = Rack::MockRequest.env_for('/')
response = Rack::MockResponse.new(*app.call(env))
Clearance::Session.should have_received(:new).with(env)
response.body.should == expected_session
- expected_session.should have_received(:add_cookie_to_headers).with(has_entries(headers))
+ expected_session.should have_received(:add_cookie_to_headers).
+ with(has_entries(headers))
end
end
51 spec/clearance/session_spec.rb
View
@@ -4,95 +4,101 @@
before { Timecop.freeze }
after { Timecop.return }
- it "finds a user from a cookie" do
+ it 'finds a user from a cookie' do
user = create(:user)
env = env_with_remember_token(user.remember_token)
-
session = Clearance::Session.new(env)
session.should be_signed_in
session.current_user.should == user
end
- it "returns nil for an unknown user" do
+ it 'returns nil for an unknown user' do
user = create(:user)
- env = env_with_remember_token("bogus")
-
+ env = env_with_remember_token('bogus')
session = Clearance::Session.new(env)
session.should be_signed_out
session.current_user.should be_nil
end
- it "returns nil without a remember token" do
+ it 'returns nil without a remember token' do
env = env_without_remember_token
session = Clearance::Session.new(env)
session.should be_signed_out
session.current_user.should be_nil
end
- it "signs in a given user" do
+ it 'signs in a given user' do
user = create(:user)
session = Clearance::Session.new(env_without_remember_token)
session.sign_in user
session.current_user.should == user
end
- it "sets a remember token cookie with a default expiration of 1 year from now" do
+ it 'sets a remember token cookie with a default expiration of 1 year from now' do
user = create(:user)
headers = {}
session = Clearance::Session.new(env_without_remember_token)
session.sign_in user
session.add_cookie_to_headers headers
- headers.should set_cookie("remember_token", user.remember_token, 1.year.from_now)
+ headers.should set_cookie('remember_token', user.remember_token, 1.year.from_now)
end
- it "sets a remember token cookie with a custom expiration" do
+ it 'sets a remember token cookie with a custom expiration' do
custom_expiration = 1.day.from_now
+
with_custom_expiration 1.day.from_now do
user = create(:user)
headers = {}
session = Clearance::Session.new(env_without_remember_token)
session.sign_in user
session.add_cookie_to_headers headers
- headers.should set_cookie("remember_token", user.remember_token, 1.day.from_now)
- Clearance.configuration.cookie_expiration.call.should be_within(100).of(1.year.from_now)
+ headers.should set_cookie('remember_token', user.remember_token, 1.day.from_now)
+ Clearance.configuration.cookie_expiration.call.should be_within(100).
+ of(1.year.from_now)
end
end
- it "doesn't set a remember token when signed out" do
+ it 'does not set a remember token when signed out' do
headers = {}
session = Clearance::Session.new(env_without_remember_token)
session.add_cookie_to_headers headers
- headers.should_not set_cookie("remember_token")
+ headers.should_not set_cookie('remember_token')
end
- it "signs out a user" do
+ it 'signs out a user' do
user = create(:user)
old_remember_token = user.remember_token
env = env_with_remember_token(old_remember_token)
-
session = Clearance::Session.new(env)
session.sign_out
session.current_user.should be_nil
user.reload.remember_token.should_not == old_remember_token
end
+ def env_with_cookies(cookies)
+ Rack::MockRequest.env_for '/', 'HTTP_COOKIE' => serialize_cookies(cookies)
+ end
+
def env_with_remember_token(token)
- env_with_cookies("remember_token" => token)
+ env_with_cookies 'remember_token' => token
end
def env_without_remember_token
env_with_cookies({})
end
- def env_with_cookies(cookies)
- Rack::MockRequest.env_for("/", "HTTP_COOKIE" => serialize_cookies(cookies))
+ def restore_default_config
+ Clearance.configuration = nil
+ Clearance.configure {}
end
def serialize_cookies(hash)
header = {}
+
hash.each do |key, value|
- Rack::Utils.set_cookie_header!(header, key, value)
+ Rack::Utils.set_cookie_header! header, key, value
end
+
header['Set-Cookie']
end
@@ -101,9 +107,4 @@ def with_custom_expiration(custom_duration)
ensure
restore_default_config
end
-
- def restore_default_config
- Clearance.configuration = nil
- Clearance.configure {}
- end
end
21 spec/controllers/denies_controller_spec.rb
View
@@ -5,17 +5,17 @@ class DeniesController < ActionController::Base
before_filter :authorize, :only => :show
def new
- render :text => "New page"
+ render :text => 'New page'
end
def show
- render :text => "Show page"
+ render :text => 'Show page'
end
protected
def authorize
- deny_access("Access denied.")
+ deny_access 'Access denied.'
end
end
@@ -31,30 +31,31 @@ def authorize
Rails.application.reload_routes!
end
- context "signed in user" do
+ context 'signed in user' do
before { sign_in }
- it "allows access to new" do
+ it 'allows access to new' do
get :new
subject.should_not deny_access
end
- it "denies access to show" do
+ it 'denies access to show' do
get :show
subject.should deny_access(:redirect => '/')
end
end
- context "visitor" do
- it "allows access to new" do
+ context 'visitor' do
+ it 'allows access to new' do
get :new
subject.should_not deny_access
end
- it "denies access to show" do
+ it 'denies access to show' do
get :show
subject.should deny_access
- subject.should deny_access(:redirect => sign_in_url, :flash => "Access denied.")
+ subject.should deny_access(:redirect => sign_in_url,
+ :flash => 'Access denied.')
end
end
end
10 spec/controllers/flashes_controller_spec.rb
View
@@ -16,8 +16,8 @@ def view_flash
describe FlashesController do
before do
Rails.application.routes.draw do
- match "set_flash" => "flashes#set_flash"
- match "view_flash" => "flashes#view_flash"
+ match 'set_flash' => 'flashes#set_flash'
+ match 'view_flash' => 'flashes#view_flash'
end
end
@@ -25,8 +25,8 @@ def view_flash
Rails.application.reload_routes!
end
- it "sets and views a flash" do
- visit "/set_flash?message=hello"
- page.should have_content("hello")
+ it 'sets and views a flash' do
+ visit '/set_flash?message=hello'
+ page.should have_content('hello')
end
end
18 spec/controllers/forgeries_controller_spec.rb
View
@@ -14,7 +14,7 @@ def create
end
describe ForgeriesController do
- context "signed in user" do
+ context 'signed in user' do
before do
Rails.application.routes.draw do
resources :forgeries
@@ -22,26 +22,26 @@ def create
end
@user = create(:user)
- @user.update_attribute(:remember_token, "old-token")
- @request.cookies["remember_token"] = "old-token"
- @request.session[:_csrf_token] = "golden-ticket"
+ @user.update_attribute(:remember_token, 'old-token')
+ @request.cookies['remember_token'] = 'old-token'
+ @request.session[:_csrf_token] = 'golden-ticket'
end
after do
Rails.application.reload_routes!
end
- it "succeeds with authentic token" do
- post :create, :authenticity_token => "golden-ticket"
+ it 'succeeds with authentic token' do
+ post :create, :authenticity_token => 'golden-ticket'
subject.should redirect_to(:action => 'index')
end
- it "fails with invalid token" do
- post :create, :authenticity_token => "hax0r"
+ it 'fails with invalid token' do
+ post :create, :authenticity_token => 'hax0r'
subject.should deny_access
end
- it "fails with no token" do
+ it 'fails with no token' do
post :create
subject.should deny_access
end
90 spec/controllers/passwords_controller_spec.rb
View
@@ -3,40 +3,41 @@
describe Clearance::PasswordsController do
include Shoulda::Matchers::ActionMailer
- it { should route(:get, '/users/1/password/edit').
- to(:controller => 'clearance/passwords', :action => 'edit', :user_id => '1') }
+ it {
+ should route(:get, '/users/1/password/edit').
+ to(:controller => 'clearance/passwords', :action => 'edit', :user_id => '1')
+ }
- describe "a signed up user" do
+ describe 'a signed up user' do
before do
@user = create(:user)
end
- describe "on GET to #new" do
+ describe 'on GET to #new' do
before { get :new, :user_id => @user.to_param }
it { should respond_with(:success) }
it { should render_template(:new) }
end
- describe "on POST to #create" do
- describe "with correct email address" do
+ describe 'on POST to #create' do
+ describe 'with correct email address' do
before do
ActionMailer::Base.deliveries.clear
post :create, :password => { :email => @user.email }
end
- it "should generate a token for the change your password email" do
+ it 'should generate a token for the change your password email' do
@user.reload.confirmation_token.should_not be_nil
end
it { should have_sent_email.with_subject(/change your password/i) }
-
it { should respond_with(:success) }
end
- describe "with incorrect email address" do
+ describe 'with incorrect email address' do
before do
- email = "user1@example.com"
+ email = 'user1@example.com'
(Clearance.configuration.user_model.exists?(['email = ?', email])).should_not be
ActionMailer::Base.deliveries.clear
@user.reload.confirmation_token.should == @user.confirmation_token
@@ -44,11 +45,11 @@
post :create, :password => { :email => email }
end
- it "should not generate a token for the change your password email" do
+ it 'should not generate a token for the change your password email' do
@user.reload.confirmation_token.should == @user.confirmation_token
end
- it "should not send a password reminder email" do
+ it 'should not send a password reminder email' do
ActionMailer::Base.deliveries.should be_empty
end
@@ -58,19 +59,19 @@
end
end
- describe "a signed up user and forgotten password" do
+ describe 'a signed up user and forgotten password' do
before do
@user = create(:user)
@user.forgot_password!
end
- describe "on GET to #edit with correct id and token" do
+ describe 'on GET to #edit with correct id and token' do
before do
get :edit, :user_id => @user.to_param,
- :token => @user.confirmation_token
+ :token => @user.confirmation_token
end
- it "should find the user" do
+ it 'should find the user' do
assigns(:user).should == @user
end
@@ -78,16 +79,16 @@
it { should render_template(:edit) }
end
- describe "on GET to #edit with correct id but blank token" do
+ describe 'on GET to #edit with correct id but blank token' do
before do
- get :edit, :user_id => @user.to_param, :token => ""
+ get :edit, :user_id => @user.to_param, :token => ''
end
it { should set_the_flash.to(/double check the URL/i).now }
it { should render_template(:new) }
end
- describe "on GET to #edit with correct id but no token" do
+ describe 'on GET to #edit with correct id but no token' do
before do
get :edit, :user_id => @user.to_param
end
@@ -96,55 +97,46 @@
it { should render_template(:new) }
end
- describe "on PUT to #update with password" do
+ describe 'on PUT to #update with password' do
before do
- @new_password = "new_password"
+ @new_password = 'new_password'
@user.encrypted_password.should_not == @new_password
-
- put(:update,
- :user_id => @user,
- :token => @user.confirmation_token,
- :user => {
- :password => @new_password
- })
+ put :update, :user_id => @user, :token => @user.confirmation_token,
+ :user => { :password => @new_password }
@user.reload
end
- it "should update password" do
+ it 'should update password' do
@user.encrypted_password.should == @new_password
end
- it "should clear confirmation token" do
+ it 'should clear confirmation token' do
@user.confirmation_token.should be_nil
end
- it "should set remember token" do
+ it 'should set remember token' do
@user.remember_token.should_not be_nil
end
it { should redirect_to_url_after_update }
end
- describe "on PUT to #update with blank password" do
+ describe 'on PUT to #update with blank password' do
before do
- put(:update,
- :user_id => @user.to_param,
- :token => @user.confirmation_token,
- :user => {
- :password => ''
- })
+ put :update, :user_id => @user.to_param, :token => @user.confirmation_token,
+ :user => { :password => '' }
@user.reload
end
- it "should not update password to be blank" do
+ it 'should not update password to be blank' do
@user.encrypted_password.should_not be_blank
end
- it "should not clear token" do
+ it 'should not clear token' do
@user.confirmation_token.should_not be_nil
end
- it "should not be signed in" do
+ it 'should not be signed in' do
cookies[:remember_token].should be_nil
end
@@ -153,16 +145,12 @@
it { should render_template(:edit) }
end
- describe "on PUT to #update with an empty token after the user sets a password" do
+ describe 'on PUT to #update with an empty token after the user sets a password' do
before do
- put :update,
- :user_id => @user.to_param,
- :token => @user.confirmation_token,
- :user => { :password => 'good password' }
- put :update,
- :user_id => @user.to_param,
- :token => [nil],
- :user => { :password => 'new password' }
+ put :update, :user_id => @user.to_param, :token => @user.confirmation_token,
+ :user => { :password => 'good password' }
+ put :update, :user_id => @user.to_param, :token => [nil],
+ :user => { :password => 'new password' }
end
it { should set_the_flash.to(/double check the URL/i).now }
@@ -170,7 +158,7 @@
end
end
- describe "given two users and user one signs in" do
+ describe 'given two users and user one signs in' do
before do
@user_one = create(:user)
@user_two = create(:user)
59 spec/controllers/sessions_controller_spec.rb
View
@@ -1,7 +1,7 @@
require 'spec_helper'
describe Clearance::SessionsController do
- describe "on GET to /sessions/new" do
+ describe 'on GET to /sessions/new' do
before { get :new }
it { should respond_with(:success) }
@@ -9,95 +9,88 @@
it { should_not set_the_flash }
end
- describe "on POST to #create with good credentials" do
+ describe 'on POST to #create with good credentials' do
before do
@user = create(:user)
- @user.update_attribute(:remember_token, "old-token")
- post :create, :session => {
- :email => @user.email,
- :password => @user.password }
+ @user.update_attribute :remember_token, 'old-token'
+ post :create, :session => { :email => @user.email, :password => @user.password }
end
it { should redirect_to_url_after_create }
- it "sets the user in the clearance session" do
+ it 'sets the user in the clearance session' do
controller.current_user.should == @user
end
- it "should not change the remember token" do
- @user.reload.remember_token.should == "old-token"
+ it 'should not change the remember token' do
+ @user.reload.remember_token.should == 'old-token'
end
end
- describe "on POST to #create with good credentials and a session return url" do
+ describe 'on POST to #create with good credentials and a session return url' do
before do
@user = create(:user)
@return_url = '/url_in_the_session'
@request.session[:return_to] = @return_url
- post :create, :session => {
- :email => @user.email,
- :password => @user.password }
+ post :create, :session => { :email => @user.email, :password => @user.password }
end
- it "redirects to the return URL" do
+ it 'redirects to the return URL' do
should redirect_to(@return_url)
end
end
- describe "on POST to #create with good credentials and a request return url" do
+ describe 'on POST to #create with good credentials and a request return url' do
before do
@user = create(:user)
@return_url = '/url_in_the_request'
- post :create, :session => {
- :email => @user.email,
- :password => @user.password },
- :return_to => @return_url
+ post :create, :session => { :email => @user.email, :password => @user.password },
+ :return_to => @return_url
end
- it "redirects to the return URL" do
+ it 'redirects to the return URL' do
should redirect_to(@return_url)
end
end
- describe "on POST to #create with good credentials and a session return url and request return url" do
+ describe 'on POST to #create with good credentials and a session return url and request return url' do
before do
@user = create(:user)
@return_url = '/url_in_the_session'
@request.session[:return_to] = @return_url
- post :create, :session => {
- :email => @user.email,
- :password => @user.password },
- :return_to => '/url_in_the_request'
+ post :create, :session => { :email => @user.email, :password => @user.password },
+ :return_to => '/url_in_the_request'
end
- it "redirects to the return url" do
+ it 'redirects to the return url' do
should redirect_to(@return_url)
end
end
- describe "on DELETE to #destroy given a signed out user" do
+ describe 'on DELETE to #destroy given a signed out user' do
before do
sign_out
delete :destroy
end
+
it { should redirect_to_url_after_destroy }
end
- describe "on DELETE to #destroy with a cookie" do
+ describe 'on DELETE to #destroy with a cookie' do
before do
@user = create(:user)
- @user.update_attribute(:remember_token, "old-token")
- @request.cookies["remember_token"] = "old-token"
+ @user.update_attribute :remember_token, 'old-token'
+ @request.cookies['remember_token'] = 'old-token'
delete :destroy
end
it { should redirect_to_url_after_destroy }
- it "should reset the remember token" do
- @user.reload.remember_token.should_not == "old-token"
+ it 'should reset the remember token' do
+ @user.reload.remember_token.should_not == 'old-token'
end
- it "should unset the current user" do
+ it 'should unset the current user' do
@controller.current_user.should be_nil
end
end
30 spec/controllers/users_controller_spec.rb
View
@@ -1,10 +1,10 @@
require 'spec_helper'
describe Clearance::UsersController do
- describe "when signed out" do
+ describe 'when signed out' do
before { sign_out }
- describe "on GET to #new" do
+ describe 'on GET to #new' do
before { get :new }
it { should respond_with(:success) }
@@ -12,18 +12,18 @@
it { should_not set_the_flash }
end
- describe "on GET to #new with email" do
+ describe 'on GET to #new with email' do
before do
- @email = "a@example.com"
+ @email = 'a@example.com'
get :new, :user => { :email => @email }
end
- it "should set assigned user's email" do
+ it 'should set assigned user email' do
assigns(:user).email.should == @email
end
end
- describe "on POST to #create with valid attributes" do
+ describe 'on POST to #create with valid attributes' do
before do
user_attributes = FactoryGirl.attributes_for(:user)
@old_user_count = User.count
@@ -32,14 +32,14 @@
it { should assign_to(:user) }
- it "should create a new user" do
+ it 'should create a new user' do
User.count.should == @old_user_count + 1
end
it { should redirect_to_url_after_create }
end
- describe "on POST to #create with valid attributes and a session return url" do
+ describe 'on POST to #create with valid attributes and a session return url' do
before do
user_attributes = FactoryGirl.attributes_for(:user)
@old_user_count = User.count
@@ -50,7 +50,7 @@
it { should assign_to(:user) }
- it "should create a new user" do
+ it 'should create a new user' do
User.count.should == @old_user_count + 1
end
@@ -58,22 +58,24 @@
end
end
- describe "A signed-in user" do
+ describe 'A signed-in user' do
before do
@user = create(:user)
sign_in_as @user
end
- describe "GET to new" do
+ describe 'GET to new' do
before { get :new }
- it "redirects to the home page" do
+
+ it 'redirects to the home page' do
should redirect_to(root_url)
end
end
- describe "POST to create" do
+ describe 'POST to create' do
before { post :create, :user => {} }
- it "redirects to the home page" do
+
+ it 'redirects to the home page' do
should redirect_to(root_url)
end
end
4 spec/factories.rb
View
@@ -1,12 +1,10 @@
FactoryGirl.define do
-
sequence :email do |n|
"user#{n}@example.com"
end
factory :user do
email
- password "password"
+ password 'password'
end
-
end
8 spec/mailers/clearance_mailer_spec.rb
View
@@ -7,21 +7,21 @@
@email = ClearanceMailer.change_password(@user)
end
- it "should be from DO_NOT_REPLY" do
+ it 'is from DO_NOT_REPLY' do
Clearance.configuration.mailer_sender.should =~ /#{@email.from[0]}/i
end
- it "should be sent to user" do
+ it 'is sent to user' do
@email.to.first.should =~ /#{@user.email}/i
end
- it "should contain a link to edit the user's password" do
+ it 'contains a link to edit the password' do
host = ActionMailer::Base.default_url_options[:host]
regexp = %r{http://#{host}/users/#{@user.id}/password/edit\?token=#{@user.confirmation_token}}
@email.body.to_s.should =~ regexp
end
- it "should set its subject" do
+ it 'should set its subject' do
@email.subject.should =~ /Change your password/
end
end
37 spec/models/bcrypt_migration_from_sha1_spec.rb
View
@@ -9,32 +9,31 @@
end.new
end
- describe "#password=" do
- let(:salt) { "salt" }
- let(:password) { "password" }
- let(:encrypted_password) { stub("encrypted password") }
+ describe '#password=' do
+ let(:salt) { 'salt' }
+ let(:password) { 'password' }
+ let(:encrypted_password) { stub('encrypted password') }
before do
subject.salt = salt
subject.encrypted_password = Digest::SHA1.hexdigest("--#{salt}--#{password}--")
-
- BCrypt::Password.stubs(:create => encrypted_password)
+ BCrypt::Password.stubs :create => encrypted_password
subject.password = password
end
- it "encrypts the password into a BCrypt-encrypted encrypted_password" do
+ it 'encrypts the password into a BCrypt-encrypted encrypted_password' do
subject.encrypted_password.should == encrypted_password
end
- it "encrypts with BCrypt" do
+ it 'encrypts with BCrypt' do
BCrypt::Password.should have_received(:create).with(password)
end
end
- describe "#authenticated?" do
- let(:password) { "password" }
- let(:salt) { "salt" }
- let(:sha1_hash) { Digest::SHA1.hexdigest("--#{salt}--#{password}--") }
+ describe '#authenticated?' do
+ let(:password) { 'password' }
+ let(:salt) { 'salt' }
+ let(:sha1_hash) { Digest::SHA1.hexdigest("--#{salt}--#{password}--") }
context 'with a SHA1-encrypted password' do
before do
@@ -42,29 +41,29 @@
subject.encrypted_password = sha1_hash
end
- it "is authenticated" do
+ it 'is authenticated' do
subject.should be_authenticated(password)
end
- it "changes the hash into a BCrypt-encrypted one" do
- subject.authenticated?(password)
+ it 'changes the hash into a BCrypt-encrypted one' do
+ subject.authenticated? password
subject.encrypted_password.should_not == sha1_hash
end
end
- context "with a BCrypt-encrypted password" do
+ context 'with a BCrypt-encrypted password' do
let(:bcrypt_hash) { ::BCrypt::Password.create(password) }
before do
subject.encrypted_password = bcrypt_hash
end
- it "is authenticated" do
+ it 'is authenticated' do
subject.should be_authenticated(password)
end
- it "does not change the hash" do
- subject.authenticated?(password)
+ it 'does not change the hash' do
+ subject.authenticated? password
subject.encrypted_password.to_s.should == bcrypt_hash.to_s
end
end
19 spec/models/bcrypt_spec.rb
View
@@ -8,33 +8,32 @@
end.new
end
- describe "#password=" do
- let(:password) { "password" }
- let(:encrypted_password) { stub("encrypted password") }
+ describe '#password=' do
+ let(:password) { 'password' }
+ let(:encrypted_password) { stub('encrypted password') }
before do
- BCrypt::Password.stubs(:create => encrypted_password)
-
+ BCrypt::Password.stubs :create => encrypted_password
subject.password = password
end
- it "encrypts the password into encrypted_password" do
+ it 'encrypts the password into encrypted_password' do
subject.encrypted_password.should == encrypted_password
end
- it "encrypts with BCrypt" do
+ it 'encrypts with BCrypt' do
BCrypt::Password.should have_received(:create).with(password)
end
end
- describe "#authenticated?" do
- let(:password) { "password" }
+ describe '#authenticated?' do
+ let(:password) { 'password' }
before do
subject.password = password
end
- it "is authenticated with BCrypt" do
+ it 'is authenticated with BCrypt' do
subject.should be_authenticated(password)
end
end
20 spec/models/blowfish_spec.rb
View
@@ -6,41 +6,39 @@
attr_accessor :salt, :encrypted_password
include Clearance::PasswordStrategies::Blowfish
- def generate_random_code; "code"; end
+ def generate_random_code; 'code'; end
end.new
end
- describe "#password=" do
- context "when the password is set" do
- let(:salt) { "salt" }
- let(:password) { "password" }
+ describe '#password=' do
+ context 'when the password is set' do
+ let(:salt) { 'salt' }
+ let(:password) { 'password' }
before do
subject.salt = salt
subject.password = password
end
- it "doesn't initialize the salt" do
+ it 'does not initialize the salt' do
subject.salt.should == salt
end
- it "encrypts the password using Blowfish into encrypted_password" do
+ it 'encrypts the password using Blowfish and the existing salt' do
cipher = OpenSSL::Cipher::Cipher.new('bf-cbc').encrypt
cipher.key = Digest::SHA256.digest(salt)
expected = cipher.update("--#{salt}--#{password}--&quo