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
@@ -15,27 +15,6 @@ describe User do
15
15
  it { should_not allow_value("foo").for(:email) }
16
16
  it { should_not allow_value("example.com").for(:email) }
17
17
 
18
- it "should initialize salt" do
19
- Factory(:user).salt.should_not be_nil
20
- end
21
-
22
- describe "encrypt password" do
23
- before do
24
- @salt = "salt"
25
- @user = Factory.build(:user, :salt => @salt)
26
- def @user.initialize_salt; end
27
- @user.save!
28
- @password = @user.password
29
-
30
- @user.send(:encrypt, @password)
31
- @expected = Digest::SHA1.hexdigest("--#{@salt}--#{@password}--")
32
- end
33
-
34
- it "should create an encrypted password using SHA1 encryption" do
35
- @user.encrypted_password.should == @expected
36
- end
37
- end
38
-
39
18
  it "should store email in down case" do
40
19
  user = Factory(:user, :email => "John.Doe@example.com")
41
20
  user.email.should == "john.doe@example.com"
@@ -210,4 +189,17 @@ describe User do
210
189
  @user.remember_token.should_not be_nil
211
190
  end
212
191
  end
192
+
193
+ describe "The password setter on a User" do
194
+ let(:password) { "a-password" }
195
+ before { subject.send(:password=, password) }
196
+
197
+ it "sets password to the plain-text password" do
198
+ subject.password.should == password
199
+ end
200
+
201
+ it "also sets encrypted_password" do
202
+ subject.encrypted_password.should_not be_nil
203
+ end
204
+ end
213
205
  end
metadata CHANGED
@@ -1,15 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: clearance
3
- version: !ruby/object:Gem::Version
4
- hash: 47
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.13.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 12
9
- - 0
10
- version: 0.12.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Dan Croak
14
9
  - Mike Burns
15
10
  - Jason Morrison
@@ -23,71 +18,109 @@ authors:
23
18
  autorequire:
24
19
  bindir: bin
25
20
  cert_chain: []
26
-
27
- date: 2011-06-30 00:00:00 -04:00
28
- default_executable:
29
- dependencies:
30
- - !ruby/object:Gem::Dependency
21
+ date: 2011-10-11 00:00:00.000000000Z
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
31
24
  name: rails
32
- prerelease: false
33
- requirement: &id001 !ruby/object:Gem::Requirement
25
+ requirement: &70265408068760 !ruby/object:Gem::Requirement
34
26
  none: false
35
- requirements:
36
- - - ">="
37
- - !ruby/object:Gem::Version
38
- hash: 7
39
- segments:
40
- - 3
41
- - 0
42
- version: "3.0"
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '3.0'
43
31
  type: :runtime
44
- version_requirements: *id001
45
- - !ruby/object:Gem::Dependency
46
- name: diesel
47
32
  prerelease: false
48
- requirement: &id002 !ruby/object:Gem::Requirement
33
+ version_requirements: *70265408068760
34
+ - !ruby/object:Gem::Dependency
35
+ name: diesel
36
+ requirement: &70265408068200 !ruby/object:Gem::Requirement
49
37
  none: false
50
- requirements:
38
+ requirements:
51
39
  - - ~>
52
- - !ruby/object:Gem::Version
53
- hash: 19
54
- segments:
55
- - 0
56
- - 1
57
- - 4
58
- version: 0.1.4
40
+ - !ruby/object:Gem::Version
41
+ version: 0.1.5
59
42
  type: :runtime
60
- version_requirements: *id002
61
- - !ruby/object:Gem::Dependency
62
- name: bundler
63
43
  prerelease: false
64
- requirement: &id003 !ruby/object:Gem::Requirement
44
+ version_requirements: *70265408068200
45
+ - !ruby/object:Gem::Dependency
46
+ name: bundler
47
+ requirement: &70265408067620 !ruby/object:Gem::Requirement
65
48
  none: false
66
- requirements:
49
+ requirements:
67
50
  - - ~>
