Skip to content

Commit

Permalink
Merge pull request #5334 from avalonmediasystem/playlist_manifest_auth
Browse files Browse the repository at this point in the history
Fix auth check for playlist manifest generation
  • Loading branch information
masaball authored Aug 30, 2023
2 parents cb0ca4a + a881e9c commit 2cb858e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/playlists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ def manifest
authorize! :read, @playlist

canvas_presenters = @playlist.items.collect do |item|
cannot_read_item = cannot? :read, @master_file
@master_file = item.clip.master_file
cannot_read_item = cannot? :read, @master_file
stream_info = if @master_file.nil?
nil
else
Expand Down
16 changes: 16 additions & 0 deletions spec/controllers/playlists_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -596,5 +596,21 @@
expect(parsed_response["service"]).not_to be_present
end
end

context "playlist item auth" do
let(:playlist) { FactoryBot.create(:playlist, items: [playlist_item, playlist_item_2], visibility: Playlist::PUBLIC) }
let(:playlist_item_2) { FactoryBot.create(:playlist_item, clip: clip_2) }
let(:clip_2) { FactoryBot.create(:avalon_clip, master_file: master_file_2) }
let(:master_file_2) { FactoryBot.create(:master_file, :with_derivative, media_object: media_object_2) }
let(:media_object_2) { FactoryBot.create(:published_media_object, visibility: 'restricted') }

it "returns populated canvas for public item and blank canvas for restricted item" do
get :manifest, format: 'json', params: { id: playlist.id }, session: valid_session
parsed_response = JSON.parse(response.body)
expect(parsed_response['items'].length).to eq 2
expect(parsed_response['items'][0]['items'][0].keys).to include 'items'
expect(parsed_response['items'][1]['items'][0].keys).to_not include 'items'
end
end
end
end

0 comments on commit 2cb858e

Please sign in to comment.