From f4f8b41017bec67818547587e3ba80cdb64fa20d Mon Sep 17 00:00:00 2001 From: Ruslan Korolev Date: Tue, 18 Aug 2015 14:13:21 +0300 Subject: [PATCH] fix RequestOptions#merge + test for default options --- lib/google/apis/options.rb | 4 ++-- spec/google/apis/options_spec.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/google/apis/options.rb b/lib/google/apis/options.rb index 2ad2ac3d3..3cf5c4df1 100644 --- a/lib/google/apis/options.rb +++ b/lib/google/apis/options.rb @@ -44,7 +44,7 @@ module Google # Request options class RequestOptions - # @!attribute [rw] credentials + # @!attribute [rw] authorization # @return [Signet::OAuth2::Client, #apply(Hash)] OAuth2 credentials # @!attribute [rw] retries # @return [Fixnum] Number of times to retry requests on server error @@ -63,7 +63,7 @@ module Google return self if options.nil? new_options = dup - %w(authorization retries timeout_sec).each do |opt| + members.each do |opt| opt = opt.to_sym new_options[opt] = options[opt] unless options[opt].nil? end diff --git a/spec/google/apis/options_spec.rb b/spec/google/apis/options_spec.rb index 387ecb560..fa5a4f46e 100644 --- a/spec/google/apis/options_spec.rb +++ b/spec/google/apis/options_spec.rb @@ -37,4 +37,12 @@ RSpec.describe Google::Apis::RequestOptions do it 'should allow nil in merge' do expect(options.merge(nil)).to be_an_instance_of(Google::Apis::RequestOptions) end + + it 'should override default options' do + Google::Apis::RequestOptions.default.header = 'Content-Length: 50' + opts = Google::Apis::RequestOptions.new + opts.header = 'Content-Length: 70' + expect(options.merge(opts).header).to eq 'Content-Length: 70' + end + end