active-fedora 3.1.4 → 3.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Gemfile.lock +38 -14
- data/History.txt +8 -0
- data/Rakefile +4 -3
- data/active-fedora.gemspec +2 -3
- data/config/jetty.yml +5 -3
- data/lib/active_fedora/base.rb +14 -10
- data/lib/active_fedora/metadata_datastream_helper.rb +6 -2
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora_dev.rake +13 -32
- data/spec/integration/base_file_management_spec.rb +1 -1
- data/spec/integration/base_find_by_fields_spec.rb +1 -1
- data/spec/integration/base_loader_spec.rb +1 -1
- data/spec/integration/base_spec.rb +8 -8
- data/spec/integration/bug_spec.rb +3 -4
- data/spec/integration/datastream_spec.rb +1 -2
- data/spec/integration/full_featured_model_spec.rb +2 -1
- data/spec/integration/metadata_datastream_helper_spec.rb +1 -2
- data/spec/integration/model_spec.rb +1 -2
- data/spec/integration/mods_article_integration_spec.rb +1 -1
- data/spec/integration/nokogiri_datastream_spec.rb +1 -1
- data/spec/integration/rels_ext_datastream_spec.rb +1 -2
- data/spec/integration/semantic_node_spec.rb +1 -1
- data/spec/integration/solr_service_spec.rb +1 -1
- data/spec/rails3_test_app/spec/unit/rails_3_init.rb +1 -1
- data/spec/spec_helper.rb +3 -5
- data/spec/unit/active_fedora_spec.rb +7 -17
- data/spec/unit/base_active_model_spec.rb +1 -1
- data/spec/unit/base_cma_spec.rb +1 -1
- data/spec/unit/base_datastream_management_spec.rb +1 -1
- data/spec/unit/base_delegate_spec.rb +1 -1
- data/spec/unit/base_extra_spec.rb +1 -1
- data/spec/unit/base_file_management_spec.rb +1 -1
- data/spec/unit/base_named_datastream_spec.rb +1 -1
- data/spec/unit/base_spec.rb +47 -16
- data/spec/unit/content_model_spec.rb +1 -1
- data/spec/unit/datastream_concurrency_spec.rb +1 -2
- data/spec/unit/datastream_spec.rb +1 -2
- data/spec/unit/has_many_collection_spec.rb +4 -4
- data/spec/unit/inheritance_spec.rb +1 -1
- data/spec/unit/metadata_datastream_spec.rb +1 -1
- data/spec/unit/model_spec.rb +1 -2
- data/spec/unit/nokogiri_datastream_spec.rb +1 -1
- data/spec/unit/property_spec.rb +1 -1
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +4 -4
- data/spec/unit/rdf_xml_writer.rb +1 -1
- data/spec/unit/relationship_spec.rb +1 -1
- data/spec/unit/relationships_helper_spec.rb +1 -1
- data/spec/unit/rels_ext_datastream_spec.rb +1 -1
- data/spec/unit/rubydora_connection_spec.rb +1 -1
- data/spec/unit/semantic_node_spec.rb +1 -1
- data/spec/unit/solr_config_options_spec.rb +1 -1
- data/spec/unit/solr_service_spec.rb +1 -1
- metadata +10 -25
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active-fedora (3.1.
|
4
|
+
active-fedora (3.1.5)
|
5
5
|
activeresource (~> 3.0.0)
|
6
6
|
activesupport (~> 3.0.0)
|
7
7
|
equivalent-xml
|
@@ -21,7 +21,7 @@ PATH
|
|
21
21
|
GEM
|
22
22
|
remote: http://rubygems.org/
|
23
23
|
specs:
|
24
|
-
RedCloth (4.2.
|
24
|
+
RedCloth (4.2.9)
|
25
25
|
activemodel (3.0.11)
|
26
26
|
activesupport (= 3.0.11)
|
27
27
|
builder (~> 2.1.2)
|
@@ -33,11 +33,13 @@ GEM
|
|
33
33
|
addressable (2.2.6)
|
34
34
|
akami (1.0.0)
|
35
35
|
gyoku (>= 0.4.0)
|
36
|
+
archive-tar-minitar (0.5.2)
|
36
37
|
builder (2.1.2)
|
37
|
-
childprocess (0.2.
|
38
|
+
childprocess (0.2.3)
|
38
39
|
ffi (~> 1.0.6)
|
39
|
-
columnize (0.3.
|
40
|
+
columnize (0.3.5)
|
40
41
|
daemons (1.1.4)
|
42
|
+
diff-lcs (1.1.3)
|
41
43
|
equivalent-xml (0.2.8)
|
42
44
|
nokogiri (>= 1.4.3)
|
43
45
|
facets (2.9.2)
|
@@ -48,7 +50,7 @@ GEM
|
|
48
50
|
httpi (0.9.5)
|
49
51
|
rack
|
50
52
|
i18n (0.5.0)
|
51
|
-
jettywrapper (1.
|
53
|
+
jettywrapper (1.2.0)
|
52
54
|
activesupport (>= 3.0.0)
|
53
55
|
childprocess
|
54
56
|
i18n
|
@@ -56,8 +58,10 @@ GEM
|
|
56
58
|
mediashelf-loggable
|
57
59
|
linecache (0.46)
|
58
60
|
rbx-require-relative (> 0.0.4)
|
61
|
+
linecache19 (0.5.12)
|
62
|
+
ruby_core_source (>= 0.1.4)
|
59
63
|
logger (1.2.8)
|
60
|
-
mediashelf-loggable (0.4.
|
64
|
+
mediashelf-loggable (0.4.9)
|
61
65
|
metaclass (0.0.1)
|
62
66
|
mime-types (1.17.2)
|
63
67
|
mocha (0.10.0)
|
@@ -79,14 +83,31 @@ GEM
|
|
79
83
|
rdf (>= 0.3.4)
|
80
84
|
rest-client (1.6.7)
|
81
85
|
mime-types (>= 1.16)
|
82
|
-
rsolr (1.0.
|
86
|
+
rsolr (1.0.6)
|
83
87
|
builder (>= 2.1.2)
|
84
|
-
rspec (
|
88
|
+
rspec (2.7.0)
|
89
|
+
rspec-core (~> 2.7.0)
|
90
|
+
rspec-expectations (~> 2.7.0)
|
91
|
+
rspec-mocks (~> 2.7.0)
|
92
|
+
rspec-core (2.7.1)
|
93
|
+
rspec-expectations (2.7.0)
|
94
|
+
diff-lcs (~> 1.1.2)
|
95
|
+
rspec-mocks (2.7.0)
|
85
96
|
ruby-debug (0.10.4)
|
86
97
|
columnize (>= 0.1)
|
87
98
|
ruby-debug-base (~> 0.10.4.0)
|
88
99
|
ruby-debug-base (0.10.4)
|
89
100
|
linecache (>= 0.3)
|
101
|
+
ruby-debug-base19 (0.11.25)
|
102
|
+
columnize (>= 0.3.1)
|
103
|
+
linecache19 (>= 0.5.11)
|
104
|
+
ruby_core_source (>= 0.1.4)
|
105
|
+
ruby-debug19 (0.11.6)
|
106
|
+
columnize (>= 0.3.1)
|
107
|
+
linecache19 (>= 0.5.11)
|
108
|
+
ruby-debug-base19 (>= 0.11.19)
|
109
|
+
ruby_core_source (0.1.5)
|
110
|
+
archive-tar-minitar (>= 0.5.2)
|
90
111
|
rubydora (0.2.6)
|
91
112
|
activemodel
|
92
113
|
activesupport
|
@@ -111,17 +132,19 @@ GEM
|
|
111
132
|
om (>= 1.4.0)
|
112
133
|
stomp
|
113
134
|
xml-simple
|
114
|
-
solrizer-fedora (1.1
|
115
|
-
active-fedora (
|
135
|
+
solrizer-fedora (1.2.1)
|
136
|
+
active-fedora (~> 3.1.0)
|
137
|
+
activesupport
|
116
138
|
fastercsv
|
139
|
+
jettywrapper (>= 1.1.0)
|
117
140
|
rsolr
|
118
141
|
solr-ruby (>= 0.0.6)
|
119
142
|
solrizer (>= 1.0.0)
|
120
|
-
stomp (1.1.
|
143
|
+
stomp (1.1.10)
|
121
144
|
wasabi (2.0.0)
|
122
145
|
nokogiri (>= 1.4.0)
|
123
146
|
xml-simple (1.1.1)
|
124
|
-
yard (0.7.
|
147
|
+
yard (0.7.4)
|
125
148
|
|
126
149
|
PLATFORMS
|
127
150
|
ruby
|
@@ -129,11 +152,12 @@ PLATFORMS
|
|
129
152
|
DEPENDENCIES
|
130
153
|
RedCloth
|
131
154
|
active-fedora!
|
132
|
-
jettywrapper (>= 1.
|
155
|
+
jettywrapper (>= 1.2.0)
|
133
156
|
mocha (>= 0.9.8)
|
134
157
|
rake
|
135
158
|
rcov
|
136
|
-
rspec (
|
159
|
+
rspec (~> 2.0)
|
137
160
|
ruby-debug
|
161
|
+
ruby-debug19
|
138
162
|
solrizer-fedora (>= 1.1.3)
|
139
163
|
yard
|
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
3.1.5
|
2
|
+
HYDRA-722 updating AF::Base#label= and then saving doesn't persist the change
|
3
|
+
JettyWrapper to 1.2.0
|
4
|
+
Upgrade to rspec2
|
5
|
+
add_file_datastream should take a prefix option.
|
6
|
+
Added assert_content_model method
|
7
|
+
Updates for ruby 1.9 compatibility
|
8
|
+
|
1
9
|
3.1.4
|
2
10
|
Update rubydora to 0.2.6
|
3
11
|
Created a consistent implementation of Model.classname_from_uri
|
data/Rakefile
CHANGED
@@ -3,9 +3,6 @@ require 'rubygems'
|
|
3
3
|
require 'bundler'
|
4
4
|
require "bundler/setup"
|
5
5
|
|
6
|
-
|
7
|
-
$: << 'lib'
|
8
|
-
|
9
6
|
Bundler::GemHelper.install_tasks
|
10
7
|
|
11
8
|
# load rake tasks defined in lib/tasks
|
@@ -13,4 +10,8 @@ Dir["lib/tasks/**/*.rake"].each { |ext| load ext } if defined?(Rake)
|
|
13
10
|
|
14
11
|
CLEAN.include %w[**/.DS_Store tmp *.log *.orig *.tmp **/*~]
|
15
12
|
|
13
|
+
task :spec => ['active_fedora:rspec']
|
14
|
+
task :rcov => ['active_fedora:rcov']
|
15
|
+
|
16
|
+
|
16
17
|
task :default => [:spec]
|
data/active-fedora.gemspec
CHANGED
@@ -35,10 +35,9 @@ Gem::Specification.new do |s|
|
|
35
35
|
s.add_development_dependency("rake")
|
36
36
|
s.add_development_dependency("rcov")
|
37
37
|
s.add_development_dependency("solrizer-fedora", ">=1.1.3") # used by the fixtures rake tasks
|
38
|
-
s.add_development_dependency("jettywrapper", ">=1.
|
39
|
-
s.add_development_dependency("rspec", "
|
38
|
+
s.add_development_dependency("jettywrapper", ">=1.2.0")
|
39
|
+
s.add_development_dependency("rspec", "~> 2.0")
|
40
40
|
s.add_development_dependency("mocha", ">= 0.9.8")
|
41
|
-
s.add_development_dependency("ruby-debug")
|
42
41
|
|
43
42
|
s.files = `git ls-files`.split("\n")
|
44
43
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/config/jetty.yml
CHANGED
data/lib/active_fedora/base.rb
CHANGED
@@ -300,10 +300,10 @@ module ActiveFedora
|
|
300
300
|
# Add the given file as a datastream in the object
|
301
301
|
#
|
302
302
|
# @param [File] file the file to add
|
303
|
-
# @param [Hash] opts options: :dsid, :label, :mimeType
|
303
|
+
# @param [Hash] opts options: :dsid, :label, :mimeType, :prefix
|
304
304
|
def add_file_datastream(file, opts={})
|
305
305
|
label = opts.has_key?(:label) ? opts[:label] : ""
|
306
|
-
attrs = {:dsLabel => label, :controlGroup => 'M', :blob => file}
|
306
|
+
attrs = {:dsLabel => label, :controlGroup => 'M', :blob => file, :prefix=>opts[:prefix]}
|
307
307
|
if opts.has_key?(:mime_type)
|
308
308
|
attrs.merge!({:mimeType=>opts[:mime_type]})
|
309
309
|
elsif opts.has_key?(:mimeType)
|
@@ -655,10 +655,8 @@ module ActiveFedora
|
|
655
655
|
end
|
656
656
|
|
657
657
|
self.send(:define_method,:"#{append_method_name}") do |*args|
|
658
|
-
opts = *args
|
659
|
-
opts ||= {}
|
660
658
|
#call add_named_datastream instead of add_file_named_datastream in case not managed datastream
|
661
|
-
add_named_datastream(name
|
659
|
+
add_named_datastream(name,*args)
|
662
660
|
end
|
663
661
|
end
|
664
662
|
|
@@ -788,7 +786,7 @@ module ActiveFedora
|
|
788
786
|
end
|
789
787
|
|
790
788
|
def label=(new_label)
|
791
|
-
@inner_object.
|
789
|
+
@inner_object.label = new_label
|
792
790
|
end
|
793
791
|
|
794
792
|
#Return a hash of all available metadata fields for all
|
@@ -933,9 +931,10 @@ module ActiveFedora
|
|
933
931
|
# m.update_attributes({"fubar"=>{"-1"=>"mork", "0"=>"york", "1"=>"mangle"}}, :datastreams=>["my_ds", "my_other_ds"])
|
934
932
|
#
|
935
933
|
def update_indexed_attributes(params={}, opts={})
|
936
|
-
if opts[:datastreams]
|
934
|
+
if ds = opts[:datastreams]
|
937
935
|
ds_array = []
|
938
|
-
|
936
|
+
ds = [ds] unless ds.respond_to? :each
|
937
|
+
ds.each do |dsname|
|
939
938
|
ds_array << datastreams[dsname]
|
940
939
|
end
|
941
940
|
else
|
@@ -990,6 +989,12 @@ module ActiveFedora
|
|
990
989
|
end
|
991
990
|
end
|
992
991
|
|
992
|
+
# This can be overriden to assert a different model
|
993
|
+
# It's normally called once in the lifecycle, by #create#
|
994
|
+
def assert_content_model
|
995
|
+
add_relationship(:has_model, ActiveFedora::ContentModel.pid_from_ruby_class(self.class))
|
996
|
+
end
|
997
|
+
|
993
998
|
private
|
994
999
|
def configure_defined_datastreams
|
995
1000
|
if self.class.ds_specs
|
@@ -1032,11 +1037,10 @@ module ActiveFedora
|
|
1032
1037
|
end
|
1033
1038
|
|
1034
1039
|
|
1035
|
-
|
1036
1040
|
|
1037
1041
|
# Deals with preparing new object to be saved to Fedora, then pushes it and its datastreams into Fedora.
|
1038
1042
|
def create
|
1039
|
-
|
1043
|
+
assert_content_model
|
1040
1044
|
@metadata_is_dirty = true
|
1041
1045
|
update
|
1042
1046
|
end
|
@@ -35,7 +35,9 @@ module ActiveFedora::MetadataDatastreamHelper
|
|
35
35
|
fields.each do |field_key, field_info|
|
36
36
|
if field_info.has_key?(:values) && !field_info[:values].nil?
|
37
37
|
field_symbol = ActiveFedora::SolrService.solr_name(field_key, field_info[:type])
|
38
|
-
field_info[:values]
|
38
|
+
values = field_info[:values]
|
39
|
+
values = [values] unless values.respond_to? :each
|
40
|
+
values.each do |val|
|
39
41
|
::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_symbol, val )
|
40
42
|
end
|
41
43
|
end
|
@@ -80,7 +82,9 @@ module ActiveFedora::MetadataDatastreamHelper
|
|
80
82
|
builder = Nokogiri::XML::Builder.with(xml_insertion_point) do |xml|
|
81
83
|
fields.each_pair do |field,field_info|
|
82
84
|
element_attrs = field_info[:element_attrs].nil? ? {} : field_info[:element_attrs]
|
83
|
-
field_info[:values]
|
85
|
+
values = field_info[:values]
|
86
|
+
values = [values] unless values.respond_to? :each
|
87
|
+
values.each do |val|
|
84
88
|
builder_arg = "xml.#{field}(val, element_attrs)"
|
85
89
|
eval(builder_arg)
|
86
90
|
end
|
@@ -1,32 +1,9 @@
|
|
1
|
-
begin
|
2
|
-
require 'spec'
|
3
|
-
rescue LoadError
|
4
|
-
require 'rubygems'
|
5
|
-
require 'spec'
|
6
|
-
end
|
7
|
-
begin
|
8
|
-
require 'spec/rake/spectask'
|
9
|
-
rescue LoadError
|
10
|
-
puts <<-EOS
|
11
|
-
To use rspec for testing you must install rspec gem:
|
12
|
-
gem install rspec
|
13
|
-
EOS
|
14
|
-
exit(0)
|
15
|
-
end
|
16
|
-
|
17
1
|
APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../")
|
18
|
-
require 'jettywrapper'
|
19
2
|
|
20
|
-
|
21
|
-
|
22
|
-
desc "Run active-fedora rspec tests"
|
23
|
-
task :spec do
|
24
|
-
Rake::Task["active_fedora:rspec"].invoke
|
25
|
-
end
|
3
|
+
require 'jettywrapper'
|
26
4
|
|
27
5
|
desc "Hudson build"
|
28
6
|
task :hudson do
|
29
|
-
|
30
7
|
ENV['environment'] = "test"
|
31
8
|
Rake::Task["active_fedora:doc"].invoke
|
32
9
|
Rake::Task["active_fedora:configure_jetty"].invoke
|
@@ -40,13 +17,13 @@ task :hudson do
|
|
40
17
|
end
|
41
18
|
|
42
19
|
namespace :active_fedora do
|
43
|
-
require '
|
20
|
+
require 'active-fedora'
|
44
21
|
|
45
22
|
# Use yard to build docs
|
46
23
|
begin
|
47
24
|
require 'yard'
|
48
25
|
require 'yard/rake/yardoc_task'
|
49
|
-
project_root =
|
26
|
+
project_root = APP_ROOT
|
50
27
|
doc_destination = File.join(project_root, 'doc')
|
51
28
|
|
52
29
|
YARD::Rake::YardocTask.new(:doc) do |yt|
|
@@ -61,12 +38,16 @@ namespace :active_fedora do
|
|
61
38
|
end
|
62
39
|
end
|
63
40
|
|
41
|
+
require 'rspec/core/rake_task'
|
42
|
+
RSpec::Core::RakeTask.new(:rspec) do |spec|
|
43
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
44
|
+
spec.pattern += FileList['spec/*_spec.rb']
|
45
|
+
end
|
64
46
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
t.rcov_opts << ['--exclude', 'spec']
|
47
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
48
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
49
|
+
spec.pattern += FileList['spec/*_spec.rb']
|
50
|
+
spec.rcov = true
|
70
51
|
end
|
71
52
|
|
72
53
|
task :clean_jetty do
|
@@ -99,6 +80,6 @@ end
|
|
99
80
|
desc 'Set up ActiveFedora environment. !! Only for use while working within a working copy of active-fedora'
|
100
81
|
task :environment do
|
101
82
|
puts "Initializing ActiveFedora Rake environment. This should only be called when working within a workign copy of the active-fedora code."
|
102
|
-
require
|
83
|
+
require "#{APP_ROOT}/spec/samples/models/hydrangea_article"
|
103
84
|
require 'active_fedora/samples'
|
104
85
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
class MockAFBaseRelationship < ActiveFedora::Base
|
4
4
|
has_relationship "testing", :has_part, :type=>MockAFBaseRelationship
|
@@ -700,8 +700,8 @@ describe ActiveFedora::Base do
|
|
700
700
|
it 'should add a datastream with the given name to the object in fedora' do
|
701
701
|
@test_object2 = MockAFBaseDatastream.new
|
702
702
|
# @test_object2.new_object = true
|
703
|
-
f = File.
|
704
|
-
f2 = File.
|
703
|
+
f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
|
704
|
+
f2 = File.open(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ), 'rb')
|
705
705
|
f2.stubs(:original_filename).returns("dino.jpg")
|
706
706
|
f.stubs(:content_type).returns("image/jpeg")
|
707
707
|
@test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f, :label=>"testDS"})
|
@@ -734,7 +734,7 @@ describe ActiveFedora::Base do
|
|
734
734
|
it 'should add a file datastream with the given name to the object in fedora' do
|
735
735
|
@test_object2 = MockAFBaseDatastream.new
|
736
736
|
# @test_object2.new_object = true
|
737
|
-
f = File.
|
737
|
+
f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
|
738
738
|
f.stubs(:content_type).returns("image/jpeg")
|
739
739
|
@test_object2.add_named_file_datastream("thumbnail",f)
|
740
740
|
ds = @test_object2.thumbnail.first
|
@@ -758,10 +758,10 @@ describe ActiveFedora::Base do
|
|
758
758
|
describe '#update_named_datastream' do
|
759
759
|
it 'should update a named datastream to have a new file' do
|
760
760
|
@test_object2 = MockAFBaseDatastream.new
|
761
|
-
f = File.
|
761
|
+
f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
|
762
762
|
minivan = f.read
|
763
763
|
f.rewind
|
764
|
-
f2 = File.
|
764
|
+
f2 = File.open(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ), 'rb')
|
765
765
|
dino = f2.read
|
766
766
|
f2.rewind
|
767
767
|
f.stubs(:content_type).returns("image/jpeg")
|
@@ -802,8 +802,8 @@ describe ActiveFedora::Base do
|
|
802
802
|
it 'should return a hash of datastream name to an array of dsids' do
|
803
803
|
@test_object2 = MockAFBaseDatastream.new
|
804
804
|
# @test_object2.new_object = true
|
805
|
-
f = File.
|
806
|
-
f2 = File.
|
805
|
+
f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
|
806
|
+
f2 = File.open(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ), 'rb')
|
807
807
|
f2.stubs(:original_filename).returns("dino.jpg")
|
808
808
|
f.stubs(:content_type).returns("image/jpeg")
|
809
809
|
@test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f, :label=>"testDS"})
|
@@ -1,9 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'active_fedora'
|
4
4
|
require 'active_fedora/model'
|
5
5
|
require "rexml/document"
|
6
|
-
require 'ftools'
|
7
6
|
require 'mocha'
|
8
7
|
|
9
8
|
include ActiveFedora::Model
|
@@ -37,13 +36,13 @@ end
|
|
37
36
|
|
38
37
|
@test_object.pid.should_not be_nil
|
39
38
|
|
40
|
-
x =
|
39
|
+
x = FooHistory.find(@test_object.pid)
|
41
40
|
ds2 = x.datastreams["someData"]
|
42
41
|
ds2.fubar_values.should == ['bar']
|
43
42
|
ds2.fubar_values = ["meh"]
|
44
43
|
ds2.fubar_values.should == ["meh"]
|
45
44
|
x.save
|
46
|
-
x =
|
45
|
+
x = FooHistory.find(@test_object.pid)
|
47
46
|
x.datastreams['someData'].fubar_values.should == ["meh"]
|
48
47
|
x.save
|
49
48
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'active-fedora'
|
4
4
|
require "rexml/document"
|
5
|
-
require 'ftools'
|
6
5
|
|
7
6
|
class MockMetaHelperSolr < ActiveFedora::Base
|
8
7
|
has_metadata :name => "properties", :type => ActiveFedora::MetadataDatastream do |m|
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'active_fedora'
|
4
4
|
require "rexml/document"
|
5
|
-
require 'ftools'
|
6
5
|
|
7
6
|
class MockAFRelsSolr < ActiveFedora::Base
|
8
7
|
has_relationship "testing", :has_part, :type=>MockAFRelsSolr
|
data/spec/spec_helper.rb
CHANGED
@@ -1,25 +1,23 @@
|
|
1
1
|
ENV["environment"] ||= 'test'
|
2
2
|
require "bundler/setup"
|
3
3
|
require 'active-fedora'
|
4
|
-
require '
|
4
|
+
require 'rspec'
|
5
5
|
require 'equivalent-xml/rspec_matchers'
|
6
6
|
|
7
7
|
require 'support/mock_fedora'
|
8
8
|
|
9
9
|
|
10
10
|
logger.level = Logger::WARN if logger.respond_to? :level ###MediaShelf StubLogger doesn't have a level= method
|
11
|
-
|
12
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
13
11
|
$VERBOSE=nil
|
14
12
|
|
15
13
|
# This loads the Fedora and Solr config info from /config/fedora.yml
|
16
14
|
# You can load it from a different location by passing a file path as an argument.
|
17
15
|
ActiveFedora.init(:fedora_config_path=>File.join(File.dirname(__FILE__), "..", "config", "fedora.yml"))
|
18
16
|
|
19
|
-
|
17
|
+
RSpec.configure do |config|
|
20
18
|
config.mock_with :mocha
|
21
19
|
end
|
22
20
|
|
23
21
|
def fixture(file)
|
24
|
-
File.
|
22
|
+
File.open(File.join(File.dirname(__FILE__), 'fixtures', file), 'rb')
|
25
23
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
# For testing Module-level methods like ActiveFedora.init
|
4
4
|
|
@@ -6,7 +6,6 @@ describe ActiveFedora do
|
|
6
6
|
|
7
7
|
after :all do
|
8
8
|
unstub_rails
|
9
|
-
unstub_blacklight
|
10
9
|
# Restore to default fedora configs
|
11
10
|
fedora_config_path = File.join(File.dirname(__FILE__), "..", "..", "config", "fedora.yml")
|
12
11
|
ActiveFedora.init(:environment=>"test", :fedora_config_path=>fedora_config_path)
|
@@ -339,8 +338,7 @@ describe ActiveFedora do
|
|
339
338
|
|
340
339
|
after(:all) do
|
341
340
|
# Restore to default fedora configs
|
342
|
-
ActiveFedora.init(:fedora_config_path => File.join(File.dirname(__FILE__), "..", "..", "config", "fedora.yml"))
|
343
|
-
|
341
|
+
ActiveFedora.init(:environment => "test", :fedora_config_path => File.join(File.dirname(__FILE__), "..", "..", "config", "fedora.yml"))
|
344
342
|
end
|
345
343
|
|
346
344
|
describe "outside of rails" do
|
@@ -400,6 +398,11 @@ end
|
|
400
398
|
|
401
399
|
|
402
400
|
describe ActiveFedora do
|
401
|
+
after(:all) do
|
402
|
+
# Restore to default fedora configs
|
403
|
+
ActiveFedora.init(:environment => "test", :fedora_config_path => File.join(File.dirname(__FILE__), "..", "..", "config", "fedora.yml"))
|
404
|
+
end
|
405
|
+
|
403
406
|
# Put methods whose tests require registering Fedora & Solr here.
|
404
407
|
# to allow tests to run fast, keep these to a minimum.
|
405
408
|
describe "register_solr_and_fedora" do
|
@@ -435,19 +438,6 @@ def unstub_rails
|
|
435
438
|
Object.send(:remove_const,:Rails) if defined?(Rails)
|
436
439
|
end
|
437
440
|
|
438
|
-
def stub_blacklight(opts={})
|
439
|
-
Object.const_set("Blacklight",Class)
|
440
|
-
Blacklight.send(:undef_method,:solr_config) if Blacklight.respond_to?(:solr_config)
|
441
|
-
if opts[:solr_config]
|
442
|
-
Blacklight.send(:define_method,:solr_config) do
|
443
|
-
opts[:solr_config]
|
444
|
-
end
|
445
|
-
end
|
446
|
-
end
|
447
|
-
|
448
|
-
def unstub_blacklight
|
449
|
-
Object.send(:remove_const,:Blacklight) if defined?(Blacklight)
|
450
|
-
end
|
451
441
|
|
452
442
|
def setup_pretest_env
|
453
443
|
ENV['RAILS_ENV']='test'
|
data/spec/unit/base_cma_spec.rb
CHANGED
data/spec/unit/base_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'active_fedora'
|
4
4
|
require 'active_fedora/base'
|
@@ -169,6 +169,11 @@ describe ActiveFedora::Base do
|
|
169
169
|
stub_ingest(@this_pid)
|
170
170
|
stub_add_ds(@this_pid, ['RELS-EXT', 'externalDisseminator', 'externalUrl'])
|
171
171
|
end
|
172
|
+
|
173
|
+
after(:all) do
|
174
|
+
# clean up test class
|
175
|
+
Object.send(:remove_const, :MoreFooHistory)
|
176
|
+
end
|
172
177
|
it "should raise an error without :disseminator or :url option" do
|
173
178
|
class MoreFooHistory < ActiveFedora::Base
|
174
179
|
has_metadata :type=>ActiveFedora::NokogiriDatastream, :name=>"externalDisseminator", :control_group => "E"
|
@@ -371,6 +376,16 @@ describe ActiveFedora::Base do
|
|
371
376
|
end
|
372
377
|
end
|
373
378
|
|
379
|
+
describe '.assert_content_model' do
|
380
|
+
it "should default to the name of the class" do
|
381
|
+
stub_ingest(@this_pid)
|
382
|
+
stub_add_ds(@this_pid, ['RELS-EXT'])
|
383
|
+
@test_object.assert_content_model
|
384
|
+
@test_object.relationships(:has_model).should == ["info:fedora/afmodel:ActiveFedora_Base"]
|
385
|
+
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
374
389
|
describe '.save' do
|
375
390
|
|
376
391
|
|
@@ -384,20 +399,13 @@ describe ActiveFedora::Base do
|
|
384
399
|
@test_object.persisted?.should be true
|
385
400
|
end
|
386
401
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
end
|
395
|
-
|
396
|
-
it "should raise an exception if any of the datastreams fail to save" do
|
397
|
-
pending # Not using Fedora::Repository anymore
|
398
|
-
Fedora::Repository.instance.expects(:save).with(@test_object.inner_object).returns(true)
|
399
|
-
Fedora::Repository.instance.expects(:save).with(kind_of(ActiveFedora::RelsExtDatastream)).raises(Fedora::ServerError, mock("Server Error"))
|
400
|
-
lambda {@test_object.save}.should raise_error(Fedora::ServerError)
|
402
|
+
it "should call assert_content_model" do
|
403
|
+
stub_ingest(@this_pid)
|
404
|
+
stub_add_ds(@this_pid, ['RELS-EXT'])
|
405
|
+
@test_object.expects(:assert_content_model)
|
406
|
+
@test_object.save.should == true
|
407
|
+
|
408
|
+
|
401
409
|
end
|
402
410
|
|
403
411
|
it "should call .save on any datastreams that are dirty" do
|
@@ -492,6 +500,29 @@ describe ActiveFedora::Base do
|
|
492
500
|
end
|
493
501
|
end
|
494
502
|
|
503
|
+
describe ".add_file_datastream" do
|
504
|
+
before do
|
505
|
+
@mock_file = mock('file')
|
506
|
+
end
|
507
|
+
it "should pass prefix" do
|
508
|
+
#@test_object.expects(:create_datastream).with(ActiveFedora::Datastream, nil, attrs)
|
509
|
+
stub_add_ds(@test_object.pid, ['content1'])
|
510
|
+
@test_object.add_file_datastream(@mock_file, :prefix=>'content' )
|
511
|
+
@test_object.datastreams.keys.should include 'content1'
|
512
|
+
end
|
513
|
+
it "should pass dsid" do
|
514
|
+
#@test_object.expects(:create_datastream).with(ActiveFedora::Datastream, "MY_DSID", attrs)
|
515
|
+
stub_add_ds(@test_object.pid, ['MY_DSID'])
|
516
|
+
@test_object.add_file_datastream(@mock_file, :dsid=>'MY_DSID')
|
517
|
+
@test_object.datastreams.keys.should include 'MY_DSID'
|
518
|
+
end
|
519
|
+
it "without dsid or prefix" do
|
520
|
+
#@test_object.expects(:create_datastream).with(ActiveFedora::Datastream, nil, attrs)
|
521
|
+
stub_add_ds(@test_object.pid, ['DS1'])
|
522
|
+
@test_object.add_file_datastream(@mock_file, {} )
|
523
|
+
@test_object.datastreams.keys.should include 'DS1'
|
524
|
+
end
|
525
|
+
end
|
495
526
|
|
496
527
|
describe ".to_xml" do
|
497
528
|
it "should provide .to_xml" do
|
@@ -729,7 +760,7 @@ describe ActiveFedora::Base do
|
|
729
760
|
sinmock = mock('solr instance')
|
730
761
|
conmock = mock("solr conn")
|
731
762
|
sinmock.expects(:conn).returns(conmock)
|
732
|
-
conmock.expects(:query).with('pid: foobar', {:ding
|
763
|
+
conmock.expects(:query).with('pid: foobar', {:ding => :dang}).returns({:baz=>:bif})
|
733
764
|
ActiveFedora::SolrService.expects(:instance).returns(sinmock)
|
734
765
|
FooHistory.solr_search("pid: foobar", {:ding=>:dang}).should == {:baz=>:bif}
|
735
766
|
end
|
@@ -2,15 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Associations::HasManyAssociation do
|
4
4
|
it "should be able to replace the collection" do
|
5
|
-
@owner = stub(:new_record? => false)
|
5
|
+
@owner = stub(:new_record? => false, :to_ary => nil)
|
6
6
|
@reflection = stub(:klass => Mocha::Mock, :options=>{:property=>'predicate'})
|
7
7
|
#ac = ActiveFedora::Associations::AssociationCollection.new(@owner, @reflection)
|
8
8
|
ac = ActiveFedora::Associations::HasManyAssociation.new(@owner, @reflection)
|
9
|
-
@target = [stub(:new_record? => false, :remove_relationship=>true), stub(:new_record? => false, :remove_relationship=>true), stub(:new_record? => false, :remove_relationship=>true)]
|
9
|
+
@target = [stub(:to_ary => nil, :new_record? => false, :remove_relationship=>true), stub(:to_ary => nil, :new_record? => false, :remove_relationship=>true), stub(:to_ary => nil, :new_record? => false, :remove_relationship=>true)]
|
10
10
|
ac.target = @target
|
11
11
|
|
12
|
-
@expected1 = stub(:new_record? => false, :add_relationship=>true, :save=>true)
|
13
|
-
@expected2 = stub(:new_record? => false, :add_relationship=>true, :save=>true)
|
12
|
+
@expected1 = stub(:new_record? => false, :add_relationship=>true, :save=>true, :to_ary => nil)
|
13
|
+
@expected2 = stub(:new_record? => false, :add_relationship=>true, :save=>true, :to_ary => nil)
|
14
14
|
ac.replace([@expected1, @expected2])
|
15
15
|
ac.target.should == [@expected1, @expected2]
|
16
16
|
|
data/spec/unit/model_spec.rb
CHANGED
data/spec/unit/property_spec.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'active_fedora'
|
4
4
|
require 'xmlsimple'
|
5
5
|
require 'nokogiri'
|
6
|
+
require 'equivalent-xml'
|
6
7
|
|
7
8
|
describe ActiveFedora::QualifiedDublinCoreDatastream do
|
8
9
|
|
@@ -61,7 +62,7 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
|
|
61
62
|
end
|
62
63
|
|
63
64
|
it "should have unmodifiable constants" do
|
64
|
-
proc {ActiveFedora::QualifiedDublinCoreDatastream::DCTERMS<<:foo}.should raise_error(TypeError,
|
65
|
+
proc {ActiveFedora::QualifiedDublinCoreDatastream::DCTERMS<<:foo}.should raise_error((TypeError if RUBY_VERSION < "1.9.0") || RuntimeError, /can't modify frozen array/i)
|
65
66
|
|
66
67
|
end
|
67
68
|
|
@@ -80,8 +81,7 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
|
|
80
81
|
tmpl.expects(:content).returns('')
|
81
82
|
tmpl.field :mycomplicated, :string, :xml_node=>'alt', :element_attrs=>{:foo=>'bar'}
|
82
83
|
tmpl.mycomplicated_values='fubar'
|
83
|
-
tmpl.to_dc_xml.should
|
84
|
-
|
84
|
+
Nokogiri::XML(tmpl.to_dc_xml).should be_equivalent_to('<dc xmlns:xsi=\'http://www.w3.org/2001/XMLSchema-instance\' xmlns:dcterms=\'http://purl.org/dc/terms/\'><dcterms:alt foo=\'bar\'>fubar</dcterms:alt></dc>')
|
85
85
|
end
|
86
86
|
|
87
87
|
|
data/spec/unit/rdf_xml_writer.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 3.1.
|
9
|
+
- 5
|
10
|
+
version: 3.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Zumwalt
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-12-14 00:00:00 -06:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -327,12 +327,12 @@ dependencies:
|
|
327
327
|
requirements:
|
328
328
|
- - ">="
|
329
329
|
- !ruby/object:Gem::Version
|
330
|
-
hash:
|
330
|
+
hash: 31
|
331
331
|
segments:
|
332
332
|
- 1
|
333
|
-
-
|
333
|
+
- 2
|
334
334
|
- 0
|
335
|
-
version: 1.
|
335
|
+
version: 1.2.0
|
336
336
|
requirement: *id021
|
337
337
|
- !ruby/object:Gem::Dependency
|
338
338
|
name: rspec
|
@@ -341,14 +341,13 @@ dependencies:
|
|
341
341
|
version_requirements: &id022 !ruby/object:Gem::Requirement
|
342
342
|
none: false
|
343
343
|
requirements:
|
344
|
-
- -
|
344
|
+
- - ~>
|
345
345
|
- !ruby/object:Gem::Version
|
346
|
-
hash:
|
346
|
+
hash: 3
|
347
347
|
segments:
|
348
348
|
- 2
|
349
349
|
- 0
|
350
|
-
|
351
|
-
version: 2.0.0
|
350
|
+
version: "2.0"
|
352
351
|
requirement: *id022
|
353
352
|
- !ruby/object:Gem::Dependency
|
354
353
|
name: mocha
|
@@ -366,20 +365,6 @@ dependencies:
|
|
366
365
|
- 8
|
367
366
|
version: 0.9.8
|
368
367
|
requirement: *id023
|
369
|
-
- !ruby/object:Gem::Dependency
|
370
|
-
name: ruby-debug
|
371
|
-
type: :development
|
372
|
-
prerelease: false
|
373
|
-
version_requirements: &id024 !ruby/object:Gem::Requirement
|
374
|
-
none: false
|
375
|
-
requirements:
|
376
|
-
- - ">="
|
377
|
-
- !ruby/object:Gem::Version
|
378
|
-
hash: 3
|
379
|
-
segments:
|
380
|
-
- 0
|
381
|
-
version: "0"
|
382
|
-
requirement: *id024
|
383
368
|
description: ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.
|
384
369
|
email:
|
385
370
|
- matt.zumwalt@yourmediashelf.com
|