active-fedora 8.7.0 → 9.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +8 -15
  3. data/Gemfile +5 -5
  4. data/History.txt +0 -80
  5. data/README.md +1 -0
  6. data/Rakefile +0 -3
  7. data/active-fedora.gemspec +8 -7
  8. data/config/fedora.yml +5 -4
  9. data/config/predicate_mappings.yml +5 -5
  10. data/gemfiles/rails4.1.gemfile +10 -0
  11. data/gemfiles/rails4.2.beta.gemfile +10 -0
  12. data/lib/active_fedora.rb +151 -117
  13. data/lib/active_fedora/associations.rb +47 -15
  14. data/lib/active_fedora/associations/association.rb +29 -8
  15. data/lib/active_fedora/associations/association_scope.rb +5 -5
  16. data/lib/active_fedora/associations/belongs_to_association.rb +20 -63
  17. data/lib/active_fedora/associations/builder/association.rb +61 -25
  18. data/lib/active_fedora/associations/builder/belongs_to.rb +7 -94
  19. data/lib/active_fedora/associations/builder/collection_association.rb +11 -43
  20. data/lib/active_fedora/associations/builder/contains.rb +28 -0
  21. data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +13 -3
  22. data/lib/active_fedora/associations/builder/has_many.rb +16 -10
  23. data/lib/active_fedora/associations/builder/property.rb +14 -0
  24. data/lib/active_fedora/associations/builder/singular_association.rb +14 -18
  25. data/lib/active_fedora/associations/builder/singular_property.rb +12 -0
  26. data/lib/active_fedora/associations/collection_association.rb +57 -80
  27. data/lib/active_fedora/associations/contains_association.rb +50 -0
  28. data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +44 -24
  29. data/lib/active_fedora/associations/has_many_association.rb +46 -14
  30. data/lib/active_fedora/associations/rdf.rb +86 -0
  31. data/lib/active_fedora/associations/singular_association.rb +4 -8
  32. data/lib/active_fedora/associations/singular_rdf.rb +15 -0
  33. data/lib/active_fedora/attached_files.rb +195 -0
  34. data/lib/active_fedora/attribute_methods.rb +122 -0
  35. data/lib/active_fedora/attribute_methods/dirty.rb +16 -0
  36. data/lib/active_fedora/attribute_methods/read.rb +61 -0
  37. data/lib/active_fedora/attribute_methods/write.rb +47 -0
  38. data/lib/active_fedora/attributes.rb +93 -44
  39. data/lib/active_fedora/attributes/primary_key.rb +12 -0
  40. data/lib/active_fedora/autosave_association.rb +2 -2
  41. data/lib/active_fedora/base.rb +16 -15
  42. data/lib/active_fedora/callbacks.rb +7 -7
  43. data/lib/active_fedora/change_set.rb +34 -0
  44. data/lib/active_fedora/cleaner.rb +62 -0
  45. data/lib/active_fedora/config.rb +4 -22
  46. data/lib/active_fedora/core.rb +173 -99
  47. data/lib/active_fedora/datastream.rb +4 -117
  48. data/lib/active_fedora/datastreams.rb +2 -263
  49. data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +28 -51
  50. data/lib/active_fedora/{datastream_attribute.rb → delegated_attribute.rb} +57 -26
  51. data/lib/active_fedora/errors.rb +61 -0
  52. data/lib/active_fedora/fedora.rb +19 -0
  53. data/lib/active_fedora/fedora_attributes.rb +58 -26
  54. data/lib/active_fedora/file.rb +318 -0
  55. data/lib/active_fedora/file_configurator.rb +32 -32
  56. data/lib/active_fedora/file_path_builder.rb +24 -0
  57. data/lib/active_fedora/files_hash.rb +82 -0
  58. data/lib/active_fedora/fixity_service.rb +40 -0
  59. data/lib/active_fedora/indexing.rb +55 -82
  60. data/lib/active_fedora/indexing_service.rb +70 -0
  61. data/lib/active_fedora/ldp_resource.rb +26 -0
  62. data/lib/active_fedora/loadable_from_json.rb +112 -0
  63. data/lib/active_fedora/model.rb +5 -19
  64. data/lib/active_fedora/nested_attributes.rb +5 -6
  65. data/lib/active_fedora/nom_datastream.rb +15 -25
  66. data/lib/active_fedora/om_datastream.rb +26 -197
  67. data/lib/active_fedora/persistence.rb +95 -71
  68. data/lib/active_fedora/predicates.rb +4 -4
  69. data/lib/active_fedora/qualified_dublin_core_datastream.rb +17 -18
  70. data/lib/active_fedora/querying.rb +3 -4
  71. data/lib/active_fedora/railtie.rb +3 -6
  72. data/lib/active_fedora/rdf.rb +3 -1
  73. data/lib/active_fedora/rdf/datastream_indexing.rb +11 -0
  74. data/lib/active_fedora/rdf/fcrepo.rb +10 -324
  75. data/lib/active_fedora/rdf/indexing.rb +20 -16
  76. data/lib/active_fedora/rdf/ldp.rb +6 -0
  77. data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +1 -1
  78. data/lib/active_fedora/rdf/persistence.rb +5 -6
  79. data/lib/active_fedora/rdf/rdf_datastream.rb +44 -37
  80. data/lib/active_fedora/rdf/rdfxml_datastream.rb +13 -0
  81. data/lib/active_fedora/rdf/rels_ext.rb +26 -0
  82. data/lib/active_fedora/reflection.rb +256 -199
  83. data/lib/active_fedora/relation.rb +18 -6
  84. data/lib/active_fedora/relation/finder_methods.rb +69 -38
  85. data/lib/active_fedora/relation/query_methods.rb +7 -3
  86. data/lib/active_fedora/rspec_matchers/belong_to_associated_active_fedora_object_matcher.rb +7 -7
  87. data/lib/active_fedora/rspec_matchers/have_many_associated_active_fedora_objects_matcher.rb +8 -8
  88. data/lib/active_fedora/rspec_matchers/have_predicate_matcher.rb +9 -11
  89. data/lib/active_fedora/simple_datastream.rb +18 -13
  90. data/lib/active_fedora/solr_instance_loader.rb +18 -38
  91. data/lib/active_fedora/solr_service.rb +37 -20
  92. data/lib/active_fedora/sparql_insert.rb +45 -0
  93. data/lib/active_fedora/test_support.rb +1 -22
  94. data/lib/active_fedora/version.rb +1 -1
  95. data/lib/active_fedora/versionable.rb +90 -0
  96. data/lib/active_fedora/with_metadata.rb +37 -0
  97. data/lib/active_fedora/with_metadata/metadata_node.rb +70 -0
  98. data/lib/generators/active_fedora/config/config_generator.rb +0 -1
  99. data/lib/generators/active_fedora/config/solr/solr_generator.rb +1 -1
  100. data/lib/generators/active_fedora/model/model_generator.rb +5 -5
  101. data/lib/generators/active_fedora/model/templates/datastream_spec.rb.erb +1 -1
  102. data/lib/generators/active_fedora/model/templates/model_spec.rb.erb +2 -2
  103. data/lib/tasks/active_fedora_dev.rake +21 -27
  104. data/spec/config_helper.rb +1 -1
  105. data/spec/fixtures/mixed_rdf_descMetadata.nt +6 -6
  106. data/spec/fixtures/rails_root/config/predicate_mappings.yml +3 -19
  107. data/spec/fixtures/solr_rdf_descMetadata.nt +6 -6
  108. data/spec/integration/associations_spec.rb +133 -153
  109. data/spec/integration/attached_files_spec.rb +164 -0
  110. data/spec/integration/attributes_spec.rb +73 -12
  111. data/spec/integration/autosave_association_spec.rb +3 -3
  112. data/spec/integration/base_spec.rb +57 -351
  113. data/spec/integration/belongs_to_association_spec.rb +86 -76
  114. data/spec/integration/bug_spec.rb +3 -3
  115. data/spec/integration/collection_association_spec.rb +4 -4
  116. data/spec/integration/complex_rdf_datastream_spec.rb +54 -56
  117. data/spec/integration/delete_all_spec.rb +18 -15
  118. data/spec/integration/eradicate_spec.rb +54 -0
  119. data/spec/integration/fedora_solr_sync_spec.rb +7 -5
  120. data/spec/integration/field_to_solr_name_spec.rb +5 -5
  121. data/spec/integration/file_fixity_spec.rb +40 -0
  122. data/spec/integration/file_spec.rb +122 -0
  123. data/spec/integration/full_featured_model_spec.rb +53 -63
  124. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +141 -114
  125. data/spec/integration/has_many_associations_spec.rb +142 -64
  126. data/spec/integration/json_serialization_spec.rb +50 -8
  127. data/spec/integration/model_spec.rb +12 -29
  128. data/spec/integration/nested_attribute_spec.rb +28 -20
  129. data/spec/integration/ntriples_datastream_spec.rb +60 -57
  130. data/spec/integration/om_datastream_spec.rb +51 -140
  131. data/spec/integration/rdf_nested_attributes_spec.rb +16 -14
  132. data/spec/integration/relation_delegation_spec.rb +7 -9
  133. data/spec/integration/relation_spec.rb +9 -7
  134. data/spec/integration/scoped_query_spec.rb +26 -26
  135. data/spec/integration/solr_instance_loader_spec.rb +69 -53
  136. data/spec/integration/solr_service_spec.rb +12 -73
  137. data/spec/integration/versionable_spec.rb +477 -0
  138. data/spec/integration/with_metadata_spec.rb +52 -0
  139. data/spec/samples/hydra-mods_article_datastream.rb +10 -6
  140. data/spec/samples/models/mods_article.rb +6 -2
  141. data/spec/samples/oral_history_sample.xml +1 -1
  142. data/spec/samples/oral_history_xml.xml +1 -1
  143. data/spec/samples/special_thing.rb +3 -3
  144. data/spec/spec_helper.rb +22 -12
  145. data/spec/support/an_active_model.rb +3 -7
  146. data/spec/unit/active_fedora_spec.rb +20 -17
  147. data/spec/unit/attached_files_spec.rb +203 -0
  148. data/spec/unit/attributes_spec.rb +286 -207
  149. data/spec/unit/base_active_model_spec.rb +8 -8
  150. data/spec/unit/base_datastream_management_spec.rb +11 -24
  151. data/spec/unit/base_extra_spec.rb +17 -67
  152. data/spec/unit/base_spec.rb +163 -428
  153. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +2 -2
  154. data/spec/unit/callback_spec.rb +38 -23
  155. data/spec/unit/change_set_spec.rb +46 -0
  156. data/spec/unit/code_configurator_spec.rb +5 -5
  157. data/spec/unit/config_spec.rb +9 -14
  158. data/spec/unit/core_spec.rb +59 -8
  159. data/spec/unit/file_configurator_spec.rb +55 -53
  160. data/spec/unit/file_path_builder_spec.rb +18 -0
  161. data/spec/unit/file_spec.rb +221 -0
  162. data/spec/unit/files_hash_spec.rb +53 -0
  163. data/spec/unit/fixity_service_spec.rb +34 -0
  164. data/spec/unit/has_and_belongs_to_many_association_spec.rb +134 -0
  165. data/spec/unit/has_many_association_spec.rb +51 -0
  166. data/spec/unit/indexing_service_spec.rb +23 -0
  167. data/spec/unit/indexing_spec.rb +26 -0
  168. data/spec/unit/inheritance_spec.rb +9 -10
  169. data/spec/unit/model_spec.rb +15 -33
  170. data/spec/unit/nom_datastream_spec.rb +13 -10
  171. data/spec/unit/ntriples_datastream_spec.rb +81 -96
  172. data/spec/unit/om_datastream_spec.rb +137 -227
  173. data/spec/unit/persistence_spec.rb +28 -34
  174. data/spec/unit/predicates_spec.rb +29 -29
  175. data/spec/unit/property_spec.rb +1 -3
  176. data/spec/unit/qualified_dublin_core_datastream_spec.rb +27 -32
  177. data/spec/unit/query_spec.rb +116 -149
  178. data/spec/unit/rdf_datastream_spec.rb +25 -43
  179. data/spec/unit/rdf_resource_datastream_spec.rb +24 -123
  180. data/spec/unit/{rdfxml_rdf_datastream_spec.rb → rdfxml_datastream_spec.rb} +21 -25
  181. data/spec/unit/readonly_spec.rb +23 -0
  182. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +6 -6
  183. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +6 -6
  184. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +6 -6
  185. data/spec/unit/serializers_spec.rb +1 -1
  186. data/spec/unit/simple_datastream_spec.rb +12 -23
  187. data/spec/unit/solr_config_options_spec.rb +14 -17
  188. data/spec/unit/solr_service_spec.rb +38 -77
  189. data/spec/unit/sparql_insert_spec.rb +32 -0
  190. data/spec/unit/validations_spec.rb +8 -11
  191. metadata +96 -121
  192. data/lib/active_fedora/auditable.rb +0 -9
  193. data/lib/active_fedora/content_model.rb +0 -70
  194. data/lib/active_fedora/datastream_collections.rb +0 -302
  195. data/lib/active_fedora/datastream_hash.rb +0 -35
  196. data/lib/active_fedora/digital_object.rb +0 -55
  197. data/lib/active_fedora/fixture_exporter.rb +0 -33
  198. data/lib/active_fedora/fixture_loader.rb +0 -48
  199. data/lib/active_fedora/rdf/identifiable.rb +0 -66
  200. data/lib/active_fedora/rdf/project_hydra.rb +0 -12
  201. data/lib/active_fedora/rdf/rdfxml_rdf_datastream.rb +0 -13
  202. data/lib/active_fedora/rdf_xml_writer.rb +0 -49
  203. data/lib/active_fedora/relationship_graph.rb +0 -101
  204. data/lib/active_fedora/reload_on_save.rb +0 -16
  205. data/lib/active_fedora/rels_ext_datastream.rb +0 -100
  206. data/lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb +0 -41
  207. data/lib/active_fedora/rubydora_connection.rb +0 -35
  208. data/lib/active_fedora/semantic_node.rb +0 -164
  209. data/lib/active_fedora/service_definitions.rb +0 -88
  210. data/lib/active_fedora/sharding.rb +0 -58
  211. data/lib/active_fedora/solr_digital_object.rb +0 -68
  212. data/lib/active_fedora/unsaved_digital_object.rb +0 -58
  213. data/lib/generators/active_fedora/config/fedora/fedora_generator.rb +0 -12
  214. data/lib/generators/active_fedora/config/fedora/templates/fedora.yml +0 -38
  215. data/lib/generators/active_fedora/config/fedora/templates/fedora_conf/conf/development/fedora.fcfg +0 -953
  216. data/lib/generators/active_fedora/config/fedora/templates/fedora_conf/conf/test/fedora.fcfg +0 -953
  217. data/lib/tasks/active_fedora.rake +0 -83
  218. data/spec/fixtures/sharded_fedora.yml +0 -11
  219. data/spec/integration/auditable_spec.rb +0 -29
  220. data/spec/integration/datastream_collections_spec.rb +0 -127
  221. data/spec/integration/datastream_spec.rb +0 -90
  222. data/spec/integration/datastreams_spec.rb +0 -173
  223. data/spec/integration/load_from_solr_spec.rb +0 -66
  224. data/spec/integration/rels_ext_datastream_spec.rb +0 -82
  225. data/spec/support/mock_fedora.rb +0 -44
  226. data/spec/unit/content_model_spec.rb +0 -86
  227. data/spec/unit/datastream_collections_spec.rb +0 -420
  228. data/spec/unit/datastream_spec.rb +0 -83
  229. data/spec/unit/datastreams_spec.rb +0 -243
  230. data/spec/unit/has_and_belongs_to_many_collection_spec.rb +0 -96
  231. data/spec/unit/has_many_collection_spec.rb +0 -35
  232. data/spec/unit/rdf_vocab_spec.rb +0 -30
  233. data/spec/unit/rdf_xml_writer_spec.rb +0 -63
  234. data/spec/unit/relationship_graph_spec.rb +0 -115
  235. data/spec/unit/reload_on_save_spec.rb +0 -24
  236. data/spec/unit/rels_ext_datastream_spec.rb +0 -170
  237. data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +0 -44
  238. data/spec/unit/rubydora_connection_spec.rb +0 -12
  239. data/spec/unit/semantic_node_spec.rb +0 -112
  240. data/spec/unit/service_definitions_spec.rb +0 -63
  241. data/spec/unit/solr_digital_object_spec.rb +0 -97
  242. data/spec/unit/unsaved_digital_object_spec.rb +0 -48
