Skip to content

Commit 62f9dbd

Browse files
authored
Merge pull request #14 from y-bonfire/develop
export as epub
2 parents 0cd02e6 + c4e136c commit 62f9dbd

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

lib/google_drive/util.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module Util
2727
'.htm' => 'text/html',
2828
'.html' => 'text/html',
2929
'.zip' => 'application/zip',
30+
'.epub' => 'application/epub+zip',
3031
'.swf' => 'application/x-shockwave-flash'
3132
}.freeze
3233

test/test_google_drive_export.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# test/test_google_drive_export.rb
2+
3+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
4+
require 'yaml'
5+
6+
require 'rubygems'
7+
require 'bundler/setup'
8+
require 'highline'
9+
require 'test/unit'
10+
11+
require 'google_drive'
12+
require_relative 'test_helper'
13+
14+
class TestGoogleDriveExport < Test::Unit::TestCase
15+
include(SessionHelper)
16+
17+
def test_upload_and_download
18+
session = get_session
19+
return unless auth_type == AuthType::USER_ACCOUNT
20+
test_file_path = File.join(File.dirname(__FILE__), 'test_file.txt')
21+
test_file_title = 'test_file_123.txt'
22+
file = session.upload_from_file(
23+
test_file_path, test_file_title, convert: true
24+
)
25+
assert { file.is_a?(GoogleDrive::File) }
26+
assert { file.title == "test_file_123" }
27+
assert { file.available_content_types == [] }
28+
assert { file.mime_type == 'application/vnd.google-apps.document' }
29+
download_path = File.join(File.dirname(__FILE__), 'sample-epub-file-dl.epub')
30+
file.export_as_file(download_path)
31+
assert { File.exist?(download_path) }
32+
File.delete(download_path)
33+
end
34+
end

0 commit comments

Comments
 (0)