From 4b6f5d0a2b8e8019ea8045b681987f90af03c2d3 Mon Sep 17 00:00:00 2001 From: joker1007 Date: Thu, 25 Feb 2016 02:48:02 +0900 Subject: [PATCH 1/3] Fix Hash value assignment in JsonSupport#getter_fn because current version cannot send `false` value. If given parameter is `false`, current version does not use it. --- lib/google/apis/core/json_representation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/google/apis/core/json_representation.rb b/lib/google/apis/core/json_representation.rb index 843038a02..9fbf4bf01 100644 --- a/lib/google/apis/core/json_representation.rb +++ b/lib/google/apis/core/json_representation.rb @@ -39,7 +39,7 @@ module Google ivar_name = "@#{name}".to_sym lambda do |_| if respond_to?(:[]) - self[name] || instance_variable_get(ivar_name) + self.key?(name) ? self[name] : instance_variable_get(ivar_name) else instance_variable_get(ivar_name) end From fe7c37739930657353d2f4791bbcbb93d24d7a9e Mon Sep 17 00:00:00 2001 From: joker1007 Date: Thu, 25 Feb 2016 05:34:39 +0900 Subject: [PATCH 2/3] Add boolean test case --- .../apis/core/json_representation_spec.rb | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/spec/google/apis/core/json_representation_spec.rb b/spec/google/apis/core/json_representation_spec.rb index ebbe3e681..644a5ac0b 100644 --- a/spec/google/apis/core/json_representation_spec.rb +++ b/spec/google/apis/core/json_representation_spec.rb @@ -28,7 +28,8 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do attr_accessor :nil_value attr_accessor :numeric_value attr_accessor :string_value - attr_accessor :boolean_value + attr_accessor :boolean_value_true + attr_accessor :boolean_value_false attr_accessor :date_value attr_accessor :bytes_value attr_accessor :items @@ -44,7 +45,8 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do property :nil_value, as: 'nilValue' property :numeric_value, as: 'numericValue' property :string_value, as: 'stringValue' - property :boolean_value, as: 'booleanValue' + property :boolean_value_true, as: 'booleanValueTrue' + property :boolean_value_false, as: 'booleanValueFalse' property :date_value, as: 'dateValue', type: DateTime property :bytes_value, as: 'bytesValue', base64: true property :items @@ -75,7 +77,8 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do end it 'serializes boolean values' do - expect(json).to be_json_eql(%(true)).at_path('booleanValue') + expect(json).to be_json_eql(%(true)).at_path('booleanValueTrue') + expect(json).to be_json_eql(%(false)).at_path('booleanValueFalse') end it 'serializes date values' do @@ -107,7 +110,8 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do model.numeric_value = 123 model.string_value = 'test' model.date_value = DateTime.new(2015, 5, 1, 12) - model.boolean_value = true + model.boolean_value_true = true + model.boolean_value_false = false model.bytes_value = 'Hello world' model.items = [1, 2, 3] model.child = child_class.new @@ -127,7 +131,8 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do string_value: 'test', numeric_value: 123, date_value: DateTime.new(2015, 5, 1, 12), - boolean_value: true, + boolean_value_true: true, + boolean_value_false: false, bytes_value: 'Hello world', items: [1, 2, 3], child: { @@ -146,7 +151,8 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do json = <