Skip to content

Commit

Permalink
Adding the update action to replace formats on the encoding.com queue…
Browse files Browse the repository at this point in the history
… items
  • Loading branch information
knaveofdiamonds committed Dec 4, 2009
1 parent d01acfb commit b8cc18d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/encoding_dot_com/facade.rb
Expand Up @@ -68,6 +68,17 @@ def process(media_id)
end
end

# Replaces all the formats in an item on the encoding.com queue
# with the formats provided.
#
# formats is a hash of destination urls => Format objects
def update(media_id, formats={})
make_request("UpdateMedia") do |q|
q.mediaid media_id
formats.each {|url, format| format.build_xml(q, url) }
end
end

# Returns a MediaInfo object with some attributes of the video
# identified by media_id.
def info(media_id)
Expand Down
24 changes: 24 additions & 0 deletions spec/facade_spec.rb
Expand Up @@ -183,6 +183,30 @@ def expect_response_xml(response_xml)
end
end

describe "updating formats of an item already in the encoding.com queue" do
it "should have an action of 'UpdateMedia'." do
expect_xml_with_xpath("/query/action[text()='UpdateMedia']")
@facade.update(5678, {})
end

it "should have a mediaid of 1234." do
expect_xml_with_xpath("/query/mediaid[text()='5678']")
@facade.update(5678, {})
end

it "should include the formats provided" do
expect_xml_with_xpath("/query/format/output[text()='flv']")
format = EncodingDotCom::Format.create("output" => "flv")
@facade.update(5678, {stub("destination") => format})
end

it "should include the destination urls in the formats provided" do
expect_xml_with_xpath("/query/format/destination[text()='http://example.com']")
format = EncodingDotCom::Format.create("output" => "flv")
@facade.update(5678, {"http://example.com" => format})
end
end

describe "getting information about a specified media item" do
it "should have an action of 'GetMediaInfo'." do
expect_xml_with_xpath("/query/action[text()='GetMediaInfo']")
Expand Down

0 comments on commit b8cc18d

Please sign in to comment.