@@ -4,7 +4,6 @@ module ActiveFedora
4
4
  class ConfigGenerator < Rails::Generators::Base
5
5
  def generate_configs
6
6
  generate('active_fedora:config:solr')
7
- generate('active_fedora:config:fedora')
8
7
  end
9
8
  end
10
9
  end
@@ -2,7 +2,7 @@ require 'rails/generators'
2
2
 
3
3
  module ActiveFedora
4
4
  class Config::SolrGenerator < Rails::Generators::Base
5
- source_root File.expand_path('../templates', __FILE__)
5
+ source_root ::File.expand_path('../templates', __FILE__)
6
6
 
7
7
  def generate
8
8
  # Overwrite the configuration files that Blacklight has installed
@@ -2,7 +2,7 @@ require 'rails/generators'
2
2
 
3
3
  module ActiveFedora
4
4
  class ModelGenerator < Rails::Generators::NamedBase
5
- source_root File.expand_path('../templates', __FILE__)
5
+ source_root ::File.expand_path('../templates', __FILE__)
6
6
  check_class_collision
7
7
 
8
8
  class_option :directory, :type => :string, :default => 'models', :desc => "Which directory to generate? (i.e. app/DIRECTORY)"
@@ -11,10 +11,10 @@ module ActiveFedora
11
11
  class_option :descMetadata, :type => :string, :default => nil, :desc => "Add a descMetadata metadata datastream"
