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.
@@ -88,15 +88,17 @@ module CryptKeeper
88
88
  before_save :encrypt_callback
89
89
 
90
90
  crypt_keeper_fields.each do |field|
91
- ensure_field_is_encryptable! field
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 ensure_field_is_encryptable!(field)
98
- unless columns_hash["#{field}"].type == :text
99
- raise ArgumentError, ":#{field} must be of type 'text' to be used for encryption"
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
@@ -1,3 +1,3 @@
1
1
  module CryptKeeper
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
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.0
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-10-11 00:00:00.000000000 Z
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: 4508045864759288754
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: 4508045864759288754
239
+ hash: 722237911978539307
240
240
  requirements: []
241
241
  rubyforge_project:
242
242
  rubygems_version: 1.8.23