vzaar 1.5.3 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -283,10 +283,11 @@ module Vzaar
283
283
 
284
284
  describe "#signature" do
285
285
  context "with default options" do
286
- let(:signature_options) { {} }
286
+ let(:signature_options) { { path: 'spec/support/video.mp4' } }
287
+
287
288
  it "returns a signature" do
288
289
  VCR.use_cassette("signature-default") do
289
- signature = subject.signature
290
+ signature = subject.signature signature_options
290
291
  expect(signature.https).to be_falsey
291
292
  end
292
293
  end
@@ -295,6 +296,7 @@ module Vzaar
295
296
  context "with custom options" do
296
297
  let(:signature_options) do
297
298
  {
299
+ path: 'spec/support/video.mp4',
298
300
  success_action_redirect: 'example.com',
299
301
  include_metadata: true,
300
302
  flash: false
@@ -308,32 +310,56 @@ module Vzaar
308
310
  end
309
311
  end
310
312
  end
313
+
314
+ context "with no options" do
315
+ it "raises an error" do
316
+ expect{ subject.signature }.
317
+ to raise_error(Vzaar::Error,
318
+ 'Path or url parameter required to generate signature.')
319
+ end
320
+ end
311
321
  end
312
322
 
313
323
  describe "#upload_video" do
314
- let(:expected_video_id) { '1407683' }
315
- let(:path) { './spec/support/video.mp4' }
316
324
  let(:upload_options) do
317
325
  { title: 'title', description: 'desc', profile: '2', path: path }
318
326
  end
319
327
 
320
- it "uploads the video, starts processing and returns the video id" do
321
- VCR.use_cassette('upload_video-success') do
322
- video = subject.upload_video(upload_options)
323
- expect(video.id).to eq(expected_video_id.to_i)
328
+ context 'when video is too small for multipart upload' do
329
+ let(:expected_video_id) { '6337328' }
330
+ let(:path) { './spec/support/video.mp4' }
331
+
332
+ it "uploads the video, starts processing and returns the video id" do
333
+ VCR.use_cassette('upload_video-success') do
334
+ video = subject.upload_video(upload_options)
335
+ expect(video.id).to eq(expected_video_id.to_i)
336
+ end
337
+ end
338
+ end
339
+
340
+ context 'when video is big enough for multipart upload' do
341
+ let(:expected_video_id) { '6337327' }
342
+ let(:path) { './spec/support/video-6mb.mp4' }
343
+
344
+ it "uploads the video, starts processing and returns the video id" do
345
+ VCR.use_cassette('upload_video-multipart-success') do
346
+ video = subject.upload_video(upload_options)
347
+ expect(video.id).to eq(expected_video_id.to_i)
348
+ end
324
349
  end
325
350
  end
326
351
  end
327
352
 
328
353
  describe "#process_video" do
329
- let(:expected_video_id) { '1407672' }
354
+ let(:expected_video_id) { '6337329' }
330
355
 
331
356
  let(:process_options) do
332
357
  {
333
- guid: 'vze7355b904a904737ab0e9582045c78ff',
358
+ guid: 'vz37d1756fd5df47b4a10f0a622c282aed',
334
359
  title: 'new video',
335
360
  description: 'a very long description',
336
- profile: '2'
361
+ profile: '2',
362
+ chunks: 2
337
363
  }
338
364
  end
339
365
 
@@ -14,7 +14,8 @@ module Vzaar
14
14
  subject { described_class.new(conn, signature, opts) }
15
15
 
16
16
  describe "#upload" do
17
- let(:uploader) { double }
17
+ let(:uploader) { double upload: result }
18
+ let(:result) { { success: true } }
18
19
 
19
20
  describe "standard upload directly to s3" do
20
21
  let(:url) { nil }
@@ -22,8 +23,6 @@ module Vzaar
22
23
  specify do
23
24
  allow(Uploaders::S3).to receive(:new)
24
25
  .with(opts[:path], signature) { uploader }
25
-
26
- allow(uploader).to receive(:upload)
27
26
  subject.upload
28
27
  end
29
28
  end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ module Vzaar
4
+ describe Uploaders::S3 do
5
+
6
+ subject { described_class.new path, signature }
7
+
8
+ let(:path) { './spec/support/video.mov' }
9
+ let(:signature) { double chunk_size: chunk_size }
10
+
11
+ describe '#upload' do
12
+ context 'and chunk_size is nil' do
13
+ let(:chunk_size) { nil }
14
+
15
+ it 'performs a single part upload' do
16
+ expect(subject).to receive(:single_part_upload)
17
+ subject.upload
18
+ end
19
+ end
20
+
21
+ context 'and chunk_size is blank' do
22
+ let(:chunk_size) { '' }
23
+
24
+ it 'performs a single part upload' do
25
+ expect(subject).to receive(:single_part_upload)
26
+ subject.upload
27
+ end
28
+ end
29
+
30
+ context 'and chunk_size is present' do
31
+ let(:chunk_size) { '32mb' }
32
+
33
+ it 'performs a single part upload' do
34
+ expect(subject).to receive(:multipart_upload)
35
+ subject.upload
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.require_paths = ['lib']
22
22
 
23
23
  s.add_dependency 'nokogiri', '~> 1.6'
24
- s.add_dependency 'httpclient', '~> 2.3'
24
+ s.add_dependency 'httpclient', '~> 2.7'
25
25
  s.add_dependency 'oauth', '~> 0.4'
26
26
 
27
27
  s.add_development_dependency 'bundler', '~> 1.3'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vzaar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed James
@@ -9,160 +9,160 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-07 00:00:00.000000000 Z
12
+ date: 2016-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.6'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.6'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: httpclient
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '2.3'
34
+ version: '2.7'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '2.3'
41
+ version: '2.7'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: oauth
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0.4'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0.4'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: bundler
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ~>
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '1.3'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1.3'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: fuubar
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ~>
74
+ - - "~>"
75
75
  - !ruby/object:Gem::Version
76
76
  version: '1.2'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ~>
81
+ - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '1.2'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rake
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ~>
88
+ - - "~>"
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ~>
95
+ - - "~>"
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: growl
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ~>
102
+ - - "~>"
103
103
  - !ruby/object:Gem::Version
104
104
  version: '1.0'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ~>
109
+ - - "~>"
110
110
  - !ruby/object:Gem::Version
111
111
  version: '1.0'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: guard-rspec
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ~>
116
+ - - "~>"
117
117
  - !ruby/object:Gem::Version
118
118
  version: '4.0'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ~>
123
+ - - "~>"
124
124
  - !ruby/object:Gem::Version
125
125
  version: '4.0'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: rspec
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - ~>
130
+ - - "~>"
131
131
  - !ruby/object:Gem::Version
132
132
  version: '2.14'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - ~>
137
+ - - "~>"
138
138
  - !ruby/object:Gem::Version
139
139
  version: '2.14'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: vcr
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
- - - ~>
144
+ - - "~>"
145
145
  - !ruby/object:Gem::Version
146
146
  version: '2.7'
147
147
  type: :development
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - ~>
151
+ - - "~>"
152
152
  - !ruby/object:Gem::Version
153
153
  version: '2.7'
154
154
  - !ruby/object:Gem::Dependency
155
155
  name: webmock
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - ~>
158
+ - - "~>"
159
159
  - !ruby/object:Gem::Version
160
160
  version: '1.16'
161
161
  type: :development
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - ~>
165
+ - - "~>"
166
166
  - !ruby/object:Gem::Version
167
167
  version: '1.16'
168
168
  description: A Ruby gem for the vzaar API
@@ -173,11 +173,11 @@ executables: []
173
173
  extensions: []
174
174
  extra_rdoc_files: []
175
175
  files:
176
- - .gitignore
177
- - .rspec
178
- - .ruby-gemset
179
- - .ruby-version
180
- - .travis.yml
176
+ - ".gitignore"
177
+ - ".rspec"
178
+ - ".ruby-gemset"
179
+ - ".ruby-version"
180
+ - ".travis.yml"
181
181
  - ChangeLog
182
182
  - Gemfile
183
183
  - Guardfile
@@ -257,6 +257,7 @@ files:
257
257
  - spec/fixtures/vcr_cassettes/process_video-default.yml
258
258
  - spec/fixtures/vcr_cassettes/signature-default.yml
259
259
  - spec/fixtures/vcr_cassettes/signature-with-options.yml
260
+ - spec/fixtures/vcr_cassettes/upload_video-multipart-success.yml
260
261
  - spec/fixtures/vcr_cassettes/upload_video-success.yml
261
262
  - spec/fixtures/vcr_cassettes/user_details-authenticated-fail.yml
262
263
  - spec/fixtures/vcr_cassettes/user_details-authenticated-success.yml
@@ -280,6 +281,7 @@ files:
280
281
  - spec/support/cfx.jpeg
281
282
  - spec/support/cfx.png
282
283
  - spec/support/pic.jpg
284
+ - spec/support/video-6mb.mp4
283
285
  - spec/support/video.mov
284
286
  - spec/support/video.mp4
285
287
  - spec/vzaar/api_xml_spec.rb
@@ -291,6 +293,7 @@ files:
291
293
  - spec/vzaar/resources/signature_spec.rb
292
294
  - spec/vzaar/resources/video_spec.rb
293
295
  - spec/vzaar/uploader_spec.rb
296
+ - spec/vzaar/uploaders/s3_spec.rb
294
297
  - spec/vzaar_spec.rb
295
298
  - vzaar.gemspec
296
299
  homepage: http://vzaar.com
@@ -303,20 +306,20 @@ require_paths:
303
306
  - lib
304
307
  required_ruby_version: !ruby/object:Gem::Requirement
305
308
  requirements:
306
- - - ! '>='
309
+ - - ">="
307
310
  - !ruby/object:Gem::Version
308
311
  version: '1.9'
309
312
  required_rubygems_version: !ruby/object:Gem::Requirement
310
313
  requirements:
311
- - - ! '>='
314
+ - - ">="
312
315
  - !ruby/object:Gem::Version
313
316
  version: '0'
314
317
  requirements: []
315
318
  rubyforge_project:
316
- rubygems_version: 2.2.2
319
+ rubygems_version: 2.5.1
317
320
  signing_key:
318
321
  specification_version: 4
319
- summary: vzaar-1.5.3
322
+ summary: vzaar-1.6.0
320
323
  test_files:
321
324
  - spec/fixtures/vcr_cassettes/account_type-fail.yml
322
325
  - spec/fixtures/vcr_cassettes/account_type-success.yml
@@ -334,6 +337,7 @@ test_files:
334
337
  - spec/fixtures/vcr_cassettes/process_video-default.yml
335
338
  - spec/fixtures/vcr_cassettes/signature-default.yml
336
339
  - spec/fixtures/vcr_cassettes/signature-with-options.yml
340
+ - spec/fixtures/vcr_cassettes/upload_video-multipart-success.yml
337
341
  - spec/fixtures/vcr_cassettes/upload_video-success.yml
338
342
  - spec/fixtures/vcr_cassettes/user_details-authenticated-fail.yml
339
343
  - spec/fixtures/vcr_cassettes/user_details-authenticated-success.yml
@@ -357,6 +361,7 @@ test_files:
357
361
  - spec/support/cfx.jpeg
358
362
  - spec/support/cfx.png
359
363
  - spec/support/pic.jpg
364
+ - spec/support/video-6mb.mp4
360
365
  - spec/support/video.mov
361
366
  - spec/support/video.mp4
362
367
  - spec/vzaar/api_xml_spec.rb
@@ -368,4 +373,5 @@ test_files:
368
373
  - spec/vzaar/resources/signature_spec.rb
369
374
  - spec/vzaar/resources/video_spec.rb
370
375
  - spec/vzaar/uploader_spec.rb
376
+ - spec/vzaar/uploaders/s3_spec.rb
371
377
  - spec/vzaar_spec.rb