has_secure_attribute 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/active_model/secure_attribute/has_secure_attribute.rb +5 -1
- data/lib/has_secure_attribute/version.rb +2 -2
- data/spec/models/has_secure_attribute_spec.rb +16 -0
- data/spec/models/test_model_with_alternative_syntax.rb +6 -0
- data/spec/spec_helper.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e61ec31351c820eaab8299f6114e7b714e5f7620
|
4
|
+
data.tar.gz: 65bf16cba90c646c29aeb7d5d75dcf80e1d4715c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 723227ddf282925dfa763c6f0efcd40d5422fef98b1532c0995815249eb4012a74879967cad67738079aa631ab751eaba1f8c7d7c36618ea23b6320ed211ab24
|
7
|
+
data.tar.gz: 89a734102051452f9226178e6779c7107cc41c5121ee2ba976b766ca0a2b6ee33f34a2a0e911d2152bfacf7e20c6d85dfbddbd1dc6aa73730d103e81d400c5e8
|
data/README.md
CHANGED
@@ -20,10 +20,18 @@ or in your `Gemfile`
|
|
20
20
|
Use it
|
21
21
|
------
|
22
22
|
|
23
|
+
The attribute can be specified using either:
|
24
|
+
|
23
25
|
class User < ActiveRecord::Base
|
24
26
|
has_secure_security_answer
|
25
27
|
end
|
26
28
|
|
29
|
+
or
|
30
|
+
|
31
|
+
class User < ActiveRecord::Base
|
32
|
+
has_secure :security_answer
|
33
|
+
end
|
34
|
+
|
27
35
|
In the above example:
|
28
36
|
|
29
37
|
* Your should have a `users` table that has one column: `security_answer_digest`.
|
@@ -18,6 +18,10 @@ module ActiveModel
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def has_secure(attr, opts={})
|
22
|
+
has_secure_attribute(attr, opts)
|
23
|
+
end
|
24
|
+
|
21
25
|
def has_secure_attribute(meth, *args, &block)
|
22
26
|
attribute_sym = meth.to_sym
|
23
27
|
attr_reader attribute_sym # setter is defined later on
|
@@ -73,4 +77,4 @@ module ActiveModel
|
|
73
77
|
end
|
74
78
|
end
|
75
79
|
|
76
|
-
ActiveRecord::Base.send :include, ActiveModel::SecureAttribute
|
80
|
+
ActiveRecord::Base.send :include, ActiveModel::SecureAttribute
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module HasSecureAttribute
|
2
|
-
VERSION = "0.
|
3
|
-
end
|
2
|
+
VERSION = "0.4.0"
|
3
|
+
end
|
@@ -182,3 +182,19 @@ describe TestModelWithAttributeDisableConfirmation do
|
|
182
182
|
t.authenticate_security_answer('Answer').should eq t
|
183
183
|
end
|
184
184
|
end
|
185
|
+
|
186
|
+
describe TestModelWithAlternativeSyntax do
|
187
|
+
it { should respond_to(:username) }
|
188
|
+
it { should respond_to(:username=) }
|
189
|
+
it { should respond_to(:username_confirmation) }
|
190
|
+
it { should respond_to(:username_confirmation=) }
|
191
|
+
it { should respond_to(:authenticate_username) }
|
192
|
+
|
193
|
+
context "with no validation" do
|
194
|
+
it { should respond_to(:security_answer) }
|
195
|
+
it { should respond_to(:security_answer=) }
|
196
|
+
it { should_not respond_to(:security_answer_confirmation) }
|
197
|
+
it { should_not respond_to(:security_answer_confirmation=) }
|
198
|
+
it { should respond_to(:authenticate_security_answer) }
|
199
|
+
end
|
200
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,6 +9,7 @@ require File.expand_path("../models/test_model_with_attribute_no_validation", __
|
|
9
9
|
require File.expand_path("../models/test_model_with_attribute_protect_setter_for_digest", __FILE__)
|
10
10
|
require File.expand_path("../models/test_model_with_attribute_with_case_sensitive", __FILE__)
|
11
11
|
require File.expand_path("../models/test_model_with_attribute_disable_confirmation", __FILE__)
|
12
|
+
require File.expand_path("../models/test_model_with_alternative_syntax", __FILE__)
|
12
13
|
|
13
14
|
require 'factory_girl'
|
14
15
|
FactoryGirl.find_definitions
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_secure_attribute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Panayotis Matsinopoulos
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- spec/models/has_secure_attribute_spec.rb
|
126
126
|
- spec/models/test_model_with_attribute_no_validation.rb
|
127
127
|
- spec/models/test_model_with_attribute_protect_setter_for_digest.rb
|
128
|
+
- spec/models/test_model_with_alternative_syntax.rb
|
128
129
|
- spec/models/test_model_with_attribute_disable_confirmation.rb
|
129
130
|
- spec/models/test_model_with_attribute.rb
|
130
131
|
- spec/models/test_model_with_attribute_with_case_sensitive.rb
|