12
12
 
13
13
  def install
14
- template('model.rb.erb',File.join('app', directory, "#{file_name}.rb"))
15
- template('datastream.rb.erb',File.join('app', datastream_directory, "#{file_name}_metadata.rb"))
16
- template('model_spec.rb.erb',File.join('spec', directory, "#{file_name}_spec.rb"))
17
- template('datastream_spec.rb.erb',File.join('spec', datastream_directory, "#{file_name}_metadata_spec.rb"))
14
+ template('model.rb.erb', ::File.join('app', directory, "#{file_name}.rb"))
15
+ template('datastream.rb.erb', ::File.join('app', datastream_directory, "#{file_name}_metadata.rb"))
16
+ template('model_spec.rb.erb', ::File.join('spec', directory, "#{file_name}_spec.rb"))
17
+ template('datastream_spec.rb.erb', ::File.join('spec', datastream_directory, "#{file_name}_metadata_spec.rb"))
18
18
  end
19
19
 
20
20
  protected
@@ -6,7 +6,7 @@ describe <%= class_name %>Metadata do
6
6
  it 'should have a title' do
7
7
  pending "Create a terminology for <%= class_name %>Metadata, then enable this test"
8
8
  subject.title = 'War and Peace'
9
- subject.title.should == ['War and Peace']
9
+ expect(subject.title).to eq ['War and Peace']
10
10
  end
11
11
 
12
12
  end
@@ -12,12 +12,12 @@ describe <%= class_name %> do
12
12
  before { subject.save! }
13
13
  after { subject.destroy }
14
14
  it 'should exist' do
15
- <%= class_name %>.exists?(subject.pid).should be_true
15
+ expect(<%= class_name %>.exists?(subject.id)).to be true
16
16
  end
17
17
  end
18
18
 
19
19
  it 'should have a descMetadata datastream' do
20
- subject.descMetadata.should be_kind_of <%= options['descMetadata'] ? options['descMetadata'] : "#{class_name}Metadata" %>
20
+ expect(subject.descMetadata).to be_kind_of <%= options['descMetadata'] ? options['descMetadata'] : "#{class_name}Metadata" %>
21
21
  end
22
22
 
23
23
  end
@@ -1,7 +1,7 @@
1
1
  APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../")
2
2
 
3
3
  require 'jettywrapper'
4
- JETTY_ZIP_BASENAME = '7.x-stable'
4
+ JETTY_ZIP_BASENAME = 'fedora-4/master'
5
5
  Jettywrapper.url = "https://github.com/projecthydra/hydra-jetty/archive/#{JETTY_ZIP_BASENAME}.zip"
6
6
 
7
7
  namespace :active_fedora do
@@ -13,7 +13,7 @@ namespace :active_fedora do
13
13
  doc_destination = File.join(project_root, 'doc')
14
14
 
15
15
  YARD::Rake::YardocTask.new(:doc) do |yt|
16
- yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
16
+ yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
17
17
  [ '-', File.join(project_root, 'README.md')]