68
- - !ruby/object:Gem::Version
69
- hash: 23
70
- segments:
71
- - 1
72
- - 0
73
- - 0
51
+ - !ruby/object:Gem::Version
74
52
  version: 1.0.0
75
53
  type: :development
76
- version_requirements: *id003
54
+ prerelease: false
55
+ version_requirements: *70265408067620
56
+ - !ruby/object:Gem::Dependency
57
+ name: appraisal
58
+ requirement: &70265408067060 !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: 0.3.8
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: *70265408067060
67
+ - !ruby/object:Gem::Dependency
68
+ name: cucumber-rails
69
+ requirement: &70265408066600 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: 1.0.2
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: *70265408066600
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec-rails
80
+ requirement: &70265408066020 !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 2.6.0
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: *70265408066020
89
+ - !ruby/object:Gem::Dependency
90
+ name: sqlite3
91
+ requirement: &70265408065580 !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: *70265408065580
100
+ - !ruby/object:Gem::Dependency
101
+ name: mocha
102
+ requirement: &70265408065080 !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ type: :development
109
+ prerelease: false
110
+ version_requirements: *70265408065080
77
111
  description: Rails authentication & authorization with email & password.
78
112
  email: support@thoughtbot.com
79
113
  executables: []
80
-
81
114
  extensions: []
82
-
83
- extra_rdoc_files:
115
+ extra_rdoc_files:
84
116
  - LICENSE
85
117
  - README.md
86
- files:
118
+ files:
87
119
  - .gitignore
88
120
  - .rspec
89
121
  - Appraisals
90
122
  - CHANGELOG.md
123
+ - CONTRIBUTING.md
91
124
  - Gemfile
92
125
  - Gemfile.lock
93
126
  - LICENSE
@@ -103,6 +136,7 @@ files:
103
136
  - app/views/passwords/create.html.erb
104
137
  - app/views/passwords/edit.html.erb
105
138
  - app/views/passwords/new.html.erb
139
+ - app/views/sessions/_form.html.erb
106
140
  - app/views/sessions/new.html.erb
107
141
  - app/views/users/_form.html.erb
108
142
  - app/views/users/new.html.erb
@@ -118,22 +152,20 @@ files:
118
152
  - features/integration.feature
119
153
  - features/step_definitions/configuration_steps.rb
120
154
  - features/step_definitions/engine/clearance_steps.rb
121
- - features/step_definitions/web_steps.rb
122
- - features/support/appraisal.rb
123
155
  - features/support/aruba.rb
124
156
  - features/support/clearance.rb
125
157
  - features/support/env.rb
126
- - features/support/paths.rb
127
- - features/support/selectors.rb
128
158
  - gemfiles/3.0.9.gemfile
129
159
  - gemfiles/3.0.9.gemfile.lock
130
- - gemfiles/3.1.0.rc4.gemfile
131
- - gemfiles/3.1.0.rc4.gemfile.lock
160
+ - gemfiles/3.1.0.gemfile
161
+ - gemfiles/3.1.0.gemfile.lock
132
162
  - init.rb
133
163
  - lib/clearance.rb
134
164
  - lib/clearance/authentication.rb
135
165
  - lib/clearance/configuration.rb
136
166
  - lib/clearance/engine.rb
167
+ - lib/clearance/password_strategies.rb
168
+ - lib/clearance/password_strategies/sha1.rb
137
169
  - lib/clearance/testing.rb
138
170
  - lib/clearance/testing/assertion_error.rb
139
171
  - lib/clearance/testing/deny_access_matcher.rb
@@ -153,45 +185,38 @@ files:
153
185
  - spec/controllers/users_controller_spec.rb
154
186
  - spec/factories.rb
155
187
  - spec/mailers/clearance_mailer_spec.rb
188
+ - spec/models/clearance_user_spec.rb
189
+ - spec/models/sha1_spec.rb
156
190
  - spec/models/user_spec.rb
157
191
  - spec/spec_helper.rb
158
192
  - spec/support/clearance.rb
159
193
  - spec/support/cookies.rb
160
- has_rdoc: true
161
194
  homepage: http://github.com/thoughtbot/clearance
162
195
  licenses: []
