Skip to content

Commit

Permalink
prevent duplicate assembly steps
Browse files Browse the repository at this point in the history
fixes #27
  • Loading branch information
ifedapoolarewaju committed May 22, 2018
1 parent 4963676 commit c57ab75
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
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

0 comments on commit c57ab75

Please sign in to comment.