18
18
  yt.options = ['--output-dir', doc_destination, '--readme', 'README.md']
19
19
  end
@@ -26,47 +26,41 @@ namespace :active_fedora do
26
26
 
27
27
  require 'rspec/core/rake_task'
28
28
  RSpec::Core::RakeTask.new(:rspec) do |spec|
29
- spec.pattern = FileList['spec/**/*_spec.rb']
30
- spec.pattern += FileList['spec/*_spec.rb']
31
29
  spec.rspec_opts = ['--backtrace'] if ENV['CI']
32
30
  end
33
31
 
34
32
  RSpec::Core::RakeTask.new(:rcov) do |spec|
35
- spec.pattern = FileList['spec/**/*_spec.rb']
36
- spec.pattern += FileList['spec/*_spec.rb']
37
33
  spec.rcov = true
38
34
  end
39
35
 
40
36
  desc "Copies the default SOLR config for the bundled Testing Server"
41
37
  task :configure_jetty do
42
- FileList['lib/generators/active_fedora/config/solr/templates/solr_conf/conf/*'].each do |f|
38
+ FileList['lib/generators/active_fedora/config/solr/templates/solr_conf/conf/*'].each do |f|
43
39
  cp("#{f}", 'jetty/solr/development-core/conf/', :verbose => true)
44
40
  cp("#{f}", 'jetty/solr/test-core/conf/', :verbose => true)
45
41
  end
46
42
  end
47
43
 
48
44
 
49
- desc "CI build"
50
- task :ci do
51
- ENV['environment'] = "test"
52
- Rake::Task["active_fedora:configure_jetty"].invoke
53
- jetty_params = Jettywrapper.load_config
54
- error = Jettywrapper.wrap(jetty_params) do
55
- Rake::Task['active_fedora:coverage'].invoke
45
+ desc "CI build"
46
+ task :ci do
47
+ ENV['environment'] = "test"
48
+ Rake::Task["active_fedora:configure_jetty"].invoke
49
+ jetty_params = Jettywrapper.load_config
50
+ error = Jettywrapper.wrap(jetty_params) do
51
+ Rake::Task['active_fedora:coverage'].invoke
52
+ end
53
+ raise "test failures: #{error}" if error
54
+ # Only create documentation if the tests have passed
55
+ Rake::Task["active_fedora:doc"].invoke
56
56
  end
57
- raise "test failures: #{error}" if error
58
- # Only create documentation if the tests have passed
59
- Rake::Task["active_fedora:doc"].invoke
60
- end
61
-
62
- desc "Execute specs with coverage"
63
- task :coverage do
64
- # Put spec opts in a file named .rspec in root
65
- ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
66
- ENV['COVERAGE'] = 'true' unless ruby_engine == 'jruby'
67
57
 
68
- # Rake::Task["active_fedora:fixtures"].invoke
69
- Rake::Task["active_fedora:rspec"].invoke
70
- end
58
+ desc "Execute specs with coverage"
59
+ task :coverage do
60
+ # Put spec opts in a file named .rspec in root
61
+ ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
62
+ ENV['COVERAGE'] = 'true' unless ruby_engine == 'jruby'
63
+ Rake::Task["active_fedora:rspec"].invoke
64
+ end
71
65
 
72
66
  end
@@ -19,7 +19,7 @@ end
19
19
  def unstub_rails
20
20
  Object.send(:remove_const,:Rails) if defined?(Rails)
21
21
  end
22
-
22
+
23
23
  def setup_pretest_env
24
24
  ENV['RAILS_ENV']='test'
25
25
  ENV['environment']='test'
@@ -1,7 +1,7 @@
1
- <info:fedora/test:1> <http://purl.org/dc/terms/created> "2010-12-31"^^<http://www.w3.org/2001/XMLSchema#date> .
2
- <info:fedora/test:1> <http://purl.org/dc/terms/title> "Title of work" .
3
- <info:fedora/test:1> <http://purl.org/dc/terms/publisher> "Penn State" .
4
- <info:fedora/test:1> <http://xmlns.com/foaf/0.1/based_near> "New York, NY, US" .
5
- <info:fedora/test:1> <http://www.w3.org/2000/01/rdf-schema#seeAlso> <http://google.com/> .
6
- <info:fedora/test:1/content> <http://purl.org/dc/terms/title> "Title of datastream" .
1
+ <http://localhost:8983/fedora/rest/test/test:1> <http://purl.org/dc/terms/created> "2010-12-31"^^<http://www.w3.org/2001/XMLSchema#date> .
2
+ <http://localhost:8983/fedora/rest/test/test:1> <http://purl.org/dc/terms/title> "Title of work" .
3
+ <http://localhost:8983/fedora/rest/test/test:1> <http://purl.org/dc/terms/publisher> "Penn State" .
4
+ <http://localhost:8983/fedora/rest/test/test:1> <http://xmlns.com/foaf/0.1/based_near> "New York, NY, US" .
5
+ <http://localhost:8983/fedora/rest/test/test:1> <http://www.w3.org/2000/01/rdf-schema#seeAlso> <http://google.com/> .
6
+ <http://localhost:8983/fedora/rest/test/test:1/content> <http://purl.org/dc/terms/title> "Title of datastream" .
7
7
 
@@ -1,23 +1,7 @@
1
- # The default namespace maps to the default namespace for generating rels_ext from solr
2
- :default_namespace: info:fedora/fedora-system:def/relations-external#
1
+ :default_namespace: http://fedora.info/definitions/v4/rels-ext#
3
2
 
4
- # namespace mappings---
5
- # you can add specific mappings for your institution by providing the following:
6
- # namespace_uri:
7
- # :relationship_symbol: relationship_identifier
8
- #
9
- # For example, if you have the following element in your rels_ext:
10
- #
11
- # <oai:itemID>oai:example.edu:changeme:500</oai:itemID>
12
- #
13
- # With the last two lines of this file uncommented, the relationships hash of your object will include:
14
- # :oai_item_id => ["info:fedora/oai:example.edu:changeme:500"]
15
- #
16
- # With the last two lines of this file commented out, the relationships hash of your object will include:
17
- # "oai_itemID" => ["info:fedora/oai:example.edu:changeme:500"]
18
- #
19
3
  :predicate_mapping:
20
- info:fedora/fedora-system:def/relations-external#:
4
+ http://fedora.info/definitions/v4/rels-ext#:
21
5
  :is_derivation_of: isDerivationOf
22
6
  :is_metadata_for: isMetadataFor
23
7
  :is_member_of_collection: isMemberOfCollection
@@ -41,7 +25,7 @@
41
25
  :has_description: hasDescription
42
26
  :has_part: hasPart
43
27
  :has_member: hasMember
44
- info:fedora/fedora-system:def/model#:
28
+ http://fedora.info/definitions/v4/model#:
45
29
  :has_model: hasModel
46
30
  # http://www.openarchives.org/OAI/2.0/:
47
31
  # :oai_item_id: itemID
