Skip to content

Commit

Permalink
Fix claim match segments (#355)
Browse files Browse the repository at this point in the history
The `matchSegments` sub-key should be camelCase, not snake_case per the
documentation.
  • Loading branch information
dgb committed Jun 26, 2019
1 parent e5024dd commit 8568132
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/yt/collections/claims.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ def eager_load_items_from(items)
end

def match_attributes(attributes = {})
attributes.tap do |match_data|
match_data[:match_segments] = match_data[:match_segments].map do |segment|
{ manual_segment: (segment[:manual_segment] || segment).slice(:start, :finish) }
end
segments = attributes[:match_segments].map do |segment|
{ manual_segment: (segment[:manual_segment] || segment).slice(:start, :finish) }
end
{ matchSegments: segments }
end

# @return [Hash] the parameters to submit to YouTube to list claims
Expand Down
9 changes: 8 additions & 1 deletion spec/collections/claims_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@
end

it 'calls do_insert with appropriate body' do
body = {
asset_id: 'some_asset_id',
video_id: 'some_video_id',
content_type: 'audiovisual',
policy: { id: 'some_policy_id' },
match_info: { matchSegments: [ { manual_segment: { start: "00:01:00.000", finish: "00:02:00.000" } } ] }
}
expect(collection).to have_received(:do_insert).with(
params: { is_manual_claim: true, on_behalf_of_content_owner: content_owner.owner_name },
body: attributes.except(:is_manual_claim)
body: body
)
end
end
Expand Down

0 comments on commit 8568132

Please sign in to comment.