-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #150 from projecthydra-labs/remove_derivatives_spec
Provide test coverage for a/v specs and remove CurationConcerns::CreateDerivativesService
- Loading branch information
Showing
13 changed files
with
143 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
curation_concerns-models/app/services/curation_concerns/create_derivatives_service.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
spec/models/curation_concerns/generic_file/derivatives_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
require 'spec_helper' | ||
|
||
describe CurationConcerns::GenericFile do | ||
|
||
describe 'audiovisual transcoding' do | ||
before do | ||
file = File.open(File.join(fixture_path, file_name), 'r') | ||
Hydra::Works::UploadFileToGenericFile.call(generic_file, file) | ||
allow_any_instance_of(Hydra::Works::GenericFile::Base).to receive(:mime_type).and_return(mime_type) | ||
generic_file.save! | ||
end | ||
|
||
|
||
context 'with a video (.avi) file', unless: $in_travis do | ||
let(:mime_type) { 'video/avi' } | ||
let(:file_name) { 'countdown.avi' } | ||
let(:generic_file) { GenericFile.create { |gf| gf.apply_depositor_metadata('jcoyne@example.com') } } | ||
|
||
it 'transcodes to webm and mp4' do | ||
generic_file.create_derivatives | ||
derivative = generic_file.webm | ||
expect(derivative).not_to be_nil | ||
expect(derivative.content).not_to be_nil | ||
expect(derivative.mime_type).to eq('video/webm') | ||
|
||
derivative2 = generic_file.mp4 | ||
expect(derivative2).not_to be_nil | ||
expect(derivative2.content).not_to be_nil | ||
expect(derivative2.mime_type).to eq('video/mp4') | ||
end | ||
end | ||
|
||
context 'with an audio (.wav) file', unless: $in_travis do | ||
let(:mime_type) { 'audio/wav' } | ||
let(:file_name) { 'piano_note.wav' } | ||
let(:generic_file) { GenericFile.create { |gf| gf.apply_depositor_metadata('jcoyne@example.com') } } | ||
|
||
it 'transcodes to mp3 and ogg' do | ||
generic_file.create_derivatives | ||
derivative = generic_file.mp3 | ||
expect(derivative).not_to be_nil | ||
expect(derivative.content).not_to be_nil | ||
expect(derivative.mime_type).to eq('audio/mpeg') | ||
|
||
derivative2 = generic_file.ogg | ||
expect(derivative2).not_to be_nil | ||
expect(derivative2.content).not_to be_nil | ||
expect(derivative2.mime_type).to eq('audio/ogg') | ||
end | ||
end | ||
|
||
context 'with an mp3 file', unless: $in_travis do | ||
let(:mime_type) { 'audio/mpeg' } | ||
let(:file_name) { 'test5.mp3' } | ||
let(:generic_file) { GenericFile.create { |gf| gf.apply_depositor_metadata('jcoyne@example.com') } } | ||
|
||
xit 'should copy the content to the mp3 datastream and transcode to ogg' do | ||
generic_file.create_derivatives | ||
derivative = generic_file.mp3 | ||
|
||
expect(derivative.size).to eq(generic_file.original_file.size) | ||
expect(derivative.mime_type).to eq('audio/mpeg') | ||
derivative2 = generic_file.ogg | ||
expect(derivative2.content).not_to be_nil | ||
expect(derivative2.mime_type).to eq('audio/ogg') | ||
end | ||
end | ||
|
||
context 'with an ogg file', unless: $in_travis do | ||
let(:mime_type) { 'audio/ogg' } | ||
let(:file_name) { 'Example.ogg' } | ||
let(:generic_file) { GenericFile.create { |gf| gf.apply_depositor_metadata('jcoyne@example.com') } } | ||
|
||
xit 'should copy the content to the ogg datastream and transcode to mp3' do | ||
generic_file.create_derivatives | ||
derivative = generic_file.mp3 | ||
expect(derivative).not_to be_nil | ||
expect(derivative.content).not_to be_nil | ||
expect(derivative.mime_type).to eq('audio/mpeg') | ||
|
||
derivative2 = generic_file.ogg | ||
expect(derivative2).not_to be_nil | ||
expect(derivative2.size).to eq(generic_file.original_file.size) | ||
expect(derivative2.mime_type).to eq('audio/ogg') | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.