@@ -1,7 +1,7 @@
1
- <info:fedora/test:1> <http://purl.org/dc/terms/created> "2009-10-10"^^<http://www.w3.org/2001/XMLSchema#date> .
2
- <info:fedora/test:1> <http://purl.org/dc/terms/title> "fake-title" .
3
- <info:fedora/test:1> <http://purl.org/dc/terms/publisher> "publisher1" .
4
- <info:fedora/test:1> <http://xmlns.com/foaf/0.1/based_near> "coverage1" .
5
- <info:fedora/test:1> <http://xmlns.com/foaf/0.1/based_near> "coverage2" .
6
- <info:fedora/test:1> <http://www.w3.org/2000/01/rdf-schema#seeAlso> <http://example.org/> .
1
+ <http://localhost:8983/fedora/rest/test/test:1> <http://purl.org/dc/terms/created> "2009-10-10"^^<http://www.w3.org/2001/XMLSchema#date> .
2
+ <http://localhost:8983/fedora/rest/test/test:1> <http://purl.org/dc/terms/title> "fake-title" .
3
+ <http://localhost:8983/fedora/rest/test/test:1> <http://purl.org/dc/terms/publisher> "publisher1" .
4
+ <http://localhost:8983/fedora/rest/test/test:1> <http://xmlns.com/foaf/0.1/based_near> "coverage1" .
5
+ <http://localhost:8983/fedora/rest/test/test:1> <http://xmlns.com/foaf/0.1/based_near> "coverage2" .
6
+ <http://localhost:8983/fedora/rest/test/test:1> <http://www.w3.org/2000/01/rdf-schema#seeAlso> <http://example.org/> .
7
7
 
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
  describe ActiveFedora::Base do
4
4
  describe "use a URI as the property" do
5
5
  before do
6
- class Book < ActiveFedora::Base
7
- belongs_to :author, :property=>RDF::DC.creator, :class_name=>'Person'
6
+ class Book < ActiveFedora::Base
7
+ belongs_to :author, predicate: ::RDF::DC.creator, class_name: 'Person'
8
8
  end
9
9
 
10
10
  class Person < ActiveFedora::Base
@@ -16,7 +16,7 @@ describe ActiveFedora::Base do
16
16
  Object.send(:remove_const, :Person)
17
17
  end
18
18
 
19
- let(:person) { Person.create}
19
+ let(:person) { Person.create }
20
20
  let(:book) { Book.new(author: person) }
21
21
 
22
22
  it "should go" do
@@ -27,14 +27,14 @@ describe ActiveFedora::Base do
27
27
 
28
28
  describe "complex example" do
29
29
  before do
30
- class Library < ActiveFedora::Base
31
- has_many :books, :property=>:has_constituent
30
+ class Library < ActiveFedora::Base
31
+ has_many :books, predicate: ActiveFedora::RDF::RelsExt.hasConstituent
32
32
  end
33
33
 
34
- class Book < ActiveFedora::Base
35
- belongs_to :library, :property=>:has_constituent
36
- belongs_to :author, :property=>:has_member, :class_name=>'Person'
37
- belongs_to :publisher, :property=>:has_member
34
+ class Book < ActiveFedora::Base
35
+ belongs_to :library, predicate: ActiveFedora::RDF::RelsExt.hasConstituent
36
+ belongs_to :author, predicate: ActiveFedora::RDF::RelsExt.hasMember, class_name: 'Person'
37
+ belongs_to :publisher, predicate: ActiveFedora::RDF::RelsExt.hasMember
38
38
  end
39
39
 
40
40
  class Person < ActiveFedora::Base
@@ -66,7 +66,7 @@ describe ActiveFedora::Base do
66
66
  expect(new_book).to be_new_record
67
67
  expect(new_book).to be_kind_of Book
68
68
  expect(new_book.library).to be_kind_of Library
69
- expect(@library.books).to eq([new_book])
69
+ expect(@library.books).to eq [new_book]
70
70
  end
71
71
 
72
72
  it "should make a new child" do
@@ -74,7 +74,7 @@ describe ActiveFedora::Base do
74
74
  expect(new_book).to be_new_record
75
75
  expect(new_book).to be_kind_of Book
76
76
  expect(new_book.library).to be_kind_of Library
77
- expect(@library.books).to eq([new_book])
77
+ expect(@library.books).to eq [new_book]
78
78
  end
79
79
 
80
80
  it "should not create children if the parent isn't saved" do
@@ -84,63 +84,63 @@ describe ActiveFedora::Base do
84
84
  it "should create children" do
85
85
  @library.save!
86
86
  new_book = @library.books.create({})
87
- expect(new_book).not_to be_new_record
87
+ expect(new_book).to_not be_new_record
88
88
  expect(new_book).to be_kind_of Book
89
- expect(new_book.library).to eq(@library)
89
+ expect(new_book.library).to eq @library
90
90
  end
91
91
 
92
92
  it "should build parent" do
93
93
  new_library = @book.build_library({})
94
94
  expect(new_library).to be_new_record
95
95
  expect(new_library).to be_kind_of Library
96
- expect(@book.library).to eq(new_library)
96
+ expect(@book.library).to eq new_library
97
97
  end
98
98
 
99
99
  it "should create parent" do
100
100
  new_library = @book.create_library({})
101
- expect(new_library).not_to be_new_record
101
+ expect(new_library).to_not be_new_record
102
102
  expect(new_library).to be_kind_of Library
103
- expect(@book.library).to eq(new_library)
103
+ expect(@book.library).to eq new_library
104
104
  end
105
105
 
106
106
  it "should let you shift onto the association" do
107
- expect(@library.new_record?).to be_truthy
108
- expect(@library.books.size).to eq(0)
109
- expect(@library.books).to eq([])
110
- expect(@library.book_ids).to eq([])
107
+ expect(@library).to be_new_record
108
+ expect(@library.books.size).to eq 0
109
+ expect(@library.books).to eq []
110
+ expect(@library.book_ids).to eq []
111
111
  @library.books << @book
112
- expect(@library.books).to eq([@book])
113
- expect(@library.book_ids).to eq([@book.pid])
112
+ expect(@library.books).to eq [@book]
113
+ expect(@library.book_ids).to eq [@book.id]
114
114
 
115
115
  end
116
116
 
117
117
  it "should let you set an array of objects" do
118
118
  @library.books = [@book, @book2]
119
- expect(@library.books).to eq([@book, @book2])
119
+ expect(@library.books).to eq [@book, @book2]
120
120
  @library.save
121
121
 
122
122
  @library.books = [@book]
123
- expect(@library.books).to eq([@book])
124
-
123
+ expect(@library.books).to eq [@book]
124
+
125
125
  end
126
126
  it "should let you set an array of object ids" do
127
- @library.book_ids = [@book.pid, @book2.pid]
128
- expect(@library.books).to eq([@book, @book2])
127
+ @library.book_ids = [@book.id, @book2.id]
128
+ expect(@library.books).to eq [@book, @book2]
129
129
  end
130
130
 
131
131
  it "setter should wipe out previously saved relations" do
132
- @library.book_ids = [@book.pid, @book2.pid]
133
- @library.book_ids = [@book2.pid]
134
- expect(@library.books).to eq([@book2])
135
-
132
+ @library.book_ids = [@book.id, @book2.id]
133
+ @library.book_ids = [@book2.id]
134
+ expect(@library.books).to eq [@book2]
135
+
136
136
  end
137
137
 
138
138
  it "saving the parent should save the relationships on the children" do
139
139
  @library.save
140
140
  @library.books = [@book, @book2]
141
141
  @library.save
142
- @library = Library.find(@library.pid)
143
- expect(@library.books).to eq([@book, @book2])
142
+ @library = Library.find(@library.id)
143
+ expect(@library.books).to eq [@book, @book2]
144
144
  end
145
145
 
146
146
 
@@ -151,22 +151,16 @@ describe ActiveFedora::Base do
151
151
  @book.save
152
152
  @book2.save
153
153
 
154
- @library = Library.find(@library.pid)
155
- expect(@library.books).to eq([@book, @book2])
156
-
157
- solr_resp = @library.books(:response_format=>:solr)
158
- expect(solr_resp.size).to eq(2)
159
- expect(solr_resp[0]['id']).to eq(@book.pid)
160
- expect(solr_resp[1]['id']).to eq(@book2.pid)
161
-
162
- end
163
-
154
+ @library = Library.find(@library.id)
155
+ expect(@library.books).to eq [@book, @book2]
164
156
 
157
+ solr_resp = @library.books(:response_format=>:solr)
158
+ expect(solr_resp.size).to eq 2
159
+ expect(solr_resp[0]['id']).to eq @book.id
160
+ expect(solr_resp[1]['id']).to eq @book2.id
165
161
 
166
- after do
167
- @book.delete
168
- @book2.delete
169
162
  end
163
+
170
164
  end
171
165
 
172
166
  describe "of belongs to" do
@@ -180,16 +174,12 @@ describe ActiveFedora::Base do
180
174
  @book.library_id = nil
181
175
  end
182
176
  it "should be settable from the book side" do
183
- @book.library_id = @library.pid
184
- expect(@book.library).to eq(@library)
185
- expect(@book.library.pid).to eq(@library.pid)
186
- @book.attributes= {:library_id => ""}
177
+ @book.library_id = @library.id
178
+ expect(@book.library).to eq @library
179
+ expect(@book.library.id).to eq @library.id
180
+ @book.attributes= {:library_id => nil }
187
181
  expect(@book.library_id).to be_nil
188
182
  end
189
- after do
190
- @library.delete
191
- @book.delete
192
- end
193
183
  end
194
184
  end
195
185
 
@@ -208,39 +198,45 @@ describe ActiveFedora::Base do
208
198
  it "should have many books once it has been saved" do
209
199
  @library.books << @book
210
200
 
211
- expect(@book.library.pid).to eq(@library.pid)
201
+ expect(@book.library.id).to eq @library.id
212
202
  @library.books.reload
213
- expect(@library.books).to eq([@book])
203
+ expect(@library.books).to eq [@book]
214
204
 
215
- @library2 = Library.find(@library.pid)
216
- expect(@library2.books).to eq([@book])
205
+ @library2 = Library.find(@library.id)
206
+ expect(@library2.books).to eq [@book]
217
207
  end
218
208
 
219
209
  it "should have a count once it has been saved" do
220
- @library.books << @book << Book.create
210
+ @book_2 = Book.create
211
+ @library.books << @book << @book_2
221
212
  @library.save
222
213
 
223
- @library2 = Library.find(@library.pid)
224
- expect(@library2.books.size).to eq(2)
214
+ @library2 = Library.find(@library.id)
215
+ expect(@library2.books.size).to eq 2
216
+ @book_2.reload
217
+ @book_2.delete
225
218
  end
226
219
 
227
220
  it "should respect the :class_name parameter" do
228
221
  @book.author = @person
229
222
  @book.save
230
- expect(Book.find(@book.id).author_id).to eq(@person.pid)
231
- expect(Book.find(@book.id).author).to be_kind_of Person
223
+ new_book = Book.find(@book.id)
224
+ expect(new_book.author_id).to eq @person.id
225
+ expect(new_book.author).to be_kind_of Person
232
226
  end
233
227
 
234
228
  it "should respect multiple associations that share the same :property and respect associated class" do
235
229
  @book.author = @person
236
230
  @book.publisher = @publisher
237
231
  @book.save
238
-
239
- expect(Book.find(@book.id).publisher_id).to eq(@publisher.pid)
240
- expect(Book.find(@book.id).publisher).to be_kind_of Publisher
241
232
 
242
- expect(Book.find(@book.id).author_id).to eq(@person.pid)
243
- expect(Book.find(@book.id).author).to be_kind_of Person
233
+ new_book = Book.find(@book.id)
234
+
235
+ expect(new_book.publisher_id).to eq @publisher.id
236
+ expect(new_book.publisher).to be_kind_of Publisher
237
+
238
+ expect(new_book.author_id).to eq @person.id
239
+ expect(new_book.author).to be_kind_of Person
244
240
  end
245
241
 
246
242
  describe "when changing the belonger" do
@@ -250,22 +246,11 @@ describe ActiveFedora::Base do
250
246
  @library2 = Library.create
251
247
  end
252
248
  it "should replace an existing instance" do
253
- expect(@book.library_id).to eq(@library.id)
249
+ expect(@book.library_id).to eq @library.id
254
250
  @book.library = @library2
255
251
  @book.save
256
- expect(Book.find(@book.id).library_id).to eq(@library2.id)
252
+ expect(Book.find(@book.id).library_id).to eq @library2.id
257
253
  end
258
- after do
259
- @library2.delete
260
- end
261
- end
262
-
263
-
264
- after do
265
- @library.delete
266
- @book.delete
267
- @person.delete
268
- @publisher.delete
269
254
  end
270
255
  end
271
256
  end
@@ -282,11 +267,11 @@ describe ActiveFedora::Base do
282
267
  end
283
268
  it "should set the association" do
284
269
  @book.library = @library
285
- expect(@book.library.pid).to eq(@library.pid)
270
+ expect(@book.library.id).to eq @library.id
286
271
  @book.save
287
272
 
288
273
 
289
- expect(Book.find(@book.pid).library.pid).to eq(@library.pid)
274
+ expect(Book.find(@book.id).library.id).to eq@library.id
290
275
 
291
276
  end
292
277
  it "should clear the association" do
@@ -294,8 +279,7 @@ describe ActiveFedora::Base do
294
279
  @book.library = nil
295
280
  @book.save
296
281
 
297
- expect(Book.find(@book.pid).library).to be_nil
298
-
282
+ expect(Book.find(@book.id).library).to be_nil
299
283
  end
300
284
 
301
285
  it "should replace the association" do
@@ -305,7 +289,7 @@ describe ActiveFedora::Base do
305
289
  @book.save
306
290
  @book.library = @library2
307
291
  @book.save
308
- expect(Book.find(@book.pid).library.pid).to eq(@library2.pid)
292
+ expect(Book.find(@book.id).library.id).to eq @library2.id
309
293
 
