transloadit 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +23 -0
- data/.standard.yml +0 -0
- data/CHANGELOG.md +68 -57
- data/Gemfile +1 -1
- data/README.md +162 -86
- data/Rakefile +12 -17
- data/examples/README.md +94 -55
- data/examples/basic/audio-concat-transcoder.rb +29 -19
- data/examples/basic/audio-transcoder.rb +32 -22
- data/examples/basic/image-transcoder.rb +22 -17
- data/examples/basic/main.rb +31 -37
- data/examples/basic/media-transcoder.rb +2 -7
- data/lib/transloadit/api_model.rb +13 -13
- data/lib/transloadit/assembly.rb +27 -24
- data/lib/transloadit/exception.rb +2 -4
- data/lib/transloadit/request.rb +58 -52
- data/lib/transloadit/response/assembly.rb +14 -13
- data/lib/transloadit/response.rb +10 -10
- data/lib/transloadit/step.rb +13 -13
- data/lib/transloadit/template.rb +5 -5
- data/lib/transloadit/version.rb +1 -1
- data/lib/transloadit.rb +24 -24
- data/test/fixtures/cassettes/cancel_assembly.yml +3 -3
- data/test/fixtures/cassettes/create_template.yml +1 -1
- data/test/fixtures/cassettes/delete_template.yml +1 -1
- data/test/fixtures/cassettes/fetch_assemblies.yml +1 -1
- data/test/fixtures/cassettes/fetch_assembly_aborted.yml +3 -3
- data/test/fixtures/cassettes/fetch_assembly_errors.yml +3 -3
- data/test/fixtures/cassettes/fetch_assembly_executing.yml +3 -3
- data/test/fixtures/cassettes/fetch_assembly_notifications.yml +1 -1
- data/test/fixtures/cassettes/fetch_assembly_ok.yml +6 -6
- data/test/fixtures/cassettes/fetch_assembly_uploading.yml +3 -3
- data/test/fixtures/cassettes/fetch_billing.yml +1 -1
- data/test/fixtures/cassettes/fetch_root.yml +3 -3
- data/test/fixtures/cassettes/fetch_template.yml +1 -1
- data/test/fixtures/cassettes/fetch_templates.yml +1 -1
- data/test/fixtures/cassettes/post_assembly.yml +2 -2
- data/test/fixtures/cassettes/rate_limit_fail.yml +3 -3
- data/test/fixtures/cassettes/rate_limit_succeed.yml +4 -4
- data/test/fixtures/cassettes/replay_assembly.yml +2 -2
- data/test/fixtures/cassettes/replay_assembly_notification.yml +1 -1
- data/test/fixtures/cassettes/submit_assembly.yml +3 -3
- data/test/fixtures/cassettes/update_template.yml +1 -1
- data/test/test_helper.rb +10 -10
- data/test/unit/test_transloadit.rb +66 -66
- data/test/unit/transloadit/test_api.rb +35 -33
- data/test/unit/transloadit/test_assembly.rb +148 -112
- data/test/unit/transloadit/test_request.rb +41 -42
- data/test/unit/transloadit/test_response.rb +76 -76
- data/test/unit/transloadit/test_step.rb +52 -52
- data/test/unit/transloadit/test_template.rb +49 -54
- data/transloadit.gemspec +25 -26
- metadata +25 -41
- data/.travis.yml +0 -13
@@ -1,60 +1,60 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
describe Transloadit::Assembly do
|
4
4
|
before do
|
5
|
-
@transloadit = Transloadit.new(:
|
5
|
+
@transloadit = Transloadit.new(key: "")
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
9
|
-
(Transloadit::Assembly < Transloadit::ApiModel).must_equal true
|
8
|
+
it "must inherit from Transloadit::ApiModel class" do
|
9
|
+
_(Transloadit::Assembly < Transloadit::ApiModel).must_equal true
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe "when initialized" do
|
13
13
|
before do
|
14
|
-
@step
|
15
|
-
@redirect =
|
14
|
+
@step = @transloadit.step "thumbs", "/video/thumbs"
|
15
|
+
@redirect = "https://foo.bar/"
|
16
16
|
|
17
17
|
@assembly = Transloadit::Assembly.new @transloadit,
|
18
|
-
:
|
19
|
-
:
|
18
|
+
steps: @step,
|
19
|
+
redirect_url: @redirect
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
@assembly.steps.must_equal @step.to_hash
|
22
|
+
it "must wrap its step in a hash" do
|
23
|
+
_(@assembly.steps).must_equal @step.to_hash
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it "must not wrap a nil step" do
|
27
27
|
@assembly.options[:steps] = nil
|
28
|
-
@assembly.steps
|
28
|
+
assert_nil @assembly.steps
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
32
|
-
@assembly.options[:steps] = {
|
33
|
-
@assembly.steps.must_equal :
|
31
|
+
it "must not wrap a hash step" do
|
32
|
+
@assembly.options[:steps] = {foo: 1}
|
33
|
+
_(@assembly.steps).must_equal foo: 1
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
37
|
-
@assembly.to_hash.must_equal(
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
36
|
+
it "must produce Transloadit-compatible hash output" do
|
37
|
+
_(@assembly.to_hash).must_equal(
|
38
|
+
auth: @transloadit.to_hash,
|
39
|
+
steps: @assembly.steps,
|
40
|
+
redirect_url: @redirect
|
41
41
|
)
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
45
|
-
VCR.use_cassette
|
46
|
-
response = @assembly.create! open(
|
47
|
-
response.code.must_equal 302
|
48
|
-
response.headers[:location].must_match %r{^
|
44
|
+
it "must submit files for upload" do
|
45
|
+
VCR.use_cassette "submit_assembly" do
|
46
|
+
response = @assembly.create! open("lib/transloadit/version.rb")
|
47
|
+
_(response.code).must_equal 302
|
48
|
+
_(response.headers[:location]).must_match %r{^https://foo.bar/}
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
describe
|
52
|
+
describe "with a secret" do
|
53
53
|
include WebMock::API
|
54
54
|
|
55
55
|
before do
|
56
56
|
WebMock.reset!
|
57
|
-
stub_request(:post,
|
57
|
+
stub_request(:post, "https://api2.transloadit.com/assemblies")
|
58
58
|
.to_return(body: '{"ok":"ASSEMBLY_COMPLETED"}')
|
59
59
|
end
|
60
60
|
|
@@ -62,58 +62,91 @@ describe Transloadit::Assembly do
|
|
62
62
|
WebMock.reset!
|
63
63
|
end
|
64
64
|
|
65
|
-
it
|
65
|
+
it "must send the signature before any file" do
|
66
|
+
transloadit = Transloadit.new(key: "", secret: "foo")
|
67
|
+
Transloadit::Assembly.new(
|
68
|
+
transloadit
|
69
|
+
).create! open("lib/transloadit/version.rb")
|
70
|
+
|
71
|
+
assert_requested(:post, "https://api2.transloadit.com/assemblies") do |req|
|
72
|
+
position_params = req.body.index 'name="params"'
|
73
|
+
position_signature = req.body.index 'name="signature"'
|
74
|
+
position_file = req.body.index 'name="file_0"'
|
75
|
+
|
76
|
+
_(position_params).wont_be_nil
|
77
|
+
_(position_signature).wont_be_nil
|
78
|
+
_(position_file).wont_be_nil
|
79
|
+
|
80
|
+
_(position_params < position_signature).must_equal true
|
81
|
+
_(position_signature < position_file).must_equal true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "with additional parameters" do
|
87
|
+
include WebMock::API
|
88
|
+
|
89
|
+
before do
|
90
|
+
WebMock.reset!
|
91
|
+
stub_request(:post, "https://api2.transloadit.com/assemblies")
|
92
|
+
.to_return(body: '{"ok":"ASSEMBLY_COMPLETED"}')
|
93
|
+
end
|
94
|
+
|
95
|
+
after do
|
96
|
+
WebMock.reset!
|
97
|
+
end
|
98
|
+
|
99
|
+
it "must allow to send a template id along" do
|
66
100
|
Transloadit::Assembly.new(
|
67
101
|
@transloadit,
|
68
|
-
:
|
102
|
+
template_id: "TEMPLATE_ID"
|
69
103
|
).create!
|
70
104
|
|
71
|
-
assert_requested(:post,
|
105
|
+
assert_requested(:post, "https://api2.transloadit.com/assemblies") do |req|
|
72
106
|
values = values_from_post_body(req.body)
|
73
|
-
MultiJson.load(values[
|
107
|
+
_(MultiJson.load(values["params"])["template_id"]).must_equal "TEMPLATE_ID"
|
74
108
|
end
|
75
109
|
end
|
76
110
|
|
77
|
-
it
|
111
|
+
it "must allow to send the fields hash" do
|
78
112
|
Transloadit::Assembly.new(
|
79
113
|
@transloadit,
|
80
|
-
:
|
114
|
+
fields: {tag: "ninja-cat"}
|
81
115
|
).create!
|
82
116
|
|
83
|
-
assert_requested(:post,
|
117
|
+
assert_requested(:post, "https://api2.transloadit.com/assemblies") do |req|
|
84
118
|
values = values_from_post_body(req.body)
|
85
|
-
values[
|
86
|
-
MultiJson.load(values[
|
119
|
+
_(values["tag"]).must_equal "ninja-cat"
|
120
|
+
_(MultiJson.load(values["params"])["fields"]["tag"]).must_equal "ninja-cat"
|
87
121
|
end
|
88
122
|
end
|
89
123
|
|
90
|
-
it
|
124
|
+
it "must allow steps through the create! method" do
|
91
125
|
Transloadit::Assembly.new(@transloadit).create!(
|
92
|
-
|
126
|
+
steps: @transloadit.step("thumbs", "/video/thumbs")
|
93
127
|
)
|
94
128
|
|
95
|
-
assert_requested(:post,
|
129
|
+
assert_requested(:post, "https://api2.transloadit.com/assemblies") do |req|
|
96
130
|
values = values_from_post_body(req.body)
|
97
|
-
MultiJson.load(values[
|
131
|
+
_(MultiJson.load(values["params"])["steps"]).must_equal({"thumbs" => {"robot" => "/video/thumbs"}})
|
98
132
|
end
|
99
133
|
end
|
100
134
|
|
101
|
-
it
|
102
|
-
@assembly.create!(
|
135
|
+
it "must allow steps passed through the create! method override steps previously set" do
|
136
|
+
@assembly.create!(steps: @transloadit.step("resize", "/image/resize"))
|
103
137
|
|
104
|
-
assert_requested(:post,
|
138
|
+
assert_requested(:post, "https://api2.transloadit.com/assemblies") do |req|
|
105
139
|
values = values_from_post_body(req.body)
|
106
|
-
MultiJson.load(values[
|
140
|
+
_(MultiJson.load(values["params"])["steps"]).must_equal({"resize" => {"robot" => "/image/resize"}})
|
107
141
|
end
|
108
142
|
end
|
109
143
|
end
|
110
144
|
|
111
145
|
describe 'when using the "submit!" method' do
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
mocker = MiniTest::Mock.new
|
146
|
+
it "must call the create! method with the same parameters" do
|
147
|
+
VCR.use_cassette "submit_assembly" do
|
148
|
+
file = open("lib/transloadit/version.rb")
|
149
|
+
mocker = Minitest::Mock.new
|
117
150
|
mocker.expect :call, nil, [file]
|
118
151
|
@assembly.stub :create!, mocker do
|
119
152
|
@assembly.submit!(file)
|
@@ -123,54 +156,62 @@ describe Transloadit::Assembly do
|
|
123
156
|
end
|
124
157
|
end
|
125
158
|
|
126
|
-
describe
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
response
|
132
|
-
|
133
|
-
|
134
|
-
warning.must_equal "Rate limit reached. Waiting for 0 seconds before retrying.\n"
|
159
|
+
describe "when rate limit is reached" do
|
160
|
+
it "must output a warning and retry for a successful request" do
|
161
|
+
VCR.use_cassette "rate_limit_succeed" do
|
162
|
+
_, warning = capture_io {
|
163
|
+
response = @assembly.create! open("lib/transloadit/version.rb")
|
164
|
+
_(response["ok"]).must_equal "ASSEMBLY_COMPLETED"
|
165
|
+
}
|
166
|
+
_(warning).must_equal "Rate limit reached. Waiting for 0 seconds before retrying.\n"
|
135
167
|
end
|
136
168
|
end
|
137
169
|
|
138
|
-
it
|
170
|
+
it "must retry only the number of times specified" do
|
139
171
|
@assembly.options[:tries] = 1
|
140
172
|
|
141
|
-
VCR.use_cassette
|
173
|
+
VCR.use_cassette "rate_limit_succeed" do
|
142
174
|
assert_raises Transloadit::Exception::RateLimitReached do
|
143
|
-
|
175
|
+
@assembly.create! open("lib/transloadit/version.rb")
|
144
176
|
end
|
145
177
|
end
|
146
178
|
end
|
147
179
|
|
148
|
-
it
|
149
|
-
VCR.use_cassette
|
180
|
+
it "must raise RateLimitReached exception after multiple retries request" do
|
181
|
+
VCR.use_cassette "rate_limit_fail" do
|
150
182
|
assert_raises Transloadit::Exception::RateLimitReached do
|
151
|
-
|
183
|
+
@assembly.create! open("lib/transloadit/version.rb")
|
152
184
|
end
|
153
185
|
end
|
154
186
|
end
|
155
187
|
end
|
156
188
|
end
|
157
189
|
|
158
|
-
describe
|
190
|
+
describe "with multiple steps" do
|
159
191
|
before do
|
160
|
-
@encode = @transloadit.step
|
161
|
-
@thumbs = @transloadit.step
|
192
|
+
@encode = @transloadit.step "encode", "/video/encode"
|
193
|
+
@thumbs = @transloadit.step "thumbs", "/video/thumbs"
|
162
194
|
|
163
195
|
@assembly = Transloadit::Assembly.new @transloadit,
|
164
|
-
:
|
196
|
+
steps: [@encode, @thumbs]
|
165
197
|
end
|
166
198
|
|
167
|
-
it
|
168
|
-
@assembly.to_hash[:steps].keys.must_include @encode.name
|
169
|
-
@assembly.to_hash[:steps].keys.must_include @thumbs.name
|
199
|
+
it "must wrap its steps into one hash" do
|
200
|
+
_(@assembly.to_hash[:steps].keys).must_include @encode.name
|
201
|
+
_(@assembly.to_hash[:steps].keys).must_include @thumbs.name
|
202
|
+
end
|
203
|
+
|
204
|
+
it "must not allow duplicate steps" do
|
205
|
+
thumbs = @transloadit.step("thumbs", "/video/thumbs")
|
206
|
+
thumbs_duplicate = @transloadit.step("thumbs", "/video/encode")
|
207
|
+
options = {steps: [thumbs, thumbs_duplicate]}
|
208
|
+
assert_raises ArgumentError do
|
209
|
+
@assembly.create! open("lib/transloadit/version.rb"), **options
|
210
|
+
end
|
170
211
|
end
|
171
212
|
end
|
172
213
|
|
173
|
-
describe
|
214
|
+
describe "using assembly API methods" do
|
174
215
|
include WebMock::API
|
175
216
|
|
176
217
|
before do
|
@@ -178,84 +219,79 @@ describe Transloadit::Assembly do
|
|
178
219
|
@assembly = Transloadit::Assembly.new @transloadit
|
179
220
|
end
|
180
221
|
|
181
|
-
describe
|
182
|
-
|
183
|
-
|
184
|
-
stub = stub_request(:get, 'api2.transloadit.com/assemblies?params=%7B%22auth%22:%7B%22key%22:%22%22%7D%7D')
|
222
|
+
describe "when fetching all assemblies" do
|
223
|
+
it "must perform GET request to /assemblies" do
|
224
|
+
stub = stub_request(:get, "https://api2.transloadit.com/assemblies?params=%7B%22auth%22:%7B%22key%22:%22%22%7D%7D")
|
185
225
|
@assembly.list
|
186
226
|
|
187
227
|
assert_requested(stub)
|
188
228
|
end
|
189
229
|
|
190
|
-
it
|
191
|
-
VCR.use_cassette
|
230
|
+
it "must return a list of items" do
|
231
|
+
VCR.use_cassette "fetch_assemblies" do
|
192
232
|
response = @assembly.list
|
193
233
|
|
194
|
-
response[
|
195
|
-
response[
|
234
|
+
_(response["items"]).must_equal []
|
235
|
+
_(response["count"]).must_equal 0
|
196
236
|
end
|
197
237
|
end
|
198
238
|
end
|
199
239
|
|
200
|
-
describe
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
@assembly.get '76fe5df1c93a0a530f3e583805cf98b4'
|
240
|
+
describe "when fetching single assembly" do
|
241
|
+
it "must perform GET request to /assemblies/[id]" do
|
242
|
+
stub = stub_request(:get, "https://api2.transloadit.com/assemblies/76fe5df1c93a0a530f3e583805cf98b4")
|
243
|
+
@assembly.get "76fe5df1c93a0a530f3e583805cf98b4"
|
205
244
|
|
206
245
|
assert_requested(stub)
|
207
246
|
end
|
208
247
|
|
209
|
-
it
|
210
|
-
VCR.use_cassette
|
211
|
-
response = @assembly.get
|
212
|
-
response[
|
248
|
+
it "must get assembly with specified id" do
|
249
|
+
VCR.use_cassette "fetch_assembly_ok" do
|
250
|
+
response = @assembly.get "76fe5df1c93a0a530f3e583805cf98b4"
|
251
|
+
_(response["assembly_id"]).must_equal "76fe5df1c93a0a530f3e583805cf98b4"
|
213
252
|
end
|
214
253
|
end
|
215
254
|
end
|
216
255
|
|
217
|
-
describe
|
218
|
-
|
219
|
-
it 'must perform GET request to /assembly_notifications' do
|
256
|
+
describe "when fetching assembly notifications" do
|
257
|
+
it "must perform GET request to /assembly_notifications" do
|
220
258
|
stub = stub_request(
|
221
259
|
:get,
|
222
|
-
|
260
|
+
"https://api2.transloadit.com/assembly_notifications?params=%7B%22auth%22:%7B%22key%22:%22%22%7D%7D"
|
223
261
|
)
|
224
262
|
@assembly.get_notifications
|
225
263
|
|
226
264
|
assert_requested(stub)
|
227
265
|
end
|
228
266
|
|
229
|
-
it
|
230
|
-
VCR.use_cassette
|
267
|
+
it "must return a list of items" do
|
268
|
+
VCR.use_cassette "fetch_assembly_notifications" do
|
231
269
|
response = @assembly.get_notifications
|
232
270
|
|
233
|
-
response[
|
234
|
-
response[
|
271
|
+
_(response["items"]).must_equal []
|
272
|
+
_(response["count"]).must_equal 0
|
235
273
|
end
|
236
274
|
end
|
237
275
|
end
|
238
276
|
|
239
|
-
describe
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
response = @assembly.replay '55c965a063a311e6ba2d379ef10b28f7'
|
277
|
+
describe "when replaying assembly" do
|
278
|
+
it "must perform POST request to assemblies/[id]/replay" do
|
279
|
+
VCR.use_cassette "replay_assembly" do
|
280
|
+
response = @assembly.replay "55c965a063a311e6ba2d379ef10b28f7"
|
244
281
|
|
245
|
-
response[
|
246
|
-
response[
|
282
|
+
_(response["ok"]).must_equal "ASSEMBLY_REPLAYING"
|
283
|
+
_(response["assembly_id"]).must_equal "b8590300650211e6b826d727b2cfd9ce"
|
247
284
|
end
|
248
285
|
end
|
249
286
|
end
|
250
287
|
|
251
|
-
describe
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
response = @assembly.replay_notification '2ea5d21063ad11e6bc93e53395ce4e7d'
|
288
|
+
describe "when replaying assembly notification" do
|
289
|
+
it "must replay notification of sepcified assembly" do
|
290
|
+
VCR.use_cassette "replay_assembly_notification" do
|
291
|
+
response = @assembly.replay_notification "2ea5d21063ad11e6bc93e53395ce4e7d"
|
256
292
|
|
257
|
-
response[
|
258
|
-
response[
|
293
|
+
_(response["ok"]).must_equal "ASSEMBLY_NOTIFICATION_REPLAYED"
|
294
|
+
_(response["assembly_id"]).must_equal "2ea5d21063ad11e6bc93e53395ce4e7d"
|
259
295
|
end
|
260
296
|
end
|
261
297
|
end
|
@@ -1,78 +1,77 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
describe Transloadit::Request do
|
4
|
-
it
|
5
|
-
request = Transloadit::Request.new
|
6
|
-
request.must_be_kind_of Transloadit::Request
|
4
|
+
it "must allow initialization" do
|
5
|
+
request = Transloadit::Request.new "/"
|
6
|
+
_(request).must_be_kind_of Transloadit::Request
|
7
7
|
end
|
8
8
|
|
9
|
-
describe
|
9
|
+
describe "when performing a GET" do
|
10
10
|
before do
|
11
|
-
@request = Transloadit::Request.new
|
11
|
+
@request = Transloadit::Request.new "/"
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
15
|
-
@request.inspect.must_equal @request.url.to_s.inspect
|
14
|
+
it "must inspect to the API URL" do
|
15
|
+
_(@request.inspect).must_equal @request.url.to_s.inspect
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
19
|
-
VCR.use_cassette
|
20
|
-
@request.get(:
|
21
|
-
must_equal
|
18
|
+
it "must perform a GET against the resource" do
|
19
|
+
VCR.use_cassette "fetch_root" do
|
20
|
+
_(@request.get(params: {foo: "bar"})["ok"])
|
21
|
+
.must_equal "SERVER_ROOT"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
25
|
+
describe "with secret" do
|
26
26
|
before do
|
27
27
|
@request.secret = "tehsupersecrettoken"
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
31
|
-
@request.inspect.must_equal @request.url.to_s.inspect
|
30
|
+
it "must inspect to the API URL" do
|
31
|
+
_(@request.inspect).must_equal @request.url.to_s.inspect
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
35
|
-
VCR.use_cassette
|
36
|
-
@request.get(:
|
37
|
-
|
34
|
+
it "must perform a GET against the resource" do
|
35
|
+
VCR.use_cassette "fetch_root" do
|
36
|
+
_(@request.get(params: {foo: "bar"})["ok"])
|
37
|
+
.must_equal "SERVER_ROOT"
|
38
38
|
end
|
39
39
|
end
|
40
|
-
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
44
|
-
describe
|
45
|
-
it
|
46
|
-
@request = Transloadit::Request.new(
|
43
|
+
describe "when performing a POST" do
|
44
|
+
it "must perform a POST against the resource" do
|
45
|
+
@request = Transloadit::Request.new("assemblies", "secret")
|
47
46
|
|
48
|
-
VCR.use_cassette
|
49
|
-
@request.post(:
|
50
|
-
:
|
51
|
-
|
52
|
-
:
|
53
|
-
})[
|
47
|
+
VCR.use_cassette "post_assembly" do
|
48
|
+
_(@request.post(params: {
|
49
|
+
auth: {key: "",
|
50
|
+
expires: (Time.now + 10).utc.strftime("%Y/%m/%d %H:%M:%S+00:00")},
|
51
|
+
steps: {encode: {robot: "/video/encode"}}
|
52
|
+
})["ok"]).must_equal "ASSEMBLY_COMPLETED"
|
54
53
|
end
|
55
54
|
end
|
56
55
|
end
|
57
56
|
|
58
|
-
describe
|
59
|
-
it
|
60
|
-
@request = Transloadit::Request.new(
|
61
|
-
VCR.use_cassette
|
62
|
-
@request.put(:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
})[
|
57
|
+
describe "when performing a PUT" do
|
58
|
+
it "must perform a PUT against the resource" do
|
59
|
+
@request = Transloadit::Request.new("templates/55c965a063a311e6ba2d379ef10b28f7", "secret")
|
60
|
+
VCR.use_cassette "update_template" do
|
61
|
+
_(@request.put(params: {
|
62
|
+
name: "foo",
|
63
|
+
template: {key: "value"}
|
64
|
+
})["ok"]).must_equal "TEMPLATE_UPDATED"
|
66
65
|
end
|
67
66
|
end
|
68
67
|
end
|
69
68
|
|
70
|
-
describe
|
71
|
-
it
|
72
|
-
@request = Transloadit::Request.new(
|
69
|
+
describe "when performing a DELETE" do
|
70
|
+
it "must perform a DELETE against the resource" do
|
71
|
+
@request = Transloadit::Request.new("templates/55c965a063a311e6ba2d379ef10b28f7", "secret")
|
73
72
|
|
74
|
-
VCR.use_cassette
|
75
|
-
@request.delete[
|
73
|
+
VCR.use_cassette "delete_template" do
|
74
|
+
_(@request.delete["ok"]).must_equal "TEMPLATE_DELETED"
|
76
75
|
end
|
77
76
|
end
|
78
77
|
end
|