clearance 1.0.0.rc2 → 1.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of clearance might be problematic. Click here for more details.

Files changed (50) hide show
  1. data/Gemfile.lock +2 -5
  2. data/NEWS.md +4 -1
  3. data/README.md +10 -10
  4. data/Rakefile +0 -1
  5. data/app/controllers/clearance/passwords_controller.rb +1 -10
  6. data/clearance.gemspec +0 -1
  7. data/features/add_migrations_to_project.feature +65 -0
  8. data/features/integration_with_rspec.feature +21 -0
  9. data/features/step_definitions/configuration_steps.rb +21 -0
  10. data/features/step_definitions/gem_file_steps.rb +7 -0
  11. data/features/support/env.rb +8 -18
  12. data/gemfiles/3.0.17.gemfile.lock +1 -4
  13. data/gemfiles/3.1.8.gemfile.lock +1 -4
  14. data/gemfiles/3.2.8.gemfile.lock +1 -4
  15. data/{features/support/clearance.rb → lib/clearance/testing/app/controllers/application_controller.rb} +0 -9
  16. data/lib/clearance/testing/application.rb +46 -0
  17. data/lib/clearance/testing/config/database.yml +11 -0
  18. data/lib/clearance/testing/config/routes.rb +3 -0
  19. data/lib/clearance/version.rb +1 -1
  20. data/lib/generators/clearance/install/install_generator.rb +103 -22
  21. data/lib/generators/clearance/install/templates/README +14 -7
  22. data/lib/generators/clearance/install/templates/db/migrate/add_clearance_to_users.rb +21 -0
  23. data/lib/generators/clearance/install/templates/db/migrate/create_users.rb +18 -0
  24. data/lib/generators/clearance/specs/USAGE +5 -0
  25. data/lib/generators/clearance/specs/specs_generator.rb +13 -0
  26. data/lib/generators/clearance/specs/templates/factories/clearance.rb +10 -0
  27. data/lib/generators/clearance/specs/templates/integration/clearance/user_signs_out_spec.rb +10 -0
  28. data/lib/generators/clearance/specs/templates/integration/clearance/visitor_resets_password_spec.rb +28 -0
  29. data/lib/generators/clearance/specs/templates/integration/clearance/visitor_signs_in_spec.rb +42 -0
  30. data/lib/generators/clearance/specs/templates/integration/clearance/visitor_signs_up_spec.rb +21 -0
  31. data/lib/generators/clearance/specs/templates/integration/clearance/visitor_updates_password_spec.rb +47 -0
  32. data/lib/generators/clearance/specs/templates/support/action_mailer.rb +3 -0
  33. data/lib/generators/clearance/specs/templates/support/clearance.rb +1 -0
  34. data/lib/generators/clearance/specs/templates/support/factory_girl.rb +5 -0
  35. data/lib/generators/clearance/specs/templates/support/integration.rb +4 -0
  36. data/lib/generators/clearance/specs/templates/support/integration/action_mailer_helpers.rb +19 -0
  37. data/lib/generators/clearance/specs/templates/support/integration/clearance_helpers.rb +49 -0
  38. data/lib/generators/clearance/views/USAGE +15 -0
  39. data/lib/generators/clearance/views/views_generator.rb +23 -2
  40. data/spec/controllers/passwords_controller_spec.rb +1 -2
  41. data/spec/spec_helper.rb +5 -3
  42. metadata +30 -35
  43. data/features/engine/visitor_resets_password.feature +0 -34
  44. data/features/engine/visitor_signs_in.feature +0 -33
  45. data/features/engine/visitor_signs_out.feature +0 -12
  46. data/features/engine/visitor_signs_up.feature +0 -17
  47. data/features/integration.feature +0 -50
  48. data/features/step_definitions/engine/clearance_steps.rb +0 -124
  49. data/lib/generators/clearance/features/features_generator.rb +0 -8
  50. data/lib/generators/clearance/install/templates/db/migrate/upgrade_clearance_to_diesel.rb +0 -37
@@ -1,9 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clearance (1.0.0.rc2)
4
+ clearance (1.0.0.rc3)
5
5
  bcrypt-ruby
6
- diesel (= 0.1.5)
7
6
  rails (>= 3.0)
8
7
 
9
8
  GEM
@@ -69,8 +68,6 @@ GEM
69
68
  cucumber (>= 1.1.0)
