clearance 0.12.0 → 0.13.0

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 (39) hide show
  1. data/Appraisals +2 -7
  2. data/CHANGELOG.md +9 -1
  3. data/CONTRIBUTING.md +38 -0
  4. data/Gemfile +2 -10
  5. data/Gemfile.lock +45 -49
  6. data/LICENSE +1 -1
  7. data/README.md +122 -13
  8. data/Rakefile +1 -1
  9. data/VERSION +1 -1
  10. data/app/views/sessions/_form.html.erb +13 -0
  11. data/app/views/sessions/new.html.erb +1 -13
  12. data/clearance.gemspec +7 -2
  13. data/features/engine/visitor_resets_password.feature +11 -23
  14. data/features/engine/visitor_signs_in.feature +6 -14
  15. data/features/engine/visitor_signs_out.feature +1 -1
  16. data/features/engine/visitor_signs_up.feature +6 -16
  17. data/features/integration.feature +0 -2
  18. data/features/step_definitions/engine/clearance_steps.rb +72 -62
  19. data/features/support/env.rb +2 -2
  20. data/gemfiles/3.0.9.gemfile +5 -10
  21. data/gemfiles/3.0.9.gemfile.lock +28 -33
  22. data/gemfiles/3.1.0.gemfile +13 -0
  23. data/gemfiles/3.1.0.gemfile.lock +187 -0
  24. data/lib/clearance.rb +1 -0
  25. data/lib/clearance/configuration.rb +2 -1
  26. data/lib/clearance/password_strategies.rb +5 -0
  27. data/lib/clearance/password_strategies/sha1.rb +46 -0
  28. data/lib/clearance/user.rb +10 -38
  29. data/lib/generators/clearance/features/features_generator.rb +0 -10
  30. data/spec/models/clearance_user_spec.rb +33 -0
  31. data/spec/models/sha1_spec.rb +43 -0
  32. data/spec/models/user_spec.rb +13 -21
  33. metadata +106 -85
  34. data/features/step_definitions/web_steps.rb +0 -211
  35. data/features/support/appraisal.rb +0 -18
  36. data/features/support/paths.rb +0 -22
  37. data/features/support/selectors.rb +0 -39
  38. data/gemfiles/3.1.0.rc4.gemfile +0 -23
  39. data/gemfiles/3.1.0.rc4.gemfile.lock +0 -216
data/Appraisals CHANGED
@@ -2,11 +2,6 @@ appraise "3.0.9" do
2
2
  gem "rails", "3.0.9"
3
3
  end
4
4
 
5
- appraise "3.1.0.rc4" do
6
- gem "rails", "3.1.0.rc4"
7
- gem 'sass-rails'
8
- gem 'coffee-script'
9
- gem 'uglifier'
10
- gem 'jquery-rails'
11
- gem 'turn'
5
+ appraise "3.1.0" do
6
+ gem "rails", "3.1.0"
12
7
  end
