Merge branch 'master' of https://github.com/google/google-api-ruby-client
This commit is contained in:
commit
2336c1a61a
|
@ -9,7 +9,7 @@ env:
|
|||
- RAILS_VERSION="~>4.0.0"
|
||||
- RAILS_VERSION="~>4.1.0"
|
||||
- RAILS_VERSION="~>4.2.0"
|
||||
script: "rake spec:all"
|
||||
script: "bundle exec rake spec:all"
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install idn
|
||||
|
|
|
@ -82,7 +82,7 @@ module Google
|
|||
# @raise [Google::Apis::ClientError] if upload source is invalid
|
||||
def prepare!
|
||||
super
|
||||
if upload_source.is_a?(IO) || upload_source.is_a?(StringIO)
|
||||
if streamable?(upload_source)
|
||||
self.upload_io = UploadIO.from_io(upload_source, content_type: upload_content_type)
|
||||
@close_io_on_finish = false
|
||||
elsif upload_source.is_a?(String)
|
||||
|
@ -97,6 +97,12 @@ module Google
|
|||
def release!
|
||||
upload_io.close if @close_io_on_finish
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def streamable?(upload_source)
|
||||
upload_source.is_a?(IO) || upload_source.is_a?(StringIO) || upload_source.is_a?(Tempfile)
|
||||
end
|
||||
end
|
||||
|
||||
# Implementation of the raw upload protocol
|
||||
|
|
|
@ -129,6 +129,20 @@ RSpec.describe Google::Apis::Core::RawUploadCommand do
|
|||
end
|
||||
end
|
||||
|
||||
context('with Tempfile input') do
|
||||
let(:file) do
|
||||
temp_file = Tempfile.new("tempfile")
|
||||
temp_file.write("Hello world\n")
|
||||
temp_file.rewind
|
||||
temp_file
|
||||
end
|
||||
include_examples 'should upload'
|
||||
|
||||
it 'should not close stream' do
|
||||
expect(file.closed?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context('with file path input') do
|
||||
let(:file) { File.join(FIXTURES_DIR, 'files', 'test.txt') }
|
||||
include_examples 'should upload'
|
||||
|
|
|
@ -19,13 +19,8 @@ GENERATED_DIR = File.expand_path(File.join(ROOT_DIR, 'generated'))
|
|||
THIRD_PARTY_DIR = File.expand_path(File.join(ROOT_DIR, 'third_party'))
|
||||
FIXTURES_DIR = File.expand_path(File.join(SPEC_DIR, 'fixtures'))
|
||||
|
||||
$LOAD_PATH.unshift(SPEC_DIR)
|
||||
$LOAD_PATH.unshift(LIB_DIR)
|
||||
$LOAD_PATH.unshift(GENERATED_DIR)
|
||||
$LOAD_PATH.unshift(THIRD_PARTY_DIR)
|
||||
$LOAD_PATH.uniq!
|
||||
|
||||
|
||||
if defined?(JRUBY_VERSION)
|
||||
puts 'Skipping coverage on JRuby'
|
||||
else
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
# Copyright 2015 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
RSpec.describe $LOAD_PATH do
|
||||
it('should contain SPEC_DIR') do
|
||||
expect($LOAD_PATH).to include(SPEC_DIR)
|
||||
end
|
||||
|
||||
it('should contain LIB_DIR') do
|
||||
expect($LOAD_PATH).to include(LIB_DIR)
|
||||
end
|
||||
|
||||
it('should contain GENERATED_DIR') do
|
||||
expect($LOAD_PATH).to include(GENERATED_DIR)
|
||||
end
|
||||
|
||||
it('should contain THIRD_PARTY_DIR') do
|
||||
expect($LOAD_PATH).to include(THIRD_PARTY_DIR)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue