-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for compatibility with hydra-pcdm and hydra-works
- Loading branch information
1 parent
b5a3f50
commit 262835c
Showing
2 changed files
with
62 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require 'spec_helper' | ||
require 'hydra/works' | ||
|
||
describe Hydra::Derivatives::Processor do | ||
|
||
before(:all) do | ||
class IndirectContainerObject < ActiveFedora::Base | ||
contains "content" | ||
contains "thumbnail" | ||
end | ||
|
||
class DirectContainerObject < Hydra::Works::GenericFile::Base | ||
end | ||
# If we only want to test against hydra-pcdm and not hydra-works, we can use this: | ||
# class DirectContainerObject < Hydra::PCDM::Object | ||
# def original_file | ||
# file_of_type(::RDF::URI("http://pcdm.org/OriginalFile")) | ||
# end | ||
# | ||
# def thumbnail | ||
# file_of_type(::RDF::URI("http://pcdm.org/ThumbnailImage")) | ||
# end | ||
# end | ||
end | ||
|
||
let(:object) { IndirectContainerObject.new } | ||
let(:source_name) { 'content' } | ||
let(:directives) { { thumb: "100x100>" } } | ||
|
||
subject { Hydra::Derivatives::Processor.new(object, source_name, directives)} | ||
|
||
describe "source_file" do | ||
it "retrieves the specified source" do | ||
expect(subject.source_file).to eq(object.content) | ||
end | ||
end | ||
|
||
describe "output_file" do | ||
it "retrieves the correct output file" do | ||
expect(subject.output_file('thumbnail')).to eq(object.thumbnail) | ||
end | ||
end | ||
|
||
describe "when files are directly contained by object (like files in a PCDM::Object)" do | ||
let(:object) { DirectContainerObject.new } | ||
let(:source_name) { 'original_file' } | ||
before do | ||
object.save | ||
end | ||
it "is able to find source_file and output_file" do | ||
expect(subject.source_file).to eq(object.original_file) | ||
expect(subject.output_file).to eq(object.thumbnail) | ||
end | ||
end | ||
end |