data/CHANGELOG.md CHANGED
@@ -1,8 +1,16 @@
1
+ 0.13.0
2
+ -------------------
3
+
4
+ * [#170] In Clearance's optional generated features, use pure Capybara instead of depending on Cucumber's removed web_steps, paths, and selectors. (Dan Croak)
5
+ * [#167] Extract SHA-1-specific code out of `User` into `PasswordStrategies` module. (Vladimir Andrijevik)
6
+ * [#164] Extract sign in form so that other methods can be added easily. (Subhash Chandra)
7
+ * [#165] Test against Rails 3.1. (Dan Croak) Required upgrades to Diesel and Appraisal. (Dan Croak, Mike Burns, Chad Pytel)
8
+ * [#160] Improved README documentation for overrides. (Dan Croak)
9
+
1
10
  0.12.0
2
11
  -------------------
3
12
 
4
13
  * [#129] Denying access redirects to root_url when signed in, sign_in_url when signed out. (Dan Croak)
5
- * New configuration setting: denied_access_url. (Dan Croak)
6
14
  * Using flash :notice key everywhere now instead of :success and :failure. More in line with Rails conventions. (Dan Croak)
7
15
  * [#149] redirect_back_or on sign up. (Dan Croak)
8
16
  * [#147] Resetting password no longer redirects to sign in page. It displays a message telling them to look for an email. (Dan Croak)
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,38 @@
1
+ We love pull requests. Here's a quick guide:
2
+
3
+ 1. Fork the repo.
4
+
5
+ 2. Run the tests. We only take pull requests with passing tests, and it's great
6
+ to know that you have a clean slate: `bundle && rake`
7
+
8
+ 3. Add a test for your change. Only refactoring and documentation changes
9
+ require no new tests. If you are adding functionality or fixing a bug, we need
10
+ a test!
11
+
12
+ 4. Make the test pass.
13
+
14
+ 5. Push to your fork and submit a pull request.
15
+
16
+
17
+ At this point you're waiting on us. We like to at least comment on, if not
18
+ accept, pull requests within three business days (and, typically, one business
19
+ day). We may suggest some changes or improvements or alternatives.
20
+
21
+ Some things that will increase the chance that your pull request is accepted,
22
+ taken straight from the Ruby on Rails guide:
23
+
24
+ * Use Rails idioms and helpers
25
+ * Include tests that fail without your code, and pass with it
26
+ * Update the documentation, the surrounding one, examples elsewhere, guides,
27
+ whatever is affected by your contribution
28
+
29
+ Syntax:
30
+
31
+ * Two spaces, no tabs.
32
+ * No trailing whitespace. Blank lines should not have any space.
33
+ * Prefer &&/|| over and/or.
34
+ * MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
35
+ * a = b and not a=b.
36
+ * Follow the conventions you see used in the source already.
37
+
38
+ And in case we didn't emphasize it enough: we love tests!
data/Gemfile CHANGED
@@ -1,17 +1,9 @@
1
1
  source "http://rubygems.org"
2
+ gemspec
2
3
 
3
- gem "rails", "3.0.9"
4
- gem "sqlite3"
5
-
6
- gem "diesel", :git => "git://github.com/thoughtbot/diesel.git"
7
-
8
- gem "cucumber-rails", '1.0.0'
9
- gem "capybara", "1.0.0"
4
+ gem "capybara", "~> 1.0.0"
10
5
  gem "factory_girl_rails"
11
6
  gem "shoulda-matchers", :git => "git://github.com/thoughtbot/shoulda-matchers.git"
12
7
  gem "database_cleaner"
13
- gem "rspec-rails", "~> 2.6.0"
14
8
  gem "launchy"
15
- gem "mocha"
16
- gem "appraisal", :git => "git://github.com/thoughtbot/appraisal.git"
17
9
  gem "aruba", "~> 0.4.2"
data/Gemfile.lock CHANGED
@@ -1,25 +1,16 @@
1
- GIT
2
- remote: git://github.com/thoughtbot/appraisal.git
3
- revision: f8029181543b4bc4bdea03735a3b1e558fd66501
4
- specs:
5
- appraisal (0.3.5)
6
- aruba (~> 0.4.2)
7
- bundler
8
- rake
9
-
10
- GIT
11
- remote: git://github.com/thoughtbot/diesel.git
12
- revision: f68a990573e2684bb4645a90876603de0a772b69
13
- specs:
14
- diesel (0.1.4)
15
- railties
16
-
17
1
  GIT
18
2
  remote: git://github.com/thoughtbot/shoulda-matchers.git
19
- revision: a922b8ec38b65ae3274f194e90eaff6ac642d0b1
3
+ revision: 5190a39bba699d4989c2500c98622b505e2de828
20
4
  specs:
21
5
  shoulda-matchers (1.0.0.beta3)
22
6
 
7
+ PATH
8
+ remote: .
9
+ specs:
10
+ clearance (0.12.0)
11
+ diesel (~> 0.1.5)
12
+ rails (>= 3.0)
13
+
23
14
  GEM
24
15
  remote: http://rubygems.org/
25
16
  specs:
@@ -50,54 +41,58 @@ GEM
50
41
  activemodel (= 3.0.9)
51
42
  activesupport (= 3.0.9)
52
43
  activesupport (3.0.9)
44
+ addressable (2.2.6)
45
+ appraisal (0.3.8)
46
+ bundler
47
+ rake
53
48
  arel (2.0.10)
54
- aruba (0.4.3)
49
+ aruba (0.4.6)
55
50
  bcat (>= 0.6.1)
56
- childprocess (>= 0.1.9)
57
- cucumber (>= 0.10.7)
51
+ childprocess (>= 0.2.0)
52
+ cucumber (>= 1.0.2)
58
53
  rdiscount (>= 1.6.8)
59
54
  rspec (>= 2.6.0)
60
55
  bcat (0.6.1)
61
56
  rack (~> 1.0)
62
57
  builder (2.1.2)
63
- capybara (1.0.0)
58
+ capybara (1.0.1)
64
59
  mime-types (>= 1.16)
65
60
  nokogiri (>= 1.3.3)
66
61
  rack (>= 1.0.0)
67
62
  rack-test (>= 0.5.4)
68
- selenium-webdriver (~> 0.2.0)
63
+ selenium-webdriver (~> 2.0)
69
64
  xpath (~> 0.1.4)
70
- childprocess (0.1.9)
65
+ childprocess (0.2.2)
71
66
  ffi (~> 1.0.6)
72
- configuration (1.3.1)
73
- cucumber (1.0.0)
67
+ cucumber (1.0.2)
74
68
  builder (>= 2.1.2)
75
69
  diff-lcs (>= 1.1.2)
76
- gherkin (~> 2.4.1)
70
+ gherkin (~> 2.4.5)
77
71
  json (>= 1.4.6)
78
72
  term-ansicolor (>= 1.0.5)
79
- cucumber-rails (1.0.0)
73
+ cucumber-rails (1.0.2)
80
74
  capybara (>= 1.0.0)
81
75
  cucumber (~> 1.0.0)
82
- nokogiri (>= 1.4.4)
83
- rack-test (>= 0.5.7)
76
+ nokogiri (>= 1.4.6)
84
77
  database_cleaner (0.6.7)
85
- diff-lcs (1.1.2)
78
+ diesel (0.1.5)
79
+ railties
80
+ diff-lcs (1.1.3)
86
81
  erubis (2.6.6)
87
82
  abstract (>= 1.0.0)
88
- factory_girl (1.3.3)
89
- factory_girl_rails (1.0.1)
90
- factory_girl (~> 1.3)
83
+ factory_girl (2.0.5)
84
+ factory_girl_rails (1.1.0)
85
+ factory_girl (~> 2.0.0)
91
86
  railties (>= 3.0.0)
92
87
  ffi (1.0.9)
93
- gherkin (2.4.1)
88
+ gherkin (2.4.16)
94
89
  json (>= 1.4.6)
95
90
  i18n (0.5.0)
96
- json (1.5.3)
97
- json_pure (1.5.3)
98
- launchy (0.4.0)
99
- configuration (>= 0.0.5)
100
- rake (>= 0.8.1)
91
+ json (1.5.4)
92
+ json_pure (1.5.4)
93
+ spruz (~> 0.2.8)
94
+ launchy (2.0.5)
95
+ addressable (~> 2.2.6)
101
96
  mail (2.2.19)
102
97
  activesupport (>= 2.3.6)
103
98
  i18n (>= 0.4.0)
@@ -105,7 +100,7 @@ GEM
105
100
  treetop (~> 1.4.8)
106
101
  mime-types (1.16)
107
102
  mocha (0.9.12)
108
- nokogiri (1.4.6)
103
+ nokogiri (1.5.0)
109
104
  polyglot (0.3.1)
110
105
  rack (1.2.3)
111
106
  rack-mount (0.6.14)
@@ -143,13 +138,14 @@ GEM
143
138
  railties (~> 3.0)
144
139
  rspec (~> 2.6.0)
145
140
  rubyzip (0.9.4)
146
- selenium-webdriver (0.2.2)
147
- childprocess (>= 0.1.9)
141
+ selenium-webdriver (2.5.0)
142
+ childprocess (>= 0.2.1)
148
143
  ffi (>= 1.0.7)
149
144
  json_pure
150
145
  rubyzip
151
- sqlite3 (1.3.3)
152
- term-ansicolor (1.0.5)
146
+ spruz (0.2.13)
147
+ sqlite3 (1.3.4)
148
+ term-ansicolor (1.0.6)
153
149
  thor (0.14.6)
154
150
  treetop (1.4.9)
155
151
  polyglot (>= 0.3.1)
@@ -161,16 +157,16 @@ PLATFORMS
161
157
  ruby
162
158
 
163
159
  DEPENDENCIES
164
- appraisal!
160
+ appraisal (~> 0.3.8)
165
161
  aruba (~> 0.4.2)
166
- capybara (= 1.0.0)
167
- cucumber-rails (= 1.0.0)
162
+ bundler (~> 1.0.0)
163
+ capybara (~> 1.0.0)
164
+ clearance!
165
+ cucumber-rails (~> 1.0.2)
168
166
  database_cleaner
169
- diesel!
170
167
  factory_girl_rails
171
168
  launchy
172
169
  mocha
173
- rails (= 3.0.9)
174
170
  rspec-rails (~> 2.6.0)
175
171
  shoulda-matchers!
176
172
  sqlite3
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2008 thoughtbot, inc.
3
+ Copyright (c) 2008-2011 thoughtbot, inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -59,13 +59,53 @@ the current_user method.
59
59
  current_user.articles
60
60
  end
61
61
 
62
- Customizing
63
- -----------
62
+ If you want to know whether the current user is signed in or out, you can use
63
+ these methods in controllers, views, or helpers:
64
64
 
65
- Clearance is intended to be small, simple, well-tested, and easy to extend.
65
+ signed_in?
66
+ signed_out?
66
67
 
67
- If you ever need to change the logic in any of the four provided controllers,
68
- subclass the Clearance controller. You don't need to do this by default.
68
+ Typically, you want to have something like this in your app, maybe in a layout:
69
+
70
+ <% if signed_in? %>
71
+ <%= current_user.email %>
72
+ <%= link_to "Sign out", sign_out_path, :method => :delete %>
73
+ <% else %>
74
+ <%= link_to "Sign in", sign_in_path %>
75
+ <% end %>
76
+
77
+ If you ever want to authenticate the user some place other than sessions/new,
78
+ maybe in an API:
79
+
80
+ User.authenticate("email@example.com", "password")
81
+
82
+ Clearance will deliver one email on your app's behalf: when a user resets their password. Therefore, you should change the default email address that email comes from:
83
+
84
+ # config/initializers/clearance.rb
85
+ Clearance.configure do |config|
86
+ config.mailer_sender = "me@example.com"
87
+ end
88
+
89
+ Overriding defaults
90
+ -------------------
91
+
92
+ Clearance is intended to be small, simple, well-tested, and easy to override defaults.
93
+
94
+ Overriding routes
95
+ -----------------
96
+
97
+ See [config/routes.rb](https://github.com/thoughtbot/clearance/blob/master/config/routes.rb) for the default behavior.
98
+
99
+ To override a Clearance route, redefine it:
100
+
101
+ resource :session, :controller => 'sessions'
102
+
103
+ Overriding controllers
104
+ ----------------------
105
+
106
+ See [app/controllers/clearance](https://github.com/thoughtbot/clearance/tree/master/app/controllers/clearance) for the default behavior.
107
+
108
+ To override a Clearance controller, subclass it:
69
109
 
70
110
  class SessionsController < Clearance::SessionsController
71
111
  def new
@@ -77,24 +117,88 @@ subclass the Clearance controller. You don't need to do this by default.
77
117
  end
78
118
  end
79
119
 
80
- and add your route in config/routes.rb:
120
+ You may want to override entire actions:
81
121
 
82
- resource :session, :controller => 'sessions'
122
+ def new
123
+ end
124
+
125
+ Or, you may want to override private methods that actions use:
126
+
127
+ url_after_create
128
+ url_after_update
129
+ url_after_destroy
130
+ flash_failure_after_create
131
+ flash_failure_after_update
132
+ flash_failure_when_forbidden
133
+ forbid_missing_token
134
+ forbid_non_existent_user
135
+
136
+ Overriding translations
137
+ -----------------------
138
+
139
+ All flash messages and email subject lines are stored in [i18n translations](http://guides.rubyonrails.org/i18n.html). Override them like any other translation.
140
+
141
+ Overriding views
142
+ ----------------
83
143
 
84
- See config/routes.rb for all the routes Clearance provides.
144
+ See [app/views](https://github.com/thoughtbot/clearance/tree/master/app/views) for the default behavior.
85
145
 
86
- Actions that redirect (create, update, and destroy) in Clearance controllers
87
- can be overridden by re-defining url_after_(action) methods as seen above.
146
+ To override those **views**, create them in your own `app/views` directory.
88
147
 
89
- Clearance is an engine, so it provides views for you. If you want to customize those views, there is a handy shortcut to copy the views into your app:
148
+ There is a shortcut to copy all Clearance views into your app:
90
149
 
91
150
  rails generate clearance:views
92
151
 
152
+ Overriding the model
153
+ --------------------
154
+
155
+ If you want to override the **model** behavior, you can include sub-modules of `Clearance::User`:
156
+
157
+ extend Clearance::User::ClassMethods
158
+ include Clearance::User::Validations
159
+ include Clearance::User::Callbacks
160
+
161
+ `ClassMethods` contains the `User.authenticate(email, password)` method.
162
+
163
+ `Validations` contains validations for email and password.
164
+
165
+ `Callbacks` contains `ActiveRecord` callbacks downcasing the email and generating a remember token.
166
+
167
+ Overriding the password strategy
168
+ --------------------------------
169
+
170
+ By default, Clearance uses SHA1 encryption of the user's password. You can provide your own password strategy by creating a module that conforms to an API of two instance methods:
171
+
172
+ def authenticated?
173
+ end
174
+
175
+ def encrypt_password
176
+ end
177
+
178
+ See [lib/clearance/password_strategies/sha1.rb](https://github.com/thoughtbot/clearance/blob/master/lib/clearance/password_strategies/sha1.rb) for the default behavior.
179
+
180
+ Once you have an API-compliant module, load it with:
181
+
182
+ Clearance.configure do |config|
183
+ config.password_strategy = MyPasswordStrategy
184
+ end
185
+
93
186
  Optional Cucumber features
94
187
  --------------------------
95
188
 
96
- As your app evolves, you want to know that authentication still works. If you
97
- use [Cucumber](http://cukes.info), run the Clearance features generator:
189
+ Clearance's Cucumber features are dependent on:
190
+
191
+ * Cucumber
192
+ * Capybara
193
+ * RSpec
194
+ * Factory Girl
195
+
196
+ As your app evolves, you want to know that authentication still works. If you've
197
+ installed [Cucumber](http://cukes.info) into your app:
198
+
199
+ rails generate cucumber:install
200
+
201
+ Then, you can use the Clearance features generator:
98
202
 
99
203
  rails generate clearance:features
100
204
 
@@ -145,6 +249,11 @@ Example:
145
249
  it { should respond_with(:success) }
146
250
  end
147
251
 
252
+ Contributing
253
+ ------------
254
+
255
+ Please see CONTRIBUTING.md for details.
256
+
148
257
  Credits
149
258
  -------
150
259
 
data/Rakefile CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'rubygems'
4
4
  require 'bundler/setup'
5
5
  require 'rake'
6
- require 'rake/gempackagetask'
6
+ require 'rubygems/package_task'
7
7
  require 'cucumber/rake/task'
8
8
  require 'diesel/tasks'
9
9
  require 'rspec/core/rake_task'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.12.0
1
+ 0.13.0
@@ -0,0 +1,13 @@
1
+ <%= form_for :session, :url => session_path do |form| %>
2
+ <div class="text_field">
3
+ <%= form.label :email %>
4
+ <%= form.text_field :email, :type => "email" %>
5
+ </div>
6
+ <div class="text_field">
7
+ <%= form.label :password %>
8
+ <%= form.password_field :password %>
9
+ </div>
10
+ <div class="submit_field">
11
+ <%= form.submit "Sign in" %>
12
+ </div>
13
+ <% end %>