diff --git a/app/controllers/master_files_controller.rb b/app/controllers/master_files_controller.rb index 1589b5d0ca..0c0735e9ec 100644 --- a/app/controllers/master_files_controller.rb +++ b/app/controllers/master_files_controller.rb @@ -246,6 +246,8 @@ def get_frame end if content send_data content, :filename => "#{params[:type]}-#{@master_file.id.split(':')[1]}", :disposition => :inline, :type => mimeType + elsif @master_file.is_video? + redirect_to ActionController::Base.helpers.asset_path('video_icon.png') else redirect_to ActionController::Base.helpers.asset_path('audio_icon.png') end diff --git a/spec/controllers/master_files_controller_spec.rb b/spec/controllers/master_files_controller_spec.rb index cebbcec7c7..21f0d77277 100644 --- a/spec/controllers/master_files_controller_spec.rb +++ b/spec/controllers/master_files_controller_spec.rb @@ -373,6 +373,20 @@ class << file expect(response.body).to eq('fake image content') expect(response.headers['Content-Type']).to eq('image/jpeg') end + + context "video without thumbnail" do + subject(:mf) { FactoryBot.create(:master_file, :with_media_object) } + it "returns video_icon.png" do + expect(get :get_frame, params: { id: mf.id, type: 'thumbnail', size: 'bar' }).to redirect_to(ActionController::Base.helpers.asset_path('video_icon.png')) + end + end + + context "audio" do + subject(:mf) { FactoryBot.create(:master_file, :audio, :with_media_object) } + it "returns audio_icon.png" do + expect(get :get_frame, params: { id: mf.id, type: 'thumbnail', size: 'bar' }).to redirect_to(ActionController::Base.helpers.asset_path('audio_icon.png')) + end + end end context 'read from solr' do