mongoid-kms 0.0.23 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94eecdfe3a08a0df7c31af9323145764e2f533ea
4
- data.tar.gz: 987d2308b3ec07529f0fed5601bf54c7a5acebb5
3
+ metadata.gz: cba610372bec2c46d28489f6e0737cf25506410b
4
+ data.tar.gz: 3f20a95f9c302c52aead878c8e5a54c0121140b2
5
5
  SHA512:
6
- metadata.gz: 0921f2e89f4c22b5a82b63cdc823578b93d5ed662a95474fece209df225e89c9eadc5cace556e1b68ebb98d6cb55457ee4a5131d2aa23ff3e6c46e1e0863d738
7
- data.tar.gz: 083bc76dbe8ae66ed2a80358da5e5db509709c7243c9e3180232d79d8d8c8cac866e395aa7d1e5db3797233b486d67c8d48df94529e9fa141bb989ddbc38152c
6
+ metadata.gz: 18f4d37ff69f49ef3408a110e77301336725a7159516796296cf7fce419fe5745cab4e338343e824789136e0163b5d5c3b5e56edaa97a5b3c4eb3fe86b419122
7
+ data.tar.gz: a82993500ff34c743a44a973d9ffc49b7f27c74f018c28bf6766080fe7a54df57fd7c61cacc747f6ff40db35f8b5ffcd16bbc0dfe0a33fb86feeb001b59dec4d
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Kms
3
- VERSION = "0.0.23"
3
+ VERSION = "0.0.24"
4
4
  end
5
5
  end
data/lib/mongoid/kms.rb CHANGED
@@ -52,7 +52,9 @@ module Mongoid
52
52
  # Instance methods
53
53
  def set_kms_values
54
54
  self.class.kms_field_map.each do |field_name, settings|
55
- if self.new_record? || self.send("#{field_name}_changed?") || kms_context_value_changed?(field_name)
55
+ if self.new_record? || # always run new records through this
56
+ changed_attributes.keys.include?(field_name.to_sym) || # this is a hack to get around Mongoid's weakass dirty hack
57
+ kms_context_value_changed?(field_name) # checks if any of the context fields have changed
56
58
  encrypted_field_name = self.class.get_encrypted_field_name(field_name)
57
59
 
58
60
  if instance_variable_get("@#{field_name}").nil? && kms_context_value_changed?(field_name)
@@ -40,6 +40,18 @@ describe Mongoid::Kms do
40
40
  expect(o.secure).to eq("other")
41
41
  end
42
42
 
43
+ it "updates properly" do
44
+ o = MyClass.new(unsecure: "robin", secure: "other")
45
+ o.save!
46
+
47
+ o = MyClass.find(o.id)
48
+ o.secure = 'salted-other'
49
+ o.save!
50
+
51
+ o = MyClass.find(o.id)
52
+ expect(o.secure).to eq("salted-other")
53
+ end
54
+
43
55
  it "handles a class without context" do
44
56
  o = MyClass.new(secure: "bla", unsecure: "blatoo")
45
57
  o.save!
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.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Winslett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-17 00:00:00.000000000 Z
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid