thoughtbot-clearance 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.textile +5 -0
- data/Rakefile +1 -1
- data/lib/clearance/user.rb +38 -10
- data/shoulda_macros/clearance.rb +14 -14
- metadata +2 -2
data/CHANGELOG.textile
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
h2. 0.6.6 (5/18/2009)
|
2
|
+
|
3
|
+
* [#14] replaced class_eval in Clearance::User with modules. This was needed
|
4
|
+
in a thoughtbot client app so we could write our own validations. (Dan Croak)
|
5
|
+
|
1
6
|
h2. 0.6.5 (5/17/2009)
|
2
7
|
|
3
8
|
* [#6] Make Clearance i18n aware. (Timur Vafin, Marcel Goerner, Eugene Bolshakov, Dan Croak)
|
data/Rakefile
CHANGED
@@ -51,7 +51,7 @@ task :default => ['test:all', 'test:features']
|
|
51
51
|
|
52
52
|
gem_spec = Gem::Specification.new do |gem_spec|
|
53
53
|
gem_spec.name = "clearance"
|
54
|
-
gem_spec.version = "0.6.
|
54
|
+
gem_spec.version = "0.6.6"
|
55
55
|
gem_spec.summary = "Rails authentication with email & password."
|
56
56
|
gem_spec.email = "support@thoughtbot.com"
|
57
57
|
gem_spec.homepage = "http://github.com/thoughtbot/clearance"
|
data/lib/clearance/user.rb
CHANGED
@@ -4,21 +4,49 @@ module Clearance
|
|
4
4
|
module User
|
5
5
|
|
6
6
|
def self.included(model)
|
7
|
-
model.extend
|
7
|
+
model.extend(ClassMethods)
|
8
|
+
|
8
9
|
model.send(:include, InstanceMethods)
|
10
|
+
model.send(:include, AttrAccessible)
|
11
|
+
model.send(:include, AttrAccessor)
|
12
|
+
model.send(:include, Validations)
|
13
|
+
model.send(:include, Callbacks)
|
14
|
+
end
|
9
15
|
|
10
|
-
|
11
|
-
|
12
|
-
|
16
|
+
module AttrAccessible
|
17
|
+
def self.included(model)
|
18
|
+
model.class_eval do
|
19
|
+
attr_accessible :email, :password, :password_confirmation
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
13
23
|
|
14
|
-
|
15
|
-
|
16
|
-
|
24
|
+
module AttrAccessor
|
25
|
+
def self.included(model)
|
26
|
+
model.class_eval do
|
27
|
+
attr_accessor :password, :password_confirmation
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module Validations
|
33
|
+
def self.included(model)
|
34
|
+
model.class_eval do
|
35
|
+
validates_presence_of :email
|
36
|
+
validates_uniqueness_of :email, :case_sensitive => false
|
37
|
+
validates_format_of :email, :with => %r{.+@.+\..+}
|
17
38
|
|
18
|
-
|
19
|
-
|
39
|
+
validates_presence_of :password, :if => :password_required?
|
40
|
+
validates_confirmation_of :password, :if => :password_required?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
20
44
|
|
21
|
-
|
45
|
+
module Callbacks
|
46
|
+
def self.included(model)
|
47
|
+
model.class_eval do
|
48
|
+
before_save :initialize_salt, :encrypt_password, :initialize_token
|
49
|
+
end
|
22
50
|
end
|
23
51
|
end
|
24
52
|
|
data/shoulda_macros/clearance.rb
CHANGED
@@ -14,7 +14,7 @@ module Clearance
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def should_be_signed_in_and_email_confirmed_as(&block)
|
17
|
-
warn "[DEPRECATION] questionable usefulness"
|
17
|
+
warn "[DEPRECATION] should_be_signed_in_and_email_confirmed_as: questionable usefulness"
|
18
18
|
should_be_signed_in_as &block
|
19
19
|
|
20
20
|
should "have confirmed email" do
|
@@ -33,7 +33,7 @@ module Clearance
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def should_deny_access_on(http_method, action, opts = {})
|
36
|
-
warn "[DEPRECATION] use a setup & should_deny_access(:flash => ?)"
|
36
|
+
warn "[DEPRECATION] should_deny_access_on: use a setup & should_deny_access(:flash => ?)"
|
37
37
|
flash_message = opts.delete(:flash)
|
38
38
|
context "on #{http_method} to #{action}" do
|
39
39
|
setup do
|
@@ -67,7 +67,7 @@ module Clearance
|
|
67
67
|
# CONTEXTS
|
68
68
|
|
69
69
|
def signed_in_user_context(&blk)
|
70
|
-
warn "[DEPRECATION] creates a Mystery Guest, causes Obscure Test"
|
70
|
+
warn "[DEPRECATION] signed_in_user_context: creates a Mystery Guest, causes Obscure Test"
|
71
71
|
context "A signed in user" do
|
72
72
|
setup do
|
73
73
|
@user = Factory(:user)
|
@@ -79,7 +79,7 @@ module Clearance
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def public_context(&blk)
|
82
|
-
warn "[DEPRECATION] common case is no-op. call sign_out otherwise"
|
82
|
+
warn "[DEPRECATION] public_context: common case is no-op. call sign_out otherwise"
|
83
83
|
context "The public" do
|
84
84
|
setup { sign_out }
|
85
85
|
merge_block(&blk)
|
@@ -89,7 +89,7 @@ module Clearance
|
|
89
89
|
# CREATING USERS
|
90
90
|
|
91
91
|
def should_create_user_successfully
|
92
|
-
warn "[DEPRECATION] not meant to be public, no longer used internally"
|
92
|
+
warn "[DEPRECATION] should_create_user_successfully: not meant to be public, no longer used internally"
|
93
93
|
should_assign_to :user
|
94
94
|
should_change 'User.count', :by => 1
|
95
95
|
|
@@ -134,7 +134,7 @@ module Clearance
|
|
134
134
|
# VALIDATIONS
|
135
135
|
|
136
136
|
def should_validate_confirmation_of(attribute, opts = {})
|
137
|
-
warn "[DEPRECATION] not meant to be public, no longer used internally"
|
137
|
+
warn "[DEPRECATION] should_validate_confirmation_of: not meant to be public, no longer used internally"
|
138
138
|
raise ArgumentError if opts[:factory].nil?
|
139
139
|
|
140
140
|
context "on save" do
|
@@ -144,7 +144,7 @@ module Clearance
|
|
144
144
|
end
|
145
145
|
|
146
146
|
def should_validate_confirmation_is_not_blank(factory, attribute, opts = {})
|
147
|
-
warn "[DEPRECATION] not meant to be public, no longer used internally"
|
147
|
+
warn "[DEPRECATION] should_validate_confirmation_is_not_blank: not meant to be public, no longer used internally"
|
148
148
|
should "validate #{attribute}_confirmation is not blank" do
|
149
149
|
model = Factory.build(factory, blank_confirmation_options(attribute))
|
150
150
|
model.save
|
@@ -154,7 +154,7 @@ module Clearance
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def should_validate_confirmation_is_not_bad(factory, attribute, opts = {})
|
157
|
-
warn "[DEPRECATION] not meant to be public, no longer used internally"
|
157
|
+
warn "[DEPRECATION] should_validate_confirmation_is_not_bad: not meant to be public, no longer used internally"
|
158
158
|
should "validate #{attribute}_confirmation is different than #{attribute}" do
|
159
159
|
model = Factory.build(factory, bad_confirmation_options(attribute))
|
160
160
|
model.save
|
@@ -166,7 +166,7 @@ module Clearance
|
|
166
166
|
# FORMS
|
167
167
|
|
168
168
|
def should_display_a_password_update_form
|
169
|
-
warn "[DEPRECATION] not meant to be public, no longer used internally"
|
169
|
+
warn "[DEPRECATION] should_display_a_password_update_form: not meant to be public, no longer used internally"
|
170
170
|
should "have a form for the user's token, password, and password confirm" do
|
171
171
|
update_path = ERB::Util.h(
|
172
172
|
user_password_path(@user, :token => @user.token)
|
@@ -181,7 +181,7 @@ module Clearance
|
|
181
181
|
end
|
182
182
|
|
183
183
|
def should_display_a_sign_up_form
|
184
|
-
warn "[DEPRECATION] not meant to be public, no longer used internally"
|
184
|
+
warn "[DEPRECATION] should_display_a_sign_up_form: not meant to be public, no longer used internally"
|
185
185
|
should "display a form to sign up" do
|
186
186
|
assert_select "form[action=#{users_path}][method=post]",
|
187
187
|
true, "There must be a form to sign up" do
|
@@ -198,7 +198,7 @@ module Clearance
|
|
198
198
|
end
|
199
199
|
|
200
200
|
def should_display_a_sign_in_form
|
201
|
-
warn "[DEPRECATION] not meant to be public, no longer used internally"
|
201
|
+
warn "[DEPRECATION] should_display_a_sign_in_form: not meant to be public, no longer used internally"
|
202
202
|
should 'display a "sign in" form' do
|
203
203
|
assert_select "form[action=#{session_path}][method=post]",
|
204
204
|
true, "There must be a form to sign in" do
|
@@ -235,19 +235,19 @@ module Clearance
|
|
235
235
|
end
|
236
236
|
|
237
237
|
def blank_confirmation_options(attribute)
|
238
|
-
warn "[DEPRECATION] not meant to be public, no longer used internally"
|
238
|
+
warn "[DEPRECATION] blank_confirmation_options: not meant to be public, no longer used internally"
|
239
239
|
opts = { attribute => attribute.to_s }
|
240
240
|
opts.merge("#{attribute}_confirmation".to_sym => "")
|
241
241
|
end
|
242
242
|
|
243
243
|
def bad_confirmation_options(attribute)
|
244
|
-
warn "[DEPRECATION] not meant to be public, no longer used internally"
|
244
|
+
warn "[DEPRECATION] bad_confirmation_options: not meant to be public, no longer used internally"
|
245
245
|
opts = { attribute => attribute.to_s }
|
246
246
|
opts.merge("#{attribute}_confirmation".to_sym => "not_#{attribute}")
|
247
247
|
end
|
248
248
|
|
249
249
|
def assert_confirmation_error(model, attribute, message = "confirmation error")
|
250
|
-
warn "[DEPRECATION] not meant to be public, no longer used internally"
|
250
|
+
warn "[DEPRECATION] assert_confirmation_error: not meant to be public, no longer used internally"
|
251
251
|
assert model.errors.on(attribute).include?("doesn't match confirmation"),
|
252
252
|
message
|
253
253
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thoughtbot-clearance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Croak
|
@@ -24,7 +24,7 @@ autorequire:
|
|
24
24
|
bindir: bin
|
25
25
|
cert_chain: []
|
26
26
|
|
27
|
-
date: 2009-05-
|
27
|
+
date: 2009-05-17 21:00:00 -07:00
|
28
28
|
default_executable:
|
29
29
|
dependencies: []
|
30
30
|
|