attr_vault 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/attr_vault/version.rb +1 -1
- data/lib/attr_vault.rb +3 -0
- data/spec/attr_vault_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86139c030cc0889d40ee3b40db69fe0b8b66beee
|
4
|
+
data.tar.gz: cadcf1eabcf1dc445edc9d8d423f66ff6cb58242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4758d09746a415b03c7b2e187419501f78a3815b67a918e810c35b7cf6d90319f9fdcf32ce100bf8b48b25453a5831c11b8d98c446c80caef47b6cd5d9d07a14
|
7
|
+
data.tar.gz: bfca3f4fc0f177d8e4244e6e778b7f4d3a4599b9aab9a0f68e225e8ba4bfd22388938d75869a49ef31cc724160340aafb563c8309b2018976c723f094515bc7d
|
data/Gemfile.lock
CHANGED
data/lib/attr_vault/version.rb
CHANGED
data/lib/attr_vault.rb
CHANGED
@@ -102,6 +102,9 @@ module AttrVault
|
|
102
102
|
end
|
103
103
|
|
104
104
|
define_method("#{name}=") do |value|
|
105
|
+
old_value = self.public_send(name)
|
106
|
+
return if value == old_value
|
107
|
+
|
105
108
|
@vault_dirty_attrs ||= {}
|
106
109
|
@vault_dirty_attrs[name] = value
|
107
110
|
# ensure that Sequel knows that this is in fact dirty and must
|
data/spec/attr_vault_spec.rb
CHANGED
@@ -61,6 +61,14 @@ describe AttrVault do
|
|
61
61
|
expect(s.secret_encrypted).not_to be_nil
|
62
62
|
end
|
63
63
|
|
64
|
+
it "avoids updating existing values when those do not change" do
|
65
|
+
the_secret = "I'm not saying it was aliens..."
|
66
|
+
s = item.create(secret: the_secret)
|
67
|
+
s.reload
|
68
|
+
s.secret = the_secret
|
69
|
+
expect(s.save_changes).to be_nil
|
70
|
+
end
|
71
|
+
|
64
72
|
it "stores the key id" do
|
65
73
|
secret = 'it was professor plum with the wrench in the library'
|
66
74
|
s = item.create(secret: secret)
|
@@ -119,6 +127,14 @@ describe AttrVault do
|
|
119
127
|
expect(s.secret).to be_nil
|
120
128
|
end
|
121
129
|
|
130
|
+
it "avoids updating existing values when those do not change" do
|
131
|
+
the_secret = "Satoshi Nakamoto"
|
132
|
+
s = item.create
|
133
|
+
s.update(secret: the_secret)
|
134
|
+
s.secret = the_secret
|
135
|
+
expect(s.save_changes).to be_nil
|
136
|
+
end
|
137
|
+
|
122
138
|
it "reads the correct value for a dirty field before the object is saved" do
|
123
139
|
s = item.create
|
124
140
|
secret = 'mcmurphy is lobotomized =('
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attr_vault
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciek Sakrejda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|