diff --git a/lib/pageflow/zencoder_video_output_definition.rb b/lib/pageflow/zencoder_video_output_definition.rb index abd63babd3..391bd8ba32 100644 --- a/lib/pageflow/zencoder_video_output_definition.rb +++ b/lib/pageflow/zencoder_video_output_definition.rb @@ -350,17 +350,17 @@ def hls_stream_definitions [ { source: 'hls-medium', - path: video_file.hls_medium.url(host: :hls_origin, default_protocol: 'http'), + path: video_file.hls_medium.url_relative_to(video_file.hls_playlist), bandwidth: 1769 }, { source: 'hls-low', - path: video_file.hls_low.url(host: :hls_origin, default_protocol: 'http'), + path: video_file.hls_low.url_relative_to(video_file.hls_playlist), bandwidth: 619 }, { source: 'hls-high', - path: video_file.hls_high.url(host: :hls_origin, default_protocol: 'http'), + path: video_file.hls_high.url_relative_to(video_file.hls_playlist), bandwidth: 3538 } ] + hls_highdef_stream_definitions @@ -371,12 +371,12 @@ def hls_highdef_stream_definitions [ { source: 'hls-fullhd', - path: video_file.hls_fullhd.url(host: :hls_origin, default_protocol: 'http'), + path: video_file.hls_fullhd.url_relative_to(video_file.hls_playlist), bandwidth: 8575 }, { source: 'hls-4k', - path: video_file.hls_4k.url(host: :hls_origin, default_protocol: 'http'), + path: video_file.hls_4k.url_relative_to(video_file.hls_playlist), bandwidth: 32000 } ] diff --git a/spec/pageflow/zencoder_video_output_definition_spec.rb b/spec/pageflow/zencoder_video_output_definition_spec.rb index ac671eb947..3026400043 100644 --- a/spec/pageflow/zencoder_video_output_definition_spec.rb +++ b/spec/pageflow/zencoder_video_output_definition_spec.rb @@ -108,13 +108,32 @@ module Pageflow end it 'uses relative urls in dash playlist' do - video_file = build(:video_file, :with_highdef_encoding) + video_file = build_stubbed(:video_file, :with_highdef_encoding) definition = ZencoderVideoOutputDefinition.new(video_file) expect(definition).to have_output .with_label('dash-playlist') .with_all_streams_having(path: a_relative_url) end + + it 'uses relative urls in hls playlist' do + video_file = build_stubbed(:video_file, :with_highdef_encoding) + definition = ZencoderVideoOutputDefinition.new(video_file) + + expect(definition).to have_output + .with_label('hls-playlist') + .with_all_streams_having(path: a_relative_url) + end + + it 'uses absolute urls in smil playlist' do + video_file = build_stubbed(:video_file, :with_highdef_encoding) + definition = ZencoderVideoOutputDefinition.new(video_file) + definition.skip_smil = false + + expect(definition).to have_output + .with_format('highwinds') + .with_all_streams_having(path: an_absolute_url) + end end end end diff --git a/spec/support/matchers/have_output.rb b/spec/support/matchers/have_output.rb index 4784c92071..08b4d3ebf1 100644 --- a/spec/support/matchers/have_output.rb +++ b/spec/support/matchers/have_output.rb @@ -7,6 +7,10 @@ output_matchers[:label] = label end + chain :with_format do |format| + output_matchers[:format] = format + end + chain :with_stream do |stream_attributes| output_matchers[:streams] = array_including(hash_including(stream_attributes)) end diff --git a/spec/support/matchers/url_matchers.rb b/spec/support/matchers/url_matchers.rb index 08aa947c8a..49a4b658d4 100644 --- a/spec/support/matchers/url_matchers.rb +++ b/spec/support/matchers/url_matchers.rb @@ -12,3 +12,16 @@ end RSpec::Matchers.alias_matcher :a_relative_url, :be_relative_url + +RSpec::Matchers.define :be_absolute_url do + match do |url| + begin + uri = URI.parse(url) + uri.host.present? && uri.scheme.present? + rescue URI::InvalidURIError + false + end + end +end + +RSpec::Matchers.alias_matcher :an_absolute_url, :be_absolute_url