Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 3.0.0 / ????-??-?? ###

* Prevent duplicate assembly steps [#49](https://github.com/transloadit/ruby-sdk/issues/27) (@ifedapoolarewaju)

### 2.0.1 / 2017-01-23 ###

* Use the ssl enabled url as the API base url (@ifedapoolarewaju)
Expand Down
3 changes: 3 additions & 0 deletions lib/transloadit/assembly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def _wrap_steps_in_hash(steps)
when Hash then steps
when Transloadit::Step then steps.to_hash
else
if steps.uniq(&:name) != steps
raise ArgumentError, "There are different Assembly steps using the same name"
end
steps.inject({}) {|h, s| h.update s }
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_transloadit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@

it 'must create assemblies with multiple steps' do
steps = [
@transloadit.step(nil, nil),
@transloadit.step(nil, nil),
@transloadit.step('step1', nil),
@transloadit.step('step2', nil),
]

assembly = @transloadit.assembly :steps => steps
Expand Down
9 changes: 9 additions & 0 deletions test/unit/transloadit/test_assembly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@
@assembly.to_hash[:steps].keys.must_include @encode.name
@assembly.to_hash[:steps].keys.must_include @thumbs.name
end

it 'must not allow duplicate steps' do
thumbs = @transloadit.step('thumbs', '/video/thumbs')
thumbs_duplicate = @transloadit.step('thumbs', '/video/encode')
options = { :steps => [ thumbs, thumbs_duplicate ] }
assert_raises ArgumentError do
response = @assembly.create! open('lib/transloadit/version.rb'), options
end
end
end

describe 'using assembly API methods' do
Expand Down