Skip to content

Commit bb650d1

Browse files
committed
Fix Array<Hash> support for steps
1 parent d8b81c7 commit bb650d1

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

lib/transloadit/assembly.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def _wrap_steps_in_hash(steps)
144144
when Hash then steps
145145
when Transloadit::Step then steps.to_hash
146146
else
147-
if steps.uniq(&:name) != steps
147+
if steps.uniq != steps
148148
raise ArgumentError, "There are different Assembly steps using the same name"
149149
end
150150
steps.inject({}) { |h, s| h.update s }

lib/transloadit/step.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ def to_json
7979
MultiJson.dump(to_hash)
8080
end
8181

82+
def eql?(other)
83+
name == other.name
84+
end
85+
8286
protected
8387

8488
attr_writer :robot

test/unit/transloadit/test_assembly.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,30 @@
211211
end
212212
end
213213

214+
describe "with multiple hash steps" do
215+
before do
216+
@encode = { "encode": { "robot": "/video/encode" } }
217+
@thumbs = { "thumbs": { "robot": "/video/thumbs" } }
218+
219+
@assembly = Transloadit::Assembly.new @transloadit,
220+
steps: [@encode, @thumbs]
221+
end
222+
223+
it "must wrap its steps into one hash" do
224+
_(@assembly.to_hash[:steps].keys).must_include @encode.keys
225+
_(@assembly.to_hash[:steps].keys).must_include @thumbs.keys
226+
end
227+
228+
it "must not allow duplicate steps" do
229+
thumbs = { "thumbs": { "robot": "/video/thumbs" } }
230+
thumbs_duplicate = { "thumbs": { "robot": "/video/encode" } }
231+
options = {steps: [thumbs, thumbs_duplicate]}
232+
assert_raises ArgumentError do
233+
@assembly.create! open("lib/transloadit/version.rb"), **options
234+
end
235+
end
236+
end
237+
214238
describe "using assembly API methods" do
215239
include WebMock::API
216240

0 commit comments

Comments
 (0)