70
69
  nokogiri (>= 1.5.0)
71
70
  database_cleaner (0.8.0)
72
- diesel (0.1.5)
73
- railties
74
71
  diff-lcs (1.1.3)
75
72
  erubis (2.7.0)
76
73
  factory_girl (3.5.0)
@@ -152,7 +149,7 @@ GEM
152
149
  thor (0.15.4)
153
150
  tilt (1.3.3)
154
151
  timecop (0.3.5)
155
- treetop (1.4.10)
152
+ treetop (1.4.11)
156
153
  polyglot
157
154
  polyglot (>= 0.3.1)
158
155
  tzinfo (0.3.33)
data/NEWS.md CHANGED
@@ -3,7 +3,7 @@ New for 1.0.0:
3
3
  * Change default password strategy to BCrypt.
4
4
  * Provide BCryptMigrationFromSHA1 password strategy to help people migrate from
5
5
  SHA1 (the old default password strategy) to BCrypt (the new default).
6
- * Require Ruby 1.9.2.
6
+ * Require > Ruby 1.9.
7
7
  * A revamped, more descriptive README.
8
8
  * More extension points in more controllers.
9
9
  * The email, encrypted_password, and remember_token fields of the users
@@ -14,6 +14,9 @@ New for 1.0.0:
14
14
  * Add a fake password strategy, which is useful when writing tests.
15
15
  * Remove deprecated methods on User: remember_me!, generate_random_code,
16
16
  password_required?.
17
+ * Improve security when changing password.
18
+ * Replace Cucumber feature generator with RSpec + Capybara.
19
+ * Remove Diesel dependency.
17
20
 
18
21
  New for 0.16.2:
19
22
 
