govdelivery-tms 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OGU2YjhiZjAxYTBmOWZjNGRiOGEzYmJmM2JiYmFhNjVkY2U4NGJmYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2EzNjAyZDA5MWRiZmYyYzBmMzkyZWYyYzc5NDQ1MjMwZjY1NmM5NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2ZhODFhYmQxZTZkMmI1MmU3NzA3OGNlNzFkMDlkMmQ1MTYwOWViMWNkYWRh
|
10
|
+
Yzg5ZDI4Y2I5ZDZlZGE1OTQyYWZkNjAxNmJkOWFmYTU1NWNjMzIxYTM1ZmUx
|
11
|
+
ZmI0MTA2MTMwNGIxZWI2YzlkYjQ2YzBlYWI0YjFhMGQ0MDk5NmU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmJmNzk5ZjRiNWI1OTJiNjIyYTFmMDY0MTgyZmFhZmQ1ZWQxNzA4YmZmMmU5
|
14
|
+
ZjZmMWUzMDUwZTJhMGY3NGQzNjE3ZTAzZjVhNmNlMGRkNGU0NDU5MTBlODUw
|
15
|
+
NTM0ZDE0ZDU4ZDFkODZhNWE0MzEyYmVmMWY3NTA3NzEwMzQ2ZWE=
|
@@ -44,6 +44,17 @@ module GovDelivery::TMS::InstanceResource
|
|
44
44
|
@readonly_attributes
|
45
45
|
end
|
46
46
|
|
47
|
+
##
|
48
|
+
# Nullable attributes are sent as null in the request
|
49
|
+
#
|
50
|
+
def nullable_attributes(*attrs)
|
51
|
+
@nullable_attributes ||= []
|
52
|
+
if attrs.any?
|
53
|
+
@nullable_attributes.map!(&:to_sym).concat(attrs).uniq! if attrs.any?
|
54
|
+
end
|
55
|
+
@nullable_attributes
|
56
|
+
end
|
57
|
+
|
47
58
|
##
|
48
59
|
# For collections that are represented as attributes (i.e. inline, no href)
|
49
60
|
#
|
@@ -166,7 +177,9 @@ module GovDelivery::TMS::InstanceResource
|
|
166
177
|
json_hash[:_links] ||= {}
|
167
178
|
json_hash[:_links][attr] = @links[attr]
|
168
179
|
end
|
169
|
-
json_hash.reject
|
180
|
+
json_hash.reject do |key, value|
|
181
|
+
value.nil? && !self.class.nullable_attributes.include?(key)
|
182
|
+
end
|
170
183
|
end
|
171
184
|
|
172
185
|
protected
|
@@ -35,6 +35,14 @@ describe GovDelivery::TMS::InstanceResource do
|
|
35
35
|
expect(@instance_resource.to_json).to eq({blah: {recipients: [], opened: [], clicked: [], sent: [], failed: []}})
|
36
36
|
end
|
37
37
|
|
38
|
+
it 'should ignore nils in to_json unless an attribute in nullable_attributes' do
|
39
|
+
@instance_resource.class.nullable_attributes :bar
|
40
|
+
@instance_resource.bar = nil
|
41
|
+
expect(@instance_resource.to_json).to eq({blah: {recipients: [], opened: [], clicked: [], sent: [], failed: []},
|
42
|
+
bar: nil})
|
43
|
+
@instance_resource.class.instance_variable_set :@nullable_attributes, []
|
44
|
+
end
|
45
|
+
|
38
46
|
it 'should not GET on initialization' do
|
39
47
|
expect(client).not_to receive(:get)
|
40
48
|
Foo.new(client, 'https://example.com/foos/1')
|