Skip to content

Commit

Permalink
Set mimeTypes for RelsExtDatastream and NokogiriDatastream
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Nov 18, 2011
1 parent 4f20648 commit 1042445
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 24 deletions.
7 changes: 5 additions & 2 deletions History.txt
@@ -1,6 +1,9 @@
3.1.2
correctly handling non-default pid_namespace
info uri support; rdf:type predicate compatibility with Fedora
correctly handling non-default pid_namespace (Benjamin Armintor)
info uri support; rdf:type predicate compatibility with Fedora(Benjamin Armintor)
more flexibility for initializing Rubydora (Michael B. Klein)
NokogiriDatastream and RELS-EXT datastream set mimeType (Justin Coyne)


3.1.1
adds support for better handling of literal values in the RELS-EXT datastream.
Expand Down
6 changes: 6 additions & 0 deletions lib/active_fedora/nokogiri_datastream.rb
Expand Up @@ -16,6 +16,12 @@ class NokogiriDatastream < Datastream
alias_method(:om_update_values, :update_values) unless method_defined?(:om_update_values)

attr_accessor :internal_solr_doc

before_create :add_mime_type

def add_mime_type
self.mimeType= 'text/xml'
end

# Create an instance of this class based on xml content
# @param [String, File, Nokogiri::XML::Node] xml the xml content to build from
Expand Down
8 changes: 7 additions & 1 deletion lib/active_fedora/rels_ext_datastream.rb
Expand Up @@ -10,7 +10,13 @@ class RelsExtDatastream < Datastream

include Solrizer::FieldNameMapper
attr_accessor :model


before_create :add_mime_type

def add_mime_type
self.mimeType= 'application/rdf+xml'
end

def serialize!
self.content = to_rels_ext() if model.relationships_are_dirty
model.relationships_are_dirty = false
Expand Down
2 changes: 1 addition & 1 deletion lib/active_fedora/version.rb
@@ -1,3 +1,3 @@
module ActiveFedora
VERSION = "3.1.1"
VERSION = "3.1.2"
end
12 changes: 0 additions & 12 deletions lib/tasks/active_fedora_dev.rake
Expand Up @@ -69,12 +69,6 @@ namespace :active_fedora do
t.rcov_opts << ['--exclude', 'spec']
end

desc "Refresh test fixtres"
task :refresh_fixtures do
Rake::Task["active_fedora:clean_jetty"].invoke
Rake::Task["active_fedora:load_fixtures"].invoke
end

task :clean_jetty do
Dir.chdir("./jetty")
system("git clean -f -d")
Expand All @@ -83,12 +77,6 @@ namespace :active_fedora do
end

task :load_fixtures => :environment do
# require 'solrizer'
# require 'solrizer-fedora'
# require 'spec/samples/models/hydrangea_article'
# ENV["FEDORA_HOME"] ||= File.expand_path(File.join(File.dirname(__FILE__),'..','..','jetty','fedora','default'))
# retval = `$FEDORA_HOME/client/bin/fedora-ingest-demos.sh localhost 8983 fedoraAdmin fedoraAdmin http`
# puts "loaded demo objects #{retval}"
ActiveFedora.init unless Thread.current[:repo]

ENV["pid"] = "hydrangea:fixture_mods_article1"
Expand Down
8 changes: 5 additions & 3 deletions spec/integration/nokogiri_datastream_spec.rb
Expand Up @@ -21,12 +21,14 @@ class HydrangeaArticle2 < ActiveFedora::Base
end
end

@pid = "hydrangea:fixture_mods_article1"
@test_solr_object = HydrangeaArticle2.load_instance_from_solr(@pid)
@test_object = HydrangeaArticle2.load_instance(@pid)
end

describe '.term_values' do
before do
@pid = "hydrangea:fixture_mods_article1"
@test_solr_object = HydrangeaArticle2.load_instance_from_solr(@pid)
@test_object = HydrangeaArticle2.load_instance(@pid)
end

it "should return the same values whether getting from solr or Fedora" do
@test_solr_object.datastreams["descMetadata"].term_values(:name,:role,:text).should == ["Creator","Contributor","Funder","Host"]
Expand Down
6 changes: 4 additions & 2 deletions spec/unit/nokogiri_datastream_spec.rb
Expand Up @@ -25,7 +25,7 @@

after(:each) do
end

it "should include the Solrizer::XML::TerminologyBasedSolrizer for .to_solr support" do
ActiveFedora::NokogiriDatastream.included_modules.should include(Solrizer::XML::TerminologyBasedSolrizer)
end
Expand Down Expand Up @@ -171,10 +171,12 @@
end
it "should persist the product of .to_xml in fedora" do
@test_ds.expects(:new?).returns(true).twice
@mock_repo.expects(:add_datastream).with(:pid => nil, :dsid => 'descMetadata', :checksumType => 'DISABLED', :versionable => true, :content => 'fake xml', :controlGroup => 'M', :dsState => 'A')
@mock_repo.expects(:datastream).with(:pid => nil, :dsid => 'descMetadata')
@mock_repo.expects(:add_datastream).with(:pid => nil, :dsid => 'descMetadata', :checksumType => 'DISABLED', :versionable => true, :content => 'fake xml', :controlGroup => 'M', :dsState => 'A', :mimeType=>'text/xml')
@test_ds.expects(:to_xml).returns("fake xml")
@test_ds.serialize!
@test_ds.save
@test_ds.mimeType.should == 'text/xml'
end
end

Expand Down
14 changes: 11 additions & 3 deletions spec/unit/rels_ext_datastream_spec.rb
Expand Up @@ -21,9 +21,17 @@
mock_inner.stubs(:pid).returns(@pid)
@test_ds = ActiveFedora::RelsExtDatastream.new(mock_inner, "RELS-EXT")
end

it 'should respond to #save' do
@test_ds.should respond_to(:save)

describe "#save" do
before do
@mock_repo.expects(:add_datastream).with(:pid => 'test:sample_pid', :dsid => 'RELS-EXT', :checksumType => 'DISABLED', :versionable => true, :content => 'fake xml', :controlGroup => 'M', :dsState => 'A', :mimeType=>'application/rdf+xml')
@mock_repo.expects(:datastream).with(:pid => 'test:sample_pid', :dsid => 'RELS-EXT')
@test_ds.content = 'fake xml'
end
it 'should set the mime type' do
@test_ds.save
@test_ds.mimeType.should == 'application/rdf+xml'
end
end


Expand Down

0 comments on commit 1042445

Please sign in to comment.