data/README.md CHANGED
@@ -4,9 +4,9 @@ Clearance
4
4
  [![Build Status](https://secure.travis-ci.org/thoughtbot/clearance.png)](http://travis-ci.org/thoughtbot/clearance?branch=master)
5
5
  [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/thoughtbot/clearance)
6
6
 
7
- Rails authentication & authorization with email & password.
7
+ Rails authentication with email & password.
8
8
 
9
- Clearance was extracted out of [Airbrake](http://airbrakeapp.com/).
9
+ Clearance was extracted out of [Airbrake](http://airbrake.io/).
10
10
  It is intended to be small, simple, well-tested, and easy to override defaults.
11
11
 
12
12
  Use [Github Issues](/thoughtbot/clearance/issues) for help.
@@ -280,24 +280,24 @@ You can write a custom password strategy that has two instance methods:
280
280
  config.password_strategy = CustomPasswordStrategy
281
281
  end
282
282
 
283
- Optional Cucumber features
283
+ Optional Integration tests
284
284
  --------------------------
285
285
 
286
- Clearance's Cucumber features are dependent on:
286
+ Clearance's integration tests are dependent on:
287
287
 
288
- * Cucumber
289
288
  * Capybara
290
289
  * RSpec
291
290
  * Factory Girl
292
291
 
293
- As your app evolves, you want to know that authentication still works. If you've
294
- installed [Cucumber](http://cukes.info) into your app:
292
+ As your app evolves, you want to know that authentication still works. We include support for RSpec integration tests.
295
293
 
296
- rails generate cucumber:install
294
+ If you've installed [RSpec](https://github.com/rspec/rspec) in your app:
297
295
 
298
- Then, you can use the Clearance features generator:
296
+ rails generate rspec:install
299
297
 
300
- rails generate clearance:features
298
+ Then, you can use the Clearance specs generator:
299
+
300
+ rails generate clearance:specs
301
301
 
302
302
  Edit your Gemfile to include:
303
303
 
data/Rakefile CHANGED
@@ -5,7 +5,6 @@ require 'bundler/setup'
5
5
  require 'bundler/gem_tasks'
6
6
 
7
7
  require 'rake'
8
- require 'diesel/tasks'
9
8
  require 'cucumber/rake/task'
10
9
  require 'rspec/core/rake_task'
11
10
  require 'appraisal'
@@ -9,11 +9,8 @@ class Clearance::PasswordsController < ApplicationController
9
9
  if user = find_user_for_create
10
10
  user.forgot_password!
11
11
  ::ClearanceMailer.change_password(user).deliver
12
- render :template => 'passwords/create'
13
- else
14
- flash_failure_after_create
15
- render :template => 'passwords/new'
16
12
  end
13
+ render :template => 'passwords/create'
17
14
  end
18
15
 
19
16
  def edit
@@ -62,12 +59,6 @@ class Clearance::PasswordsController < ApplicationController
62
59
  :default => 'Please double check the URL or try submitting the form again.')
63
60
  end
64
61
 
65
- def flash_failure_after_create
66
- flash.now[:notice] = translate(:unknown_email,
67
- :scope => [:clearance, :controllers, :passwords],
68
- :default => 'Unknown email.')
69
- end
70
-
71
62
  def flash_failure_after_update
72
63
  flash.now[:notice] = translate(:blank_password,
73
64
  :scope => [:clearance, :controllers, :passwords],
@@ -23,7 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.required_ruby_version = Gem::Requirement.new('>= 1.9.2')
24
24
 
25
25
  s.add_dependency 'bcrypt-ruby'
26
- s.add_dependency 'diesel', '0.1.5'
27
26
  s.add_dependency 'rails', '>= 3.0'
28
27
  s.add_development_dependency 'appraisal', '0.4.1'
29
28
  s.add_development_dependency 'aruba', '0.4.11'
@@ -0,0 +1,65 @@
1
+ Feature: add migrations to the project
2
+
3
+ Background:
4
+ Given I have a project with clearance
5
+ And I run `bundle install --local`
6
+
7
+ Scenario: Users table does not exist
8
+ And I successfully run `bundle exec rails generate clearance:install`
9
+ And I successfully run `ls db/migrate`
10
+ Then the output should contain:
11
+ """
12
+ create_users.rb
13
+ """
14
+
15
+ Scenario: Users table without clearance fields exists in the database
16
+ When I write to "db/migrate/001_create_users.rb" with:
17
+ """
18
+ class CreateUsers < ActiveRecord::Migration
19
+ def self.up
20
+ create_table(:users) do |t|
21
+ t.string :email
22
+ t.string :name
23
+ end
24
+ end
25
+ def self.down
26
+ end
27
+ end
28
+ """
29
+ And I successfully run `bundle exec rake db:migrate --trace`
30
+ And I successfully run `bundle exec rails generate clearance:install`
31
+ And I successfully run `ls db/migrate`
32
+ Then the output should contain:
33
+ """
34
+ add_clearance_to_users.rb
35
+ """
36
+
37
+ Scenario: Users table with clearance fields exists in the database
38
+ When I write to "db/migrate/001_create_users.rb" with:
39
+ """
40
+ class CreateUsers < ActiveRecord::Migration
41
+ def self.up
42
+ create_table :users do |t|
43
+ t.timestamps :null => false
44
+ t.string :email, :null => false
45
+ t.string :encrypted_password, :limit => 128, :null => false
46
+ t.string :confirmation_token, :limit => 128
47
+ t.string :remember_token, :limit => 128, :null => false
48
+ end
49
+
50
+ add_index :users, :email
51
+ add_index :users, :remember_token
52
+ end
53
+
54
+ def self.down
55
+ drop_table :users
56
+ end
57
+ end
58
+ """
59
+ And I successfully run `bundle exec rake db:migrate --trace`
60
+ And I successfully run `bundle exec rails generate clearance:install`
61
+ And I successfully run `ls db/migrate`
62
+ Then the output should not contain:
63
+ """
64
+ add_clearance_to_users.rb
65
+ """
@@ -0,0 +1,21 @@
1
+ Feature: generate rspec integration tests with application
2
+
3
+ Background:
4
+ Given I have a project with clearance and the following gems:
5
+ | gem |
6
+ | capybara |
7
+ | rspec-rails |
8
+ | factory_girl_rails |
9
+ | database_cleaner |
10
+ And I run `bundle install --local`
11
+ And I successfully run `bundle exec rails generate rspec:install`
12
+ And I successfully run `bundle exec rails generate clearance:specs`
13
+
14
+ Scenario: generate a Rails app, run the generators, and run the tests
15
+ And I successfully run `bundle exec rails generate clearance:install`
16
+ Then the output should contain "Next steps"
17
+ When I successfully run `bundle exec rake db:migrate --trace`
18
+ And I successfully run `bundle exec rspec`
19
+ Then the output should contain "Finished"
20
+ And the output should not contain "Failed examples"
21
+ And the output should not contain "Could not find generator"
@@ -1,3 +1,24 @@
1
+ When "I have a project with clearance and the following gems:" do |table|
2
+ step "I have a project with clearance"
3
+
4
+ table.map_column!('gem') do |gem|
5
+ step %Q{ And I add the "#{gem}" gem }
6
+ end
7
+ end
8
+
9
+ When "I have a project with clearance" do
10
+ step "I successfully run `bundle exec rails new testapp`"
11
+
12
+ steps %Q{
13
+ And I cd to "testapp"
14
+ And I remove the file "public/index.html"
15
+ And I remove the file "app/views/layouts/application.html.erb"
16
+ And I configure ActionMailer to use "localhost" as a host
17
+ And I configure a root route
18
+ And I add the "clearance" gem from this project
19
+ }
20
+ end
21
+
1
22
  When /^I configure ActionMailer to use "([^"]+)" as a host$/ do |host|
2
23
  mailer_config = "config.action_mailer.default_url_options = { :host => '#{host}' }"
3
24
  path = 'config/application.rb'
@@ -0,0 +1,7 @@
1
+ When /^I add the "([^"]*)" gem$/ do |gem_name|
2
+ append_to_file('Gemfile', %{\ngem "#{gem_name}"\n})
3
+ end
4
+
5
+ When /^I add the "([^"]*)" gem from this project$/ do |gem_name|
6
+ append_to_file('Gemfile', %{\ngem "#{gem_name}", :path => "../../.."\n})
7
+ end
@@ -1,35 +1,25 @@
1
- # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
- # It is recommended to regenerate this file in the future when you upgrade to a
3
- # newer version of cucumber-rails. Consider adding your own code to a new file
4
- # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
- # files.
6
-
7
1
  ENV['RAILS_ENV'] ||= 'test'
