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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ff53867f1679d30798e00a65bf1f5857a9e5dbb
4
- data.tar.gz: d7b68c80ddcec2ee55eee1705ee2ca11480a4143
3
+ metadata.gz: e61ec31351c820eaab8299f6114e7b714e5f7620
4
+ data.tar.gz: 65bf16cba90c646c29aeb7d5d75dcf80e1d4715c
5
5
  SHA512:
6
- metadata.gz: ab847858fd13348f213ede32e136b0ba88269e401cd68eaf41c8a31702d79e1cd9f2d5f23d176aad60e1a325ac90679e9317b1e39ee310d245baf5f75882f747
7
- data.tar.gz: 8f5603f7dfc36b9801d7f27f7e2006d496b26c803362201c72d7993e0bb83a774b520f7579cf2341d2e4b2a284270d70347d21f00ef650082c7cabb282c957cb
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.1"
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
@@ -0,0 +1,6 @@
1
+ class TestModelWithAlternativeSyntax < ActiveRecord::Base
2
+ self.table_name = "test_model_with_attributes"
3
+
4
+ has_secure :username
5
+ has_secure :security_answer, validations: false
6
+ 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.3.1
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