crypt_keeper 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/crypt_keeper/model.rb +8 -6
- data/lib/crypt_keeper/version.rb +1 -1
- data/spec/model_spec.rb +6 -1
- metadata +4 -4
data/lib/crypt_keeper/model.rb
CHANGED
@@ -88,15 +88,17 @@ module CryptKeeper
|
|
88
88
|
before_save :encrypt_callback
|
89
89
|
|
90
90
|
crypt_keeper_fields.each do |field|
|
91
|
-
|
91
|
+
ensure_valid_field! field
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
# Private: Ensures that each field is of type text. This prevents
|
96
|
-
# encrypted data from being truncated
|
97
|
-
def
|
98
|
-
|
99
|
-
raise ArgumentError, ":#{field}
|
95
|
+
# Private: Ensures that each field exist and is of type text. This prevents
|
96
|
+
# encrypted data from being truncated.
|
97
|
+
def ensure_valid_field!(field)
|
98
|
+
if columns_hash["#{field}"].nil?
|
99
|
+
raise ArgumentError, "Column :#{field} does not exist"
|
100
|
+
elsif columns_hash["#{field}"].type != :text
|
101
|
+
raise ArgumentError, "Column :#{field} must be of type 'text' to be used for encryption"
|
100
102
|
end
|
101
103
|
end
|
102
104
|
end
|
data/lib/crypt_keeper/version.rb
CHANGED
data/spec/model_spec.rb
CHANGED
@@ -18,8 +18,13 @@ module CryptKeeper
|
|
18
18
|
subject.crypt_keeper_fields.should == [:storage, :secret]
|
19
19
|
end
|
20
20
|
|
21
|
+
it "should raise an exception with missing field" do
|
22
|
+
msg = "Column :none does not exist"
|
23
|
+
expect { subject.crypt_keeper :none, encryptor: :fake_encryptor }.to raise_error(ArgumentError, msg)
|
24
|
+
end
|
25
|
+
|
21
26
|
it "should raise an exception with wrong field type" do
|
22
|
-
msg = ":name must be of type 'text' to be used for encryption"
|
27
|
+
msg = "Column :name must be of type 'text' to be used for encryption"
|
23
28
|
expect { subject.crypt_keeper :name, encryptor: :fake_encryptor }.to raise_error(ArgumentError, msg)
|
24
29
|
end
|
25
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crypt_keeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -227,7 +227,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
227
227
|
version: '0'
|
228
228
|
segments:
|
229
229
|
- 0
|
230
|
-
hash:
|
230
|
+
hash: 722237911978539307
|
231
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
232
|
none: false
|
233
233
|
requirements:
|
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
236
|
version: '0'
|
237
237
|
segments:
|
238
238
|
- 0
|
239
|
-
hash:
|
239
|
+
hash: 722237911978539307
|
240
240
|
requirements: []
|
241
241
|
rubyforge_project:
|
242
242
|
rubygems_version: 1.8.23
|