Skip to content

Commit

Permalink
Only fetch if there's no label.
Browse files Browse the repository at this point in the history
  • Loading branch information
Trey Terrell committed Jan 27, 2015
1 parent 063ed2d commit dd94128
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/oregon_digital/rdf/controlled.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def rdf_label
node? ? [] : [rdf_subject.to_s]
end

def fetch
return unless rdf_label == [rdf_subject.to_s] || rdf_label.empty?
super
end

##
# Class methods for adding and using controlled vocabularies
module ClassMethods
Expand Down
34 changes: 34 additions & 0 deletions spec/lib/oregon_digital/rdf/controlled_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,40 @@ class DummyAuthority < ActiveFedora::Rdf::Resource
end
end

describe "#fetch" do
subject { DummyAuthority.new(uri) }
let(:uri) { "http://purl.org/dc/dcmitype/Image" }
before do
allow(subject).to receive(:load)
end
context "if there's a label" do
before do
subject << [subject.rdf_subject, RDF::SKOS.prefLabel, "Test"]
subject.fetch
end
it "should not call #load" do
expect(subject).not_to have_received(:load)
end
end
context "if there's no label" do
before do
subject.fetch
end
it "should call #load" do
expect(subject).to have_received(:load)
end
end
context "if it has no uri" do
let(:uri) { nil }
before do
subject.fetch
end
it "should call #load" do
expect(subject).to have_received(:load)
end
end
end

describe '#list_terms' do
it 'should list terms from registered StrictVocabs' do
subject.vocabularies.each do |name, vocab|
Expand Down

0 comments on commit dd94128

Please sign in to comment.