8
2
 
9
3
  PROJECT_ROOT = File.expand_path('../../..', __FILE__)
10
4
  $LOAD_PATH << File.join(PROJECT_ROOT, 'lib')
11
5
 
12
6
  require 'rails/all'
7
+ require 'rails/test_help'
13
8
 
14
9
  Bundler.require
15
10
 
16
- require 'diesel/testing'
17
- require 'diesel/testing/integration'
18
- require 'cucumber/rails/application'
11
+ require 'aruba/cucumber'
12
+ require 'clearance/testing/application'
19
13
  require 'cucumber/rails/action_controller'
20
- require 'rails/test_help'
21
- require 'cucumber/rails/world'
22
- require 'cucumber/rails/hooks'
14
+ require 'cucumber/rails/application'
23
15
  require 'cucumber/rails/capybara'
16
+ require 'cucumber/rails/hooks'
17
+ require 'cucumber/rails/world'
24
18
 
25
- # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
26
- # order to ease the transition to Capybara we set the default here. If you'd
27
- # prefer to use XPath just remove this line and adjust any selectors in your
28
- # steps to use the XPath syntax.
19
+ ActionController::Base.allow_rescue = false
29
20
  Capybara.default_selector = :css
30
21
  Capybara.save_and_open_page_path = 'tmp'
31
-
32
- ActionController::Base.allow_rescue = false
22
+ Clearance::Testing::Application.initialize!
33
23
 
34
24
  begin
35
25
  DatabaseCleaner.strategy = :transaction
@@ -1,9 +1,8 @@
1
1
  PATH
2
- remote: /Users/croaky/dev/clearance
2
+ remote: /Users/harlow/Sites/clearance
3
3
  specs:
4
4
  clearance (1.0.0.rc2)
5
5
  bcrypt-ruby
6
- diesel (= 0.1.5)
7
6
  rails (>= 3.0)
8
7
 
9
8
  GEM
@@ -69,8 +68,6 @@ GEM
69
68
  cucumber (>= 1.1.0)
70
69
  nokogiri (>= 1.5.0)
71
70
  database_cleaner (0.8.0)
72
- diesel (0.1.5)
73
- railties
74
71
  diff-lcs (1.1.3)
75
72
  erubis (2.6.6)
76
73
  abstract (>= 1.0.0)
@@ -1,9 +1,8 @@
1
1
  PATH
2
- remote: /Users/croaky/dev/clearance
2
+ remote: /Users/harlow/Sites/clearance
3
3
  specs:
