From bb650d11b699ec9080f28a4029e0b63b8f7ebaff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0=2E=20Emre=20Kutlu?= Date: Wed, 22 Apr 2026 10:43:46 +0300 Subject: [PATCH] Fix Array support for steps --- lib/transloadit/assembly.rb | 2 +- lib/transloadit/step.rb | 4 ++++ test/unit/transloadit/test_assembly.rb | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/transloadit/assembly.rb b/lib/transloadit/assembly.rb index 5d0f1c7..bf9befd 100644 --- a/lib/transloadit/assembly.rb +++ b/lib/transloadit/assembly.rb @@ -144,7 +144,7 @@ def _wrap_steps_in_hash(steps) when Hash then steps when Transloadit::Step then steps.to_hash else - if steps.uniq(&:name) != steps + if steps.uniq != steps raise ArgumentError, "There are different Assembly steps using the same name" end steps.inject({}) { |h, s| h.update s } diff --git a/lib/transloadit/step.rb b/lib/transloadit/step.rb index 5219610..25873c0 100644 --- a/lib/transloadit/step.rb +++ b/lib/transloadit/step.rb @@ -79,6 +79,10 @@ def to_json MultiJson.dump(to_hash) end + def eql?(other) + name == other.name + end + protected attr_writer :robot diff --git a/test/unit/transloadit/test_assembly.rb b/test/unit/transloadit/test_assembly.rb index 0202ca2..161365b 100644 --- a/test/unit/transloadit/test_assembly.rb +++ b/test/unit/transloadit/test_assembly.rb @@ -211,6 +211,30 @@ end end + describe "with multiple hash steps" do + before do + @encode = { "encode": { "robot": "/video/encode" } } + @thumbs = { "thumbs": { "robot": "/video/thumbs" } } + + @assembly = Transloadit::Assembly.new @transloadit, + steps: [@encode, @thumbs] + end + + it "must wrap its steps into one hash" do + _(@assembly.to_hash[:steps].keys).must_include @encode.keys + _(@assembly.to_hash[:steps].keys).must_include @thumbs.keys + end + + it "must not allow duplicate steps" do + thumbs = { "thumbs": { "robot": "/video/thumbs" } } + thumbs_duplicate = { "thumbs": { "robot": "/video/encode" } } + options = {steps: [thumbs, thumbs_duplicate]} + assert_raises ArgumentError do + @assembly.create! open("lib/transloadit/version.rb"), **options + end + end + end + describe "using assembly API methods" do include WebMock::API