163
-
164
196
  post_install_message:
165
- rdoc_options:
197
+ rdoc_options:
166
198
  - --charset=UTF-8
167
- require_paths:
199
+ require_paths:
168
200
  - lib
169
- required_ruby_version: !ruby/object:Gem::Requirement
201
+ required_ruby_version: !ruby/object:Gem::Requirement
170
202
  none: false
171
- requirements:
172
- - - ">="
173
- - !ruby/object:Gem::Version
174
- hash: 3
175
- segments:
176
- - 0
177
- version: "0"
178
- required_rubygems_version: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ! '>='
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
208
  none: false
180
- requirements:
181
- - - ">="
182
- - !ruby/object:Gem::Version
183
- hash: 3
184
- segments:
185
- - 0
186
- version: "0"
209
+ requirements:
210
+ - - ! '>='
211
+ - !ruby/object:Gem::Version
212
+ version: '0'
187
213
  requirements: []
188
-
189
214
  rubyforge_project:
190
- rubygems_version: 1.6.2
215
+ rubygems_version: 1.8.6
191
216
  signing_key:
192
217
  specification_version: 3
193
218
  summary: Rails authentication & authorization with email & password.
194
- test_files:
219
+ test_files:
195
220
  - features/engine/visitor_resets_password.feature
196
221
  - features/engine/visitor_signs_in.feature
197
222
  - features/engine/visitor_signs_out.feature
@@ -199,10 +224,6 @@ test_files:
199
224
  - features/integration.feature
200
225
  - features/step_definitions/configuration_steps.rb
201
226
  - features/step_definitions/engine/clearance_steps.rb
202
- - features/step_definitions/web_steps.rb
203
- - features/support/appraisal.rb
204
227
  - features/support/aruba.rb
205
228
  - features/support/clearance.rb
206
229
  - features/support/env.rb