4
4
  clearance (1.0.0.rc2)
5
5
  bcrypt-ruby
6
- diesel (= 0.1.5)
7
6
  rails (>= 3.0)
8
7
 
9
8
  GEM
@@ -70,8 +69,6 @@ GEM
70
69
  cucumber (>= 1.1.0)
71
70
  nokogiri (>= 1.5.0)
72
71
  database_cleaner (0.8.0)
73
- diesel (0.1.5)
74
- railties
75
72
  diff-lcs (1.1.3)
76
73
  erubis (2.7.0)
77
74
  factory_girl (3.5.0)
@@ -1,9 +1,8 @@
1
1
  PATH
2
- remote: /Users/croaky/dev/clearance
2
+ remote: /Users/harlow/Sites/clearance
3
3
  specs:
4
4
  clearance (1.0.0.rc2)
5
5
  bcrypt-ruby
6
- diesel (= 0.1.5)
7
6
  rails (>= 3.0)
8
7
 
9
8
  GEM
@@ -69,8 +68,6 @@ GEM
69
68
  cucumber (>= 1.1.0)
70
69
  nokogiri (>= 1.5.0)
71
70
  database_cleaner (0.8.0)
72
- diesel (0.1.5)
73
- railties
74
71
  diff-lcs (1.1.3)
75
72
  erubis (2.7.0)
76
73
  factory_girl (3.5.0)
@@ -1,8 +1,3 @@
1
- require 'clearance'
2
-
3
- Clearance.configure do |config|
4
- end
5
-
6
1
  class ApplicationController < ActionController::Base
7
2
  include Clearance::Authentication
8
3
 
@@ -10,7 +5,3 @@ class ApplicationController < ActionController::Base
10
5
  render :text => '', :layout => 'application'
11
6
  end
12
7
  end
13
-
14
- class User < ActiveRecord::Base
15
- include Clearance::User
16
- end
@@ -0,0 +1,46 @@
1
+ require 'rails/all'
2
+
3
+ module Clearance
4
+ module Testing
5
+ APP_ROOT = File.expand_path('..', __FILE__).freeze
6
+
7
+ class Application < Rails::Application
8
+ config.encoding = "utf-8"
9
+ config.action_mailer.default_url_options = { :host => 'localhost' }
10
+
11
+ if Rails::VERSION::MAJOR >= 3 && Rails::VERSION::MINOR >= 1
12
+ config.paths['config/database'] = "#{APP_ROOT}/config/database.yml"
13
+ config.paths['config/routes'] << "#{APP_ROOT}/config/routes.rb"
14
+ config.paths['app/controllers'] << "#{APP_ROOT}/app/controllers"
15
+ config.paths['app/views'] << "#{APP_ROOT}/app/views"
16
+ config.paths['log'] = "tmp/log/development.log"
17
+ config.assets.enabled = true
18
+ else
19
+ config.paths.config.database = "#{APP_ROOT}/config/database.yml"
20
+ config.paths.config.routes << "#{APP_ROOT}/config/routes.rb"
21
+ config.paths.app.controllers << "#{APP_ROOT}/app/controllers"
22
+ config.paths.app.views << "#{APP_ROOT}/app/views"
23
+ config.paths.log = "tmp/log"
24
+ end
25
+
26
+ config.cache_classes = true
27
+ config.whiny_nils = true
28
+ config.consider_all_requests_local = true
29
+ config.action_controller.perform_caching = false
30
+ config.action_dispatch.show_exceptions = false
31
+ config.action_controller.allow_forgery_protection = false
32
+ config.action_mailer.delivery_method = :test
33
+ config.active_support.deprecation = :stderr
34
+ config.secret_token = "SECRET_TOKEN_IS_MIN_30_CHARS_LONG"
35
+
36
+ def require_environment!
37
+ initialize!
38
+ end
39
+
40
+ def initialize!
41
+ FileUtils.mkdir_p(Rails.root.join("db").to_s)
42
+ super unless @initialized
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,11 @@
1
+ development:
2
+ adapter: sqlite3
3
+ database: db/development.sqlite3
4
+ pool: 5
5
+ timeout: 5000
6
+
7
+ test:
8
+ adapter: sqlite3
9
+ database: db/test.sqlite3
10
+ pool: 5
11
+ timeout: 5000
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ root :to => "application#show"
3
+ end