310
294
  end
311
295
 
@@ -315,13 +299,14 @@ describe ActiveFedora::Base do
315
299
 
316
300
  @book.publisher = @publisher
317
301
  @book.author = @author
318
- @book.save
302
+ @book.save!
319
303
 
320
304
  @book.publisher = @publisher2
321
- @book.save
305
+ @book.save!
322
306
 
323
- expect(Book.find(@book.pid).publisher.pid).to eq(@publisher2.pid)
324
- expect(Book.find(@book.pid).author.pid).to eq(@author.pid)
307
+ new_book = Book.find(@book.id)
308
+ expect(new_book.publisher.id).to eq @publisher2.id
309
+ expect(new_book.author.id).to eq @author.id
325
310
  end
326
311
 
327
312
  it "should only clear the matching class association" do
@@ -332,38 +317,30 @@ describe ActiveFedora::Base do
332
317
  @book.author = nil
333
318
  @book.save
334
319
 
335
- expect(Book.find(@book.pid).author).to be_nil
336
- expect(Book.find(@book.pid).publisher.pid).to eq(@publisher.pid)
320
+ expect(Book.find(@book.id).author).to be_nil
321
+ expect(Book.find(@book.id).publisher.id).to eq @publisher.id
337
322
  end
338
323
 
339
324
  it "should be able to be set by id" do
340
- @book.library_id = @library.pid
341
- expect(@book.library_id).to eq(@library.pid)
342
- expect(@book.library.pid).to eq(@library.pid)
325
+ @book.library_id = @library.id
326
+ expect(@book.library_id).to eq @library.id
327
+ expect(@book.library.id).to eq @library.id
343
328
  @book.save
344
- expect(Book.find(@book.pid).library_id).to eq(@library.pid)
329
+ expect(Book.find(@book.id).library_id).to eq @library.id
345
330
  end
346
331
 
347
- after do
348
- @library.delete
349
- @book.delete
350
- @author.delete
351
- @publisher.delete
352
- @library2.delete if @library2
353
- @publisher2.delete if @publisher2
354
- end
355
332
  end
356
333
  end
357
334
 
358
335
  describe "single direction habtm" do
359
336
  before :all do
360
337
  class Course < ActiveFedora::Base
361
- has_and_belongs_to_many :textbooks, :property=>:is_part_of
338
+ has_and_belongs_to_many :textbooks, predicate: ActiveFedora::RDF::RelsExt.isPartOf
362
339
  end
363
340
  class Textbook < ActiveFedora::Base
364
- has_many :courses, :property=>:is_part_of
341
+ has_many :courses, predicate: ActiveFedora::RDF::RelsExt.isPartOf
365
342
  end
366
-
343
+
367
344
  end
368
345
  after :all do
369
346
  Object.send(:remove_const, :Course)
@@ -380,17 +357,17 @@ describe ActiveFedora::Base do
380
357
  end
381
358
 
382
359
  it "should load the association stored in the parent" do
383
- @reloaded_course = Course.find(@course.pid)
384
- expect(@reloaded_course.textbooks).to eq([@t1, @t2])
360
+ @reloaded_course = Course.find(@course.id)
361
+ expect(@reloaded_course.textbooks).to eq [@t1, @t2]
385
362
  end
386
363
 
387
364
  it "should allow a parent to be deleted from the has_many association" do
388
- @reloaded_course = Course.find(@course.pid)
365
+ @reloaded_course = Course.find(@course.id)
389
366
  @t1.courses.delete(@reloaded_course)
390
367
  @reloaded_course.save
391
368
 
392
- @reloaded_course = Course.find(@course.pid)
393
- expect(@reloaded_course.textbooks).to eq([@t2])
369
+ @reloaded_course = Course.find(@course.id)
370
+ expect(@reloaded_course.textbooks).to eq [@t2]
394
371
  end
395
372
 
396
373
  it "should allow replacing the children" do
@@ -399,17 +376,17 @@ describe ActiveFedora::Base do
399
376
  @course.textbooks = [@t3, @t4]
400
377
  @course.save
401
378
 
402
- expect(@course.reload.textbooks).to eq([@t3, @t4])
379
+ expect(@course.reload.textbooks).to eq [@t3, @t4]
403
380
  end
404
381
 
405
382
  it "should allow a child to be deleted from the has_and_belongs_to_many association" do
406
- @reloaded_course = Course.find(@course.pid)
383
+ @reloaded_course = Course.find(@course.id)
407
384
  @reloaded_course.textbooks.delete(@t1)
408
385
  @reloaded_course.save
409
386
  @t1.save
410
387
 
411
- @reloaded_course = Course.find(@course.pid)
412
- expect(@reloaded_course.textbooks).to eq([@t2])
388
+ @reloaded_course = Course.find(@course.id)
389
+ expect(@reloaded_course.textbooks).to eq [@t2]
413
390
  end
414
391
  end
415
392
  end
@@ -418,24 +395,27 @@ describe ActiveFedora::Base do
418
395
  describe "for habtm" do
419
396
  before :all do
420
397
  class LibraryBook < ActiveFedora::Base
421
- has_and_belongs_to_many :pages, :property=>:is_part_of, after_remove: :after_hook, before_remove: :before_hook
398
+ has_and_belongs_to_many :pages, predicate: ActiveFedora::RDF::RelsExt.isPartOf, after_remove: :after_hook, before_remove: :before_hook
422
399
 
423
400
  def before_hook(m)
424
401
  say_hi(m)
425
- m.reload.library_books.count.should == 1
402
+ before_count(m.reload.library_books.count)
426
403
  end
427
404
 
428
405
  def after_hook(m)
429
406
  say_hi(m)
430
- m.reload.library_books.count.should == 0
407
+ after_count(m.reload.library_books.count)
408
+ end
409
+
410
+ def say_hi(var)
431
411
  end
432
412
 
433
413
 
434
414
  end
435
415
  class Page < ActiveFedora::Base
436
- has_many :library_books, :property=>:is_part_of
416
+ has_many :library_books, predicate: ActiveFedora::RDF::RelsExt.isPartOf
437
417
  end
438
-
418
+
439
419
  end
440
420
  after :all do
441
421
  Object.send(:remove_const, :LibraryBook)
@@ -451,6 +431,8 @@ describe ActiveFedora::Base do
451
431
  subject.save!
452
432
  end
453
433
  it "should save between the before and after hooks" do
434
+ expect(subject).to receive(:before_count).with(1)
435
+ expect(subject).to receive(:after_count).with(0)
454
436
  expect(subject).to receive(:say_hi).with(@p2).twice
455
437
  subject.pages.delete(@p2)
456
438
  end
@@ -459,14 +441,14 @@ describe ActiveFedora::Base do
459
441
  describe "for has_many" do
460
442
  before :all do
461
443
  class LibraryBook < ActiveFedora::Base
462
- has_many :pages, :property=>:is_part_of, after_remove: :say_hi
444
+ has_many :pages, predicate: ActiveFedora::RDF::RelsExt.isPartOf, after_remove: :say_hi
463
445
 
