active-fedora 4.0.0.rc11 → 4.0.0.rc12
Sign up to get free protection for your applications and to get access to all the features.
- data/CONSOLE_GETTING_STARTED.textile +1 -1
- data/Gemfile.lock +7 -7
- data/History.txt +3 -1
- data/active-fedora.gemspec +2 -3
- data/lib/active_fedora.rb +2 -4
- data/lib/active_fedora/file_configurator.rb +0 -2
- data/lib/active_fedora/fixture_loader.rb +4 -1
- data/lib/active_fedora/persistence.rb +4 -4
- data/lib/active_fedora/rels_ext_datastream.rb +1 -0
- data/lib/active_fedora/solr_digital_object.rb +6 -3
- data/lib/active_fedora/solr_service.rb +8 -0
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora.rake +18 -41
- data/lib/tasks/active_fedora_dev.rake +1 -1
- data/spec/integration/base_spec.rb +42 -0
- data/spec/integration/nokogiri_datastream_spec.rb +0 -6
- data/spec/unit/active_fedora_spec.rb +1 -3
- data/spec/unit/datastream_spec.rb +2 -2
- data/spec/unit/metadata_datastream_spec.rb +2 -2
- data/spec/unit/nokogiri_datastream_spec.rb +1 -1
- data/spec/unit/rels_ext_datastream_spec.rb +2 -2
- data/spec/unit/solr_digital_object_spec.rb +20 -0
- data/spec/unit/solr_service_spec.rb +19 -1
- metadata +14 -10
@@ -114,7 +114,7 @@ To see a more complete implementation of importing and deleting Fedora objects,
|
|
114
114
|
|
115
115
|
h2. Define a Model for Your (Active)Fedora Objects
|
116
116
|
|
117
|
-
Look at the SpecialThing model defined in
|
117
|
+
Look at the SpecialThing model defined in spec/samples/special_thing.rb to see how you declare an ActiveFedora model.
|
118
118
|
|
119
119
|
Create an instance of the SpecialThing class:
|
120
120
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active-fedora (4.0.0.
|
4
|
+
active-fedora (4.0.0.rc12)
|
5
5
|
activeresource (>= 3.0.0)
|
6
6
|
activesupport (>= 3.0.0)
|
7
7
|
equivalent-xml
|
@@ -11,9 +11,9 @@ PATH
|
|
11
11
|
nokogiri
|
12
12
|
om (>= 1.5.3)
|
13
13
|
rdf
|
14
|
-
rdf-rdfxml
|
14
|
+
rdf-rdfxml (= 0.3.5)
|
15
15
|
rsolr
|
16
|
-
rubydora (~> 0.5.
|
16
|
+
rubydora (~> 0.5.7)
|
17
17
|
solrizer (~> 1.2.0)
|
18
18
|
xml-simple (>= 1.0.12)
|
19
19
|
|
@@ -61,7 +61,7 @@ GEM
|
|
61
61
|
metaclass (~> 0.0.1)
|
62
62
|
multi_json (1.1.0)
|
63
63
|
multipart-post (1.1.2)
|
64
|
-
nokogiri (1.5.
|
64
|
+
nokogiri (1.5.2)
|
65
65
|
nori (1.1.0)
|
66
66
|
om (1.5.3)
|
67
67
|
mediashelf-loggable
|
@@ -75,7 +75,7 @@ GEM
|
|
75
75
|
rdf (>= 0.3.4)
|
76
76
|
rest-client (1.6.7)
|
77
77
|
mime-types (>= 1.16)
|
78
|
-
rsolr (1.0.
|
78
|
+
rsolr (1.0.7)
|
79
79
|
builder (>= 2.1.2)
|
80
80
|
rspec (2.8.0)
|
81
81
|
rspec-core (~> 2.8.0)
|
@@ -85,7 +85,7 @@ GEM
|
|
85
85
|
rspec-expectations (2.8.0)
|
86
86
|
diff-lcs (~> 1.1.2)
|
87
87
|
rspec-mocks (2.8.0)
|
88
|
-
rubydora (0.5.
|
88
|
+
rubydora (0.5.7)
|
89
89
|
activemodel
|
90
90
|
activesupport
|
91
91
|
fastercsv
|
@@ -108,7 +108,7 @@ GEM
|
|
108
108
|
om (>= 1.5.0)
|
109
109
|
stomp
|
110
110
|
xml-simple
|
111
|
-
stomp (1.2.
|
111
|
+
stomp (1.2.1)
|
112
112
|
wasabi (2.1.0)
|
113
113
|
nokogiri (>= 1.4.0)
|
114
114
|
xml-simple (1.1.1)
|
data/History.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
4.0.0.
|
1
|
+
4.0.0.rc12
|
2
2
|
Removed deprecations
|
3
3
|
* allowing :fedora level in fedora.yml
|
4
4
|
* automatic includes of Relationships and FileMethods is removed
|
@@ -18,6 +18,8 @@ HYDRA-753 has_metadata should accept :versionable as part of the spec.
|
|
18
18
|
HYDRA-755 Instantiate un-spec'ed datastreams in SolrDigitalObject
|
19
19
|
HYDRA-758 Added ActiveFedora::Base.exists?
|
20
20
|
Fixes for Ruby 1.9 compatibility
|
21
|
+
HYDRA-741 Use fixture loader in repo:* rake tasks. Parameters changed to foxml and dir.
|
22
|
+
rubydora to 0.5.7
|
21
23
|
|
22
24
|
3.3.2
|
23
25
|
HYDRA-745 No need to require :url be present on external datastreams
|
data/active-fedora.gemspec
CHANGED
@@ -26,14 +26,13 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_dependency("activesupport", '>= 3.0.0')
|
27
27
|
s.add_dependency("mediashelf-loggable")
|
28
28
|
s.add_dependency("equivalent-xml")
|
29
|
-
s.add_dependency("rubydora", '~>0.5.
|
29
|
+
s.add_dependency("rubydora", '~>0.5.7')
|
30
30
|
s.add_dependency("rdf")
|
31
|
-
s.add_dependency("rdf-rdfxml")
|
31
|
+
s.add_dependency("rdf-rdfxml", '0.3.5') # 0.3.6 is broken
|
32
32
|
s.add_development_dependency("yard")
|
33
33
|
s.add_development_dependency("RedCloth") # for RDoc formatting
|
34
34
|
s.add_development_dependency("rake")
|
35
35
|
# s.add_development_dependency("rcov") # not ruby 1.9 compatible
|
36
|
-
# s.add_development_dependency("solrizer-fedora", "~>1.2.5") # used by the fixtures rake tasks
|
37
36
|
s.add_development_dependency("jettywrapper", ">=1.2.0")
|
38
37
|
s.add_development_dependency("rspec", "~> 2.0")
|
39
38
|
s.add_development_dependency("mocha", ">= 0.9.8")
|
data/lib/active_fedora.rb
CHANGED
@@ -111,11 +111,9 @@ module ActiveFedora #:nodoc:
|
|
111
111
|
elsif defined?(ENV['environment']) and !(ENV['environment'].nil?)
|
112
112
|
return ENV['environment']
|
113
113
|
elsif defined?(ENV['RAILS_ENV']) and !(ENV['RAILS_ENV'].nil?)
|
114
|
-
|
115
|
-
ENV['environment'] = ENV['RAILS_ENV']
|
116
|
-
return ENV['environment']
|
114
|
+
raise RuntimeError, "You're depending on RAILS_ENV for setting your environment. Please use ENV['environment'] for non-rails environment setting: 'rake foo:bar environment=test'"
|
117
115
|
else
|
118
|
-
ENV['environment'] = 'development'
|
116
|
+
ENV['environment'] = 'development'
|
119
117
|
end
|
120
118
|
end
|
121
119
|
|
@@ -17,6 +17,9 @@ module ActiveFedora
|
|
17
17
|
rescue ActiveFedora::ObjectNotFoundError
|
18
18
|
logger.debug "The object #{pid} has already been deleted (or was never created)."
|
19
19
|
0
|
20
|
+
rescue Errno::ECONNREFUSED => e
|
21
|
+
logger.debug "Can't connect to Fedora! Are you sure jetty is running?"
|
22
|
+
0
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
@@ -35,7 +38,7 @@ module ActiveFedora
|
|
35
38
|
ActiveFedora::Base.find(pid).update_index
|
36
39
|
end
|
37
40
|
|
38
|
-
def self.import_to_fedora(filename, pid)
|
41
|
+
def self.import_to_fedora(filename, pid='0')
|
39
42
|
file = File.new(filename, "r")
|
40
43
|
result = ActiveFedora::Base.connection_for_pid(pid).ingest(:file=>file.read)
|
41
44
|
raise "Failed to ingest the fixture." unless result
|
@@ -8,10 +8,11 @@ module ActiveFedora
|
|
8
8
|
# If it's a new object, set the conformsTo relationship for Fedora CMA
|
9
9
|
if new_object?
|
10
10
|
result = create
|
11
|
+
update_index if ENABLE_SOLR_UPDATES
|
11
12
|
else
|
12
13
|
result = update
|
14
|
+
update_index if @metadata_is_dirty == true && ENABLE_SOLR_UPDATES
|
13
15
|
end
|
14
|
-
update_index if @metadata_is_dirty == true && ENABLE_SOLR_UPDATES
|
15
16
|
@metadata_is_dirty = false
|
16
17
|
return result
|
17
18
|
end
|
@@ -72,8 +73,8 @@ module ActiveFedora
|
|
72
73
|
solrizer = Solrizer::Fedora::Solrizer.new
|
73
74
|
solrizer.solrize( self )
|
74
75
|
else
|
75
|
-
SolrService.
|
76
|
-
SolrService.
|
76
|
+
SolrService.add(self.to_solr)
|
77
|
+
SolrService.commit
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
@@ -85,7 +86,6 @@ module ActiveFedora
|
|
85
86
|
def create
|
86
87
|
assign_pid
|
87
88
|
assert_content_model
|
88
|
-
@metadata_is_dirty = true
|
89
89
|
persist
|
90
90
|
end
|
91
91
|
|
@@ -34,6 +34,12 @@ module ActiveFedora
|
|
34
34
|
@finished = true
|
35
35
|
@profile.freeze
|
36
36
|
@datastreams.freeze
|
37
|
+
class << self
|
38
|
+
#Once this instance is frozen create a repository method just for this one instance.
|
39
|
+
define_method :repository do
|
40
|
+
ActiveFedora::Base.connection_for_pid(self.pid)
|
41
|
+
end
|
42
|
+
end
|
37
43
|
self
|
38
44
|
end
|
39
45
|
|
@@ -41,8 +47,5 @@ module ActiveFedora
|
|
41
47
|
false
|
42
48
|
end
|
43
49
|
|
44
|
-
def repository
|
45
|
-
@finished ? ActiveFedora::Base.connection_for_pid(self.pid) : nil
|
46
|
-
end
|
47
50
|
end
|
48
51
|
end
|
@@ -81,6 +81,14 @@ module ActiveFedora
|
|
81
81
|
result['response']['docs']
|
82
82
|
end
|
83
83
|
|
84
|
+
def self.add(doc)
|
85
|
+
SolrService.instance.conn.add(doc)
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.commit
|
89
|
+
SolrService.instance.conn.commit
|
90
|
+
end
|
91
|
+
|
84
92
|
|
85
93
|
end #SolrService
|
86
94
|
class SolrNotInitialized < StandardError;end
|
@@ -11,14 +11,8 @@ namespace :repo do
|
|
11
11
|
puts "You must specify a valid pid. Example: rake repo:delete pid=demo:12"
|
12
12
|
else
|
13
13
|
pid = ENV["pid"]
|
14
|
-
|
15
|
-
|
16
|
-
rescue ActiveFedora::ObjectNotFoundError
|
17
|
-
puts "The object #{pid} has already been deleted (or was never created)."
|
18
|
-
rescue Errno::ECONNREFUSED => e
|
19
|
-
puts "Can't connect to Fedora! Are you sure jetty is running?"
|
20
|
-
end
|
21
|
-
puts "Deleted '#{pid}' from #{ActiveFedora::Base.connection_for_pid(pid).client.url}"
|
14
|
+
result = ActiveFedora::FixtureLoader.delete(pid)
|
15
|
+
puts "Deleted '#{pid}' from #{ActiveFedora::Base.connection_for_pid(pid).client.url}" if result == 1
|
22
16
|
end
|
23
17
|
end
|
24
18
|
|
@@ -34,12 +28,8 @@ namespace :repo do
|
|
34
28
|
i = start_point
|
35
29
|
while i <= stop_point do
|
36
30
|
pid = namespace + ":" + i.to_s
|
37
|
-
|
38
|
-
|
39
|
-
rescue ActiveFedora::ObjectNotFoundError
|
40
|
-
# The object has already been deleted (or was never created). Do nothing.
|
41
|
-
end
|
42
|
-
puts "Deleted '#{pid}' from #{ActiveFedora::Base.connection_for_pid(pid).client.url}"
|
31
|
+
result = ActiveFedora::FixtureLoader.delete(pid)
|
32
|
+
puts "Deleted '#{pid}' from #{ActiveFedora::Base.connection_for_pid(pid).client.url}" if result == 1
|
43
33
|
i += 1
|
44
34
|
end
|
45
35
|
end
|
@@ -51,46 +41,33 @@ namespace :repo do
|
|
51
41
|
else
|
52
42
|
pid = ENV["pid"]
|
53
43
|
puts "Exporting '#{pid}' from #{ActiveFedora::Base.connection_for_pid(pid).client.url}"
|
54
|
-
if !ENV["
|
55
|
-
|
44
|
+
if !ENV["dir"].nil?
|
45
|
+
dir = ENV["dir"]
|
56
46
|
else
|
57
|
-
|
47
|
+
dir = File.join('spec', 'fixtures')
|
58
48
|
end
|
59
|
-
filename = ActiveFedora::FixtureExporter.export_to_path(pid,
|
49
|
+
filename = ActiveFedora::FixtureExporter.export_to_path(pid, dir)
|
60
50
|
puts "The object has been saved as #{filename}"
|
61
51
|
end
|
62
52
|
end
|
63
53
|
|
64
|
-
desc "Load the object located at the provided path or identified by pid. Example: rake repo:load
|
54
|
+
desc "Load the object located at the provided path or identified by pid. Example: rake repo:load foxml=spec/fixtures/demo_12.foxml.xml"
|
65
55
|
task :load => :environment do
|
66
|
-
if !ENV["
|
67
|
-
filename = ENV["
|
56
|
+
if !ENV["foxml"].nil? and File.file?(ENV["foxml"])
|
57
|
+
filename = ENV["foxml"]
|
58
|
+
pid = ActiveFedora::FixtureLoader.import_to_fedora(filename)
|
59
|
+
ActiveFedora::FixtureLoader.index(pid)
|
68
60
|
elsif !ENV["pid"].nil?
|
69
61
|
pid = ENV["pid"]
|
70
|
-
if !ENV["
|
71
|
-
|
62
|
+
if !ENV["dir"].nil? and File.directory?(ENV["dir"])
|
63
|
+
loader = ActiveFedora::FixtureLoader.new(ENV["dir"])
|
72
64
|
else
|
73
|
-
|
65
|
+
loader = ActiveFedora::FixtureLoader.new(File.join("spec", "fixtures"))
|
74
66
|
end
|
67
|
+
loader.import_and_index(pid)
|
75
68
|
else
|
76
|
-
puts "You must specify
|
69
|
+
puts "You must specify the foxml path or provide its pid. Example: rake repo:load foxml=spec/fixtures/demo_12.foxml.xml"
|
77
70
|
end
|
78
|
-
|
79
|
-
if !filename.nil?
|
80
|
-
puts "Loading '#{filename}' in #{ActiveFedora::Base.connection_for_pid(pid).client.url}"
|
81
|
-
file = File.new(filename, "r")
|
82
|
-
result = ActiveFedora::Base.connection_for_pid(pid).ingest(:file=>file.read)
|
83
|
-
if result
|
84
|
-
puts "The object has been loaded as #{result.body}"
|
85
|
-
if pid.nil?
|
86
|
-
pid = result.body
|
87
|
-
end
|
88
|
-
ActiveFedora::Base.find(pid).update_index
|
89
|
-
else
|
90
|
-
puts "Failed to load the object."
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
71
|
end
|
95
72
|
|
96
73
|
|
@@ -45,7 +45,7 @@ require 'rspec/core/rake_task'
|
|
45
45
|
|
46
46
|
desc "Loads or refreshes the fixtures needed to run the tests"
|
47
47
|
task :load_fixtures => :environment do
|
48
|
-
|
48
|
+
# ActiveFedora.init unless Thread.current[:repo]
|
49
49
|
|
50
50
|
ENV["pid"] = "hydrangea:fixture_mods_article1"
|
51
51
|
Rake::Task["repo:refresh"].invoke
|
@@ -25,6 +25,44 @@ describe "Datastreams synched together" do
|
|
25
25
|
|
26
26
|
end
|
27
27
|
|
28
|
+
describe "has_metadata" do
|
29
|
+
before :all do
|
30
|
+
class MockAFBaseRelationship < ActiveFedora::Base
|
31
|
+
has_metadata :name=>'foo', :type=>Hydra::ModsArticleDatastream
|
32
|
+
end
|
33
|
+
end
|
34
|
+
after :all do
|
35
|
+
Object.send(:remove_const, :MockAFBaseRelationship)
|
36
|
+
end
|
37
|
+
describe "a new document" do
|
38
|
+
before do
|
39
|
+
@obj = MockAFBaseRelationship.new
|
40
|
+
@obj.foo.person = "bob"
|
41
|
+
@obj.save
|
42
|
+
end
|
43
|
+
it "should save the datastream." do
|
44
|
+
ActiveFedora::Base.find(@obj.pid).foo.person.should == ['bob']
|
45
|
+
ActiveFedora::SolrService.query("id:#{@obj.pid.gsub(":", "\\:")}", :fl=>'id person_t').first.should == {"id"=>@obj.pid, 'person_t'=>['bob']}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
describe "a changed document" do
|
51
|
+
before do
|
52
|
+
@obj = MockAFBaseRelationship.new
|
53
|
+
@obj.foo.person = "bob"
|
54
|
+
@obj.save
|
55
|
+
@obj.foo.person = "frank"
|
56
|
+
@obj.save
|
57
|
+
end
|
58
|
+
it "should save the datastream." do
|
59
|
+
ActiveFedora::Base.find(@obj.pid).foo.person.should == ['frank']
|
60
|
+
ActiveFedora::SolrService.query("id:#{@obj.pid.gsub(":", "\\:")}", :fl=>'id person_t').first.should == {"id"=>@obj.pid, 'person_t'=>['frank']}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
28
66
|
|
29
67
|
describe ActiveFedora::Base do
|
30
68
|
before :all do
|
@@ -65,6 +103,10 @@ describe ActiveFedora::Base do
|
|
65
103
|
before(:all) do
|
66
104
|
ActiveFedora::SolrService.register(ActiveFedora.solr_config[:url])
|
67
105
|
end
|
106
|
+
|
107
|
+
after :all do
|
108
|
+
Object.send(:remove_const, :MockAFBaseRelationship)
|
109
|
+
end
|
68
110
|
|
69
111
|
before(:each) do
|
70
112
|
@test_object = ActiveFedora::Base.new
|
@@ -5,12 +5,6 @@ describe ActiveFedora::NokogiriDatastream do
|
|
5
5
|
|
6
6
|
before(:all) do
|
7
7
|
class HydrangeaArticle2 < ActiveFedora::Base
|
8
|
-
|
9
|
-
#has_relationship "parts", :is_part_of, :inbound => true
|
10
|
-
|
11
|
-
# Uses the Hydra Rights Metadata Schema for tracking access permissions & copyright
|
12
|
-
# has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadata
|
13
|
-
|
14
8
|
# Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
|
15
9
|
has_metadata :name => "descMetadata", :type => Hydra::ModsArticleDatastream
|
16
10
|
|
@@ -35,9 +35,7 @@ describe ActiveFedora do
|
|
35
35
|
it "should use ENV['RAILS_ENV'] and log a warning if none of the above are set" do
|
36
36
|
ENV['environment']=nil
|
37
37
|
ENV['RAILS_ENV'] = "rails_env"
|
38
|
-
|
39
|
-
ActiveFedora.expects(:config_options).at_least_once.returns({})
|
40
|
-
ActiveFedora.environment.should eql("rails_env")
|
38
|
+
lambda {ActiveFedora.environment}.should raise_error(RuntimeError, "You're depending on RAILS_ENV for setting your environment. Please use ENV['environment'] for non-rails environment setting: 'rake foo:bar environment=test'")
|
41
39
|
ENV['environment']='test'
|
42
40
|
end
|
43
41
|
|
@@ -64,7 +64,7 @@ describe ActiveFedora::Datastream do
|
|
64
64
|
it "should set dirty? to false" do
|
65
65
|
mock_repo = mock('repository', :config=>{})
|
66
66
|
mock_repo.stubs(:add_datastream).with(:mimeType=>'text/xml', :versionable => true, :pid => @test_object.pid, :dsid => 'abcd', :controlGroup => 'M', :dsState => 'A', :content => 'hi there')
|
67
|
-
mock_repo.expects(:datastream).with(:dsid => 'abcd', :pid => @test_object.pid)
|
67
|
+
mock_repo.expects(:datastream).with(:dsid => 'abcd', :pid => @test_object.pid).returns('')
|
68
68
|
@test_object.inner_object.stubs(:repository).returns(mock_repo)
|
69
69
|
@test_datastream.dirty?.should be_true
|
70
70
|
@test_datastream.save
|
@@ -130,7 +130,7 @@ describe ActiveFedora::Datastream do
|
|
130
130
|
EOS
|
131
131
|
|
132
132
|
mock_repo = mock('repository', :config=>{})
|
133
|
-
@
|
133
|
+
@test_object.inner_object.stubs(:repository).returns(mock_repo)
|
134
134
|
mock_repo.expects(:datastream).with(:dsid => 'abcd', :pid => @test_object.pid).returns(ds_profile)
|
135
135
|
@test_datastream.size.should == 9999
|
136
136
|
end
|
@@ -21,7 +21,7 @@ describe ActiveFedora::MetadataDatastream do
|
|
21
21
|
mock_inner = mock('inner object')
|
22
22
|
@test_object = ActiveFedora::Base.new
|
23
23
|
@mock_repo = mock('repository')
|
24
|
-
@mock_repo.stubs(:datastream)
|
24
|
+
@mock_repo.stubs(:datastream).returns('')
|
25
25
|
@mock_repo.stubs(:datastream_dissemination=>'My Content', :config=>{})
|
26
26
|
mock_inner.stubs(:repository).returns(@mock_repo)
|
27
27
|
mock_inner.stubs(:pid)
|
@@ -43,7 +43,7 @@ describe ActiveFedora::MetadataDatastream do
|
|
43
43
|
it "should persist the product of .to_xml in fedora" do
|
44
44
|
@test_ds.field('coverage', :string)
|
45
45
|
@test_ds.expects(:new?).returns(true).times(3)
|
46
|
-
@mock_repo.expects(:datastream).with(:pid => nil, :dsid => 'mdDs')
|
46
|
+
@mock_repo.expects(:datastream).with(:pid => nil, :dsid => 'mdDs').returns("")
|
47
47
|
@mock_repo.expects(:add_datastream)
|
48
48
|
#@test_ds.expects(:to_xml).returns("fake xml")
|
49
49
|
@test_ds.expects(:dirty?).returns(true)
|
@@ -176,7 +176,7 @@ describe ActiveFedora::NokogiriDatastream do
|
|
176
176
|
end
|
177
177
|
it "should persist the product of .to_xml in fedora" do
|
178
178
|
@test_ds.expects(:new?).returns(true).twice
|
179
|
-
@mock_repo.expects(:datastream).with(:pid => nil, :dsid => 'descMetadata')
|
179
|
+
@mock_repo.expects(:datastream).with(:pid => nil, :dsid => 'descMetadata').returns('')
|
180
180
|
@mock_repo.expects(:add_datastream).with(:pid => nil, :dsid => 'descMetadata', :versionable => true, :content => 'fake xml', :controlGroup => 'M', :dsState => 'A', :mimeType=>'text/xml')
|
181
181
|
@test_ds.expects(:to_xml).returns("fake xml")
|
182
182
|
@test_ds.serialize!
|
@@ -25,10 +25,10 @@ describe ActiveFedora::RelsExtDatastream do
|
|
25
25
|
describe "#save" do
|
26
26
|
before do
|
27
27
|
@mock_repo.expects(:add_datastream).with(:pid => 'test:sample_pid', :dsid => 'RELS-EXT', :versionable => true, :content => 'fake xml', :controlGroup => 'M', :dsState => 'A', :mimeType=>'application/rdf+xml')
|
28
|
-
@mock_repo.expects(:datastream).with(:pid => 'test:sample_pid', :dsid => 'RELS-EXT')
|
29
|
-
@test_ds.content = 'fake xml'
|
28
|
+
@mock_repo.expects(:datastream).with(:pid => 'test:sample_pid', :dsid => 'RELS-EXT').returns("")
|
30
29
|
end
|
31
30
|
it 'should set the mime type' do
|
31
|
+
@test_ds.content = 'fake xml'
|
32
32
|
@test_ds.save
|
33
33
|
@test_ds.mimeType.should == 'application/rdf+xml'
|
34
34
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::SolrDigitalObject do
|
4
|
+
subject { ActiveFedora::SolrDigitalObject.new({}) }
|
5
|
+
describe "when not finished" do
|
6
|
+
it "should not respond_to? :repository" do
|
7
|
+
subject.should_not respond_to :repository
|
8
|
+
end
|
9
|
+
end
|
10
|
+
describe "when finished" do
|
11
|
+
before do
|
12
|
+
subject.freeze
|
13
|
+
end
|
14
|
+
it "should respond_to? :repository" do
|
15
|
+
subject.should respond_to :repository
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
end
|
@@ -75,7 +75,7 @@ describe ActiveFedora::SolrService do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
describe ".query" do
|
78
|
-
it "should call
|
78
|
+
it "should call solr" do
|
79
79
|
mock_conn = mock("Connection")
|
80
80
|
stub_result = stub("Result")
|
81
81
|
mock_conn.expects(:get).with('select', :params=>{:q=>'querytext', :qt=>'standard'}).returns(stub_result)
|
@@ -83,5 +83,23 @@ describe ActiveFedora::SolrService do
|
|
83
83
|
ActiveFedora::SolrService.query('querytext', :raw=>true).should == stub_result
|
84
84
|
end
|
85
85
|
end
|
86
|
+
describe ".add" do
|
87
|
+
it "should call solr" do
|
88
|
+
mock_conn = mock("Connection")
|
89
|
+
doc = {'id' => '1234'}
|
90
|
+
mock_conn.expects(:add).with(doc)
|
91
|
+
ActiveFedora::SolrService.stubs(:instance =>stub("instance", :conn=>mock_conn))
|
92
|
+
ActiveFedora::SolrService.add(doc)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
describe ".commit" do
|
96
|
+
it "should call solr" do
|
97
|
+
mock_conn = mock("Connection")
|
98
|
+
doc = {'id' => '1234'}
|
99
|
+
mock_conn.expects(:commit)
|
100
|
+
ActiveFedora::SolrService.stubs(:instance =>stub("instance", :conn=>mock_conn))
|
101
|
+
ActiveFedora::SolrService.commit()
|
102
|
+
end
|
103
|
+
end
|
86
104
|
|
87
105
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15424141
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 4
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 4.0.0.
|
11
|
+
- 12
|
12
|
+
version: 4.0.0.rc12
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Matt Zumwalt
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2012-03-
|
22
|
+
date: 2012-03-16 00:00:00 Z
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
25
|
prerelease: false
|
@@ -195,12 +195,12 @@ dependencies:
|
|
195
195
|
requirements:
|
196
196
|
- - ~>
|
197
197
|
- !ruby/object:Gem::Version
|
198
|
-
hash:
|
198
|
+
hash: 5
|
199
199
|
segments:
|
200
200
|
- 0
|
201
201
|
- 5
|
202
|
-
-
|
203
|
-
version: 0.5.
|
202
|
+
- 7
|
203
|
+
version: 0.5.7
|
204
204
|
version_requirements: *id012
|
205
205
|
name: rubydora
|
206
206
|
type: :runtime
|
@@ -223,12 +223,14 @@ dependencies:
|
|
223
223
|
requirement: &id014 !ruby/object:Gem::Requirement
|
224
224
|
none: false
|
225
225
|
requirements:
|
226
|
-
- - "
|
226
|
+
- - "="
|
227
227
|
- !ruby/object:Gem::Version
|
228
|
-
hash:
|
228
|
+
hash: 25
|
229
229
|
segments:
|
230
230
|
- 0
|
231
|
-
|
231
|
+
- 3
|
232
|
+
- 5
|
233
|
+
version: 0.3.5
|
232
234
|
version_requirements: *id014
|
233
235
|
name: rdf-rdfxml
|
234
236
|
type: :runtime
|
@@ -538,6 +540,7 @@ files:
|
|
538
540
|
- spec/unit/semantic_node_spec.rb
|
539
541
|
- spec/unit/service_definitions_spec.rb
|
540
542
|
- spec/unit/solr_config_options_spec.rb
|
543
|
+
- spec/unit/solr_digital_object_spec.rb
|
541
544
|
- spec/unit/solr_service_spec.rb
|
542
545
|
- spec/unit/unsaved_digital_object_spec.rb
|
543
546
|
- spec/unit/validations_spec.rb
|
@@ -697,6 +700,7 @@ test_files:
|
|
697
700
|
- spec/unit/semantic_node_spec.rb
|
698
701
|
- spec/unit/service_definitions_spec.rb
|
699
702
|
- spec/unit/solr_config_options_spec.rb
|
703
|
+
- spec/unit/solr_digital_object_spec.rb
|
700
704
|
- spec/unit/solr_service_spec.rb
|
701
705
|
- spec/unit/unsaved_digital_object_spec.rb
|
702
706
|
- spec/unit/validations_spec.rb
|