207
- - features/support/paths.rb
208
- - features/support/selectors.rb
@@ -1,211 +0,0 @@
1
- # TL;DR: YOU SHOULD DELETE THIS FILE
2
- #
3
- # This file was generated by Cucumber-Rails and is only here to get you a head start
4
- # These step definitions are thin wrappers around the Capybara/Webrat API that lets you
5
- # visit pages, interact with widgets and make assertions about page content.
6
- #
7
- # If you use these step definitions as basis for your features you will quickly end up
8
- # with features that are:
9
- #
10
- # * Hard to maintain
11
- # * Verbose to read
12
- #
13
- # A much better approach is to write your own higher level step definitions, following
14
- # the advice in the following blog posts:
15
- #
16
- # * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
17
- # * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
18
- # * http://elabs.se/blog/15-you-re-cuking-it-wrong
19
- #
20
-
21
-
22
- require 'uri'
23
- require 'cgi'
24
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
25
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
26
-
27
- module WithinHelpers
28
- def with_scope(locator)
29
- locator ? within(*selector_for(locator)) { yield } : yield
30
- end
31
- end
32
- World(WithinHelpers)
33
-
34
- # Single-line step scoper
35
- When /^(.*) within ([^:]+)$/ do |step, parent|
36
- with_scope(parent) { When step }
37
- end
38
-
39
- # Multi-line step scoper
40
- When /^(.*) within ([^:]+):$/ do |step, parent, table_or_string|
41
- with_scope(parent) { When "#{step}:", table_or_string }
42
- end
43
-
44
- Given /^(?:|I )am on (.+)$/ do |page_name|
45
- visit path_to(page_name)
46
- end
47
-
48
- When /^(?:|I )go to (.+)$/ do |page_name|
49
- visit path_to(page_name)
50
- end
51
-
52
- When /^(?:|I )press "([^"]*)"$/ do |button|
53
- click_button(button)
54
- end
55
-
56
- When /^(?:|I )follow "([^"]*)"$/ do |link|
57
- click_link(link)
58
- end
59
-
60
- When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
61
- fill_in(field, :with => value)
62
- end
63
-
64
- When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
65
- fill_in(field, :with => value)
66
- end
67
-
68
- # Use this to fill in an entire form with data from a table. Example:
69
- #
70
- # When I fill in the following:
71
- # | Account Number | 5002 |
72
- # | Expiry date | 2009-11-01 |
73
- # | Note | Nice guy |
74
- # | Wants Email? | |
75
- #
76
- # TODO: Add support for checkbox, select og option
77
- # based on naming conventions.
78
- #
79
- When /^(?:|I )fill in the following:$/ do |fields|
80
- fields.rows_hash.each do |name, value|
81
- When %{I fill in "#{name}" with "#{value}"}
82
- end
83
- end
84
-
85
- When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
86
- select(value, :from => field)
87
- end
88
-
89
- When /^(?:|I )check "([^"]*)"$/ do |field|
90
- check(field)
91
- end
92
-
93
- When /^(?:|I )uncheck "([^"]*)"$/ do |field|
94
- uncheck(field)
95
- end
96
-
97
- When /^(?:|I )choose "([^"]*)"$/ do |field|
98
- choose(field)
99
- end
100
-
101
- When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
102
- attach_file(field, File.expand_path(path))
103
- end
104
-
105
- Then /^(?:|I )should see "([^"]*)"$/ do |text|
106
- if page.respond_to? :should
107
- page.should have_content(text)
108
- else
109
- assert page.has_content?(text)
110
- end
111
- end
112
-
113
- Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
114
- regexp = Regexp.new(regexp)
115
-
116
- if page.respond_to? :should
117
- page.should have_xpath('//*', :text => regexp)
118
- else
119
- assert page.has_xpath?('//*', :text => regexp)
120
- end
121
- end
122
-
123
- Then /^(?:|I )should not see "([^"]*)"$/ do |text|
124
- if page.respond_to? :should
125
- page.should have_no_content(text)
126
- else
127
- assert page.has_no_content?(text)
128
- end
129
- end
130
-
131
- Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
132
- regexp = Regexp.new(regexp)
133
-
134
- if page.respond_to? :should
135
- page.should have_no_xpath('//*', :text => regexp)
136
- else
137
- assert page.has_no_xpath?('//*', :text => regexp)
138
- end
139
- end
140
-
141
- Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
142
- with_scope(parent) do
143
- field = find_field(field)
144
- field_value = (field.tag_name == 'textarea') ? field.text : field.value
145
- if field_value.respond_to? :should
146
- field_value.should =~ /#{value}/
147
- else
148
- assert_match(/#{value}/, field_value)
149
- end
150
- end
151
- end
152
-
153
- Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
154
- with_scope(parent) do
155
- field = find_field(field)
156
- field_value = (field.tag_name == 'textarea') ? field.text : field.value
157
- if field_value.respond_to? :should_not
158
- field_value.should_not =~ /#{value}/
159
- else
160
- assert_no_match(/#{value}/, field_value)
161
- end
162
- end
163
- end
164
-
165
- Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
166
- with_scope(parent) do
167
- field_checked = find_field(label)['checked']
168
- if field_checked.respond_to? :should
169
- field_checked.should be_true
170
- else
171
- assert field_checked
172
- end
173
- end
174
- end
175
-
176
- Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
177
- with_scope(parent) do
178
- field_checked = find_field(label)['checked']
179
- if field_checked.respond_to? :should
180
- field_checked.should be_false
181
- else
182
- assert !field_checked
183
- end
184
- end
185
- end
186
-
187
- Then /^(?:|I )should be on (.+)$/ do |page_name|
188
- current_path = URI.parse(current_url).path
189
- if current_path.respond_to? :should
190
- current_path.should == path_to(page_name)
191
- else
192
- assert_equal path_to(page_name), current_path
193
- end
194
- end
195
-
196
- Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
197
- query = URI.parse(current_url).query
198
- actual_params = query ? CGI.parse(query) : {}
199
- expected_params = {}
200
- expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
201
-
202
- if actual_params.respond_to? :should
203
- actual_params.should == expected_params
204
- else
205
- assert_equal expected_params, actual_params
206
- end
207
- end
208
-
209
- Then /^show me the page$/ do
210
- save_and_open_page
211
- end