464
446
  end
465
447
  class Page < ActiveFedora::Base
466
- belongs_to :library_book, :property=>:is_part_of
448
+ belongs_to :library_book, predicate: ActiveFedora::RDF::RelsExt.isPartOf
467
449
  end
468
-
469
450
  end
451
+
470
452
  after :all do
471
453
  Object.send(:remove_const, :LibraryBook)
472
454
  Object.send(:remove_const, :Page)
@@ -490,7 +472,7 @@ describe ActiveFedora::Base do
490
472
  describe "when an object doesn't have a property, and the class_name is predictable" do
491
473
  before (:all) do
492
474
  class Bauble < ActiveFedora::Base
493
- belongs_to :media_object, property: :is_part_of
475
+ belongs_to :media_object, predicate: ActiveFedora::RDF::RelsExt.isPartOf
494
476
  end
495
477
  class MediaObject < ActiveFedora::Base
496
478
  has_many :baubles
@@ -502,63 +484,68 @@ describe ActiveFedora::Base do
502
484
  end
503
485
 
504
486
  it "it should find the predicate" do
505
- expect(MediaObject.new.association(:baubles).send(:find_predicate)).to eq(:is_part_of)
487
+ expect(MediaObject.new.association(:baubles).send(:find_predicate)).to eq 'http://fedora.info/definitions/v4/rels-ext#isPartOf'
506
488
  end
507
489
  end
508
490
 
509
491
  describe "when an object doesn't have a property, but has a class_name" do
510
- before (:all) do
492
+ before :all do
511
493
  class MasterFile < ActiveFedora::Base
512
- belongs_to :media_object, property: :is_part_of
494
+ belongs_to :media_object, predicate: ActiveFedora::RDF::RelsExt.isPartOf
513
495
  end
514
496
  class MediaObject < ActiveFedora::Base
515
- has_many :parts, :class_name=>'MasterFile'
497
+ has_many :parts, class_name: 'MasterFile'
516
498
  end
517
499
  end
500
+
518
501
  after :all do
519
502
  Object.send(:remove_const, :MasterFile)
520
503
  Object.send(:remove_const, :MediaObject)
521
504
  end
522
505
 
523
506
  it "it should find the predicate" do
524
- expect(MediaObject.new.association(:parts).send(:find_predicate)).to eq(:is_part_of)
507
+ expect(MediaObject.new.association(:parts).send(:find_predicate)).to eq 'http://fedora.info/definitions/v4/rels-ext#isPartOf'
525
508
  end
526
509
  end
527
510
 
528
511
  describe "an object has an explicity property" do
529
- before (:all) do
512
+ before :all do
530
513
  class Bauble < ActiveFedora::Base
531
- belongs_to :media_object, property: :is_part_of
514
+ belongs_to :media_object, predicate: ActiveFedora::RDF::RelsExt.isPartOf
532
515
  end
533
516
  class MediaObject < ActiveFedora::Base
534
- has_many :baubles, property: :has_baubles
517
+ has_many :baubles, predicate: ActiveFedora::RDF::RelsExt.hasEquivalent
535
518
  end
536
519
  end
520
+
537
521
  after :all do
538
522
  Object.send(:remove_const, :Bauble)
539
523
  Object.send(:remove_const, :MediaObject)
540
524
  end
541
525
 
542
526
  it "it should find the predicate" do
543
- expect(MediaObject.new.association(:baubles).send(:find_predicate)).to eq(:has_baubles)
527
+ expect(MediaObject.new.association(:baubles).send(:find_predicate)).to eq 'http://fedora.info/definitions/v4/rels-ext#hasEquivalent'
544
528
  end
545
529
  end
530
+
546
531
  describe "an object doesn't have a property" do
547
- before (:all) do
532
+ before :all do
548
533
  class Bauble < ActiveFedora::Base
549
- belongs_to :media_object, property: :is_part_of
534
+ belongs_to :media_object, predicate: ActiveFedora::RDF::RelsExt.isPartOf
550
535
  end
536
+
551
537
  class MediaObject < ActiveFedora::Base
552
538
  has_many :shoes
553
539
  end
554
540
  end
541
+
555
542
  after :all do
556
543
  Object.send(:remove_const, :Bauble)
557
544
  Object.send(:remove_const, :MediaObject)
558
545
  end
559
546
 
560
547
  it "it should find the predicate" do
561
- expect { MediaObject.new.shoes.send(:find_predicate) }.to raise_error RuntimeError, "No :property attribute was set or could be inferred for has_many :shoes on MediaObject"
548
+ expect { MediaObject.new.shoes.send(:find_predicate) }.to raise_error RuntimeError, "No :predicate attribute was set or could be inferred for has_many :shoes on MediaObject"
562
549
  end
563
550
  end
564
551
  end
@@ -567,19 +554,19 @@ describe ActiveFedora::Base do
567
554
  describe "for habtm" do
568
555
  before :all do
569
556
  class Novel < ActiveFedora::Base
570
- has_and_belongs_to_many :contents, property: :is_part_of, class_name: 'ActiveFedora::Base'
557
+ has_and_belongs_to_many :contents, predicate: ActiveFedora::RDF::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
571
558
  end
572
559
  class TextBook < ActiveFedora::Base
573
- has_and_belongs_to_many :contents, property: :is_part_of, class_name: 'ActiveFedora::Base'
560
+ has_and_belongs_to_many :contents, predicate: ActiveFedora::RDF::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
574
561
  end
575
562
  class Text < ActiveFedora::Base
576
- has_many :books, property: :is_part_of, class_name: 'ActiveFedora::Base'
563
+ has_many :books, predicate: ActiveFedora::RDF::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
577
564
  end
578
565
  class Image < ActiveFedora::Base
579
- has_many :books, property: :is_part_of, class_name: 'ActiveFedora::Base'
566
+ has_many :books, predicate: ActiveFedora::RDF::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
580
567
  end
581
-
582
568
  end
569
+
583
570
  after :all do
584
571
  Object.send(:remove_const, :Novel)
585
572
  Object.send(:remove_const, :TextBook)
@@ -602,19 +589,12 @@ describe ActiveFedora::Base do
602
589
  book2.save!
603
590
 
604
591
  expect(book1.reload.contents).to include(text1, image1)
605
- expect(text1.reload.books).to eq([book1])
606
- expect(image1.reload.books).to eq([book1])
592
+ expect(text1.reload.books).to eq [book1]
593
+ expect(image1.reload.books).to eq [book1]
607
594
 
608
595
  expect(book2.reload.contents).to include(text2, image2)
609
- expect(text2.reload.books).to eq([book2])
610
- expect(image2.reload.books).to eq([book2])
611
- end
612
-
613
- it "should work when added via the has_many" do
614
- text2.books << book2
615
- book2.save
616
- expect(book2.reload.contents).to eq([text2])
617
- expect(text2.reload.books).to eq([book2])
596
+ expect(text2.reload.books).to eq [book2]
597
+ expect(image2.reload.books).to eq [book2]
618
598
  end
619
599
  end
620
600
  end