mongoid-kms 0.0.30 → 0.0.31

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: 062414877225ffb6f54fb22a16c521812e65f83d
4
- data.tar.gz: d0fc31f7e5843857777de5b279478c9ebd6b0389
3
+ metadata.gz: 37ae0463add173e91447c34a3c39113b63ffb3b6
4
+ data.tar.gz: e03daf701ac8a8bca65770bc304cafa7bcb0b45e
5
5
  SHA512:
6
- metadata.gz: 03fb34db1385ac0cf754ef546370be58798fc09d56456efe75d227209022a92b9aa1146d50ef8f7a3daf07e2fbfcde99463fb0426b2e4547ac57cc045716527d
7
- data.tar.gz: 6957fafa2eacfb9d4f888b56f66cc1631ceb808eed0c8729ac580c9e2db44f3e850d4e6a7f9afada1cb45a93d40c34b5c79e0c754b8b254235911ed51fe74c0f
6
+ metadata.gz: 8b70d8aff3d48a2e1f6810beb55d06ab0bba560ac457753ebef754745a548d1fade9018ab98993488c3c3995fcadf9dd96e6610452ccbcddb3a560cf9f0a6b06
7
+ data.tar.gz: 8d5dedead0ff718b5d40b38cb8fbd6a63e010ff95fdb9beb67d274af7b515c5799543ed8721d8b41834e4f8cd522fc852062634b2d8cd4fea8266d5dd691d094
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Kms
3
- VERSION = "0.0.30"
3
+ VERSION = "0.0.31"
4
4
  end
5
5
  end
data/lib/mongoid/kms.rb CHANGED
@@ -153,7 +153,7 @@ module Mongoid
153
153
  encrypted_field_name = get_encrypted_field_name(field_name)
154
154
 
155
155
  create_dirty_methods field_name, field_name
156
- before_save :set_kms_values
156
+ after_validation :set_kms_values
157
157
 
158
158
  kms_field_map[field_name.to_s] = {context: args.delete(:context), type: args[:type]}
159
159
 
@@ -87,33 +87,46 @@ describe Mongoid::Kms do
87
87
  o.bla
88
88
  end
89
89
 
90
- it "works with embedded documents" do
91
- class ParentClass
92
- include Mongoid::Document
90
+ describe "works with embedded documents" do
91
+ before do
92
+ class ParentClass
93
+ include Mongoid::Document
93
94
 
94
- embeds_one :child_class, class_name: "ChildClass"
95
+ embeds_one :child_class, class_name: "ChildClass"
95
96
 
96
- field :unsecure, type: String
97
- end
97
+ field :unsecure, type: String
98
+ end
98
99
 
99
- class ChildClass
100
- include Mongoid::Document
101
- include Mongoid::Kms
100
+ class ChildClass
101
+ include Mongoid::Document
102
+ include Mongoid::Kms
102
103
 
103
- embedded_in :parent_class
104
+ embedded_in :parent_class
104
105
 
105
- secure_field :secure, type: String
106
- field :unsecure, type: String
106
+ secure_field :secure, type: String
107
+ field :unsecure, type: String
108
+ end
107
109
  end
108
110
 
109
- o = ParentClass.create!(unsecure: "wonder woman")
110
- o.child_class = ChildClass.new(secure: "invisible ship", unsecure: "a whip")
111
- o.save!
111
+ it "on save" do
112
+ o = ParentClass.create!(unsecure: "wonder woman")
113
+ o.child_class = ChildClass.new(secure: "invisible ship", unsecure: "a whip")
114
+ o.save!
112
115
 
113
- o.reload
114
- expect(o.unsecure).to eq("wonder woman")
115
- expect(o.child_class.secure).to eq("invisible ship")
116
- expect(o.child_class.unsecure).to eq("a whip")
116
+ o.reload
117
+ expect(o.unsecure).to eq("wonder woman")
118
+ expect(o.child_class.secure).to eq("invisible ship")
119
+ expect(o.child_class.unsecure).to eq("a whip")
120
+ end
121
+
122
+ it "on create" do
123
+ o = ParentClass.create!(unsecure: "wonder woman", child_class: ChildClass.new(secure: "invisible ship", unsecure: "a whip"))
124
+ o.reload
125
+
126
+ expect(o.unsecure).to eq("wonder woman")
127
+ expect(o.child_class.secure).to eq("invisible ship")
128
+ expect(o.child_class.unsecure).to eq("a whip")
129
+ end
117
130
  end
118
131
 
119
132
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-kms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Winslett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-20 00:00:00.000000000 Z
11
+ date: 2015-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  requirements: []
193
193
  rubyforge_project:
194
- rubygems_version: 2.4.6
194
+ rubygems_version: 2.4.7
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: Easy plugin for Mongoid + AWS KMS for security