active-fedora 7.0.0.rc2 → 7.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +13 -3
  3. data/CONTRIBUTORS.md +1 -0
  4. data/Gemfile +2 -3
  5. data/active-fedora.gemspec +4 -3
  6. data/gemfiles/rails3.gemfile +1 -7
  7. data/gemfiles/rails4.1.gemfile +5 -0
  8. data/gemfiles/rails4.gemfile +1 -6
  9. data/lib/active_fedora.rb +6 -6
  10. data/lib/active_fedora/associations/association_scope.rb +1 -1
  11. data/lib/active_fedora/base.rb +2 -0
  12. data/lib/active_fedora/datastream.rb +29 -2
  13. data/lib/active_fedora/datastream_collections.rb +2 -2
  14. data/lib/active_fedora/datastream_hash.rb +1 -1
  15. data/lib/active_fedora/datastreams.rb +4 -23
  16. data/lib/active_fedora/file_configurator.rb +8 -7
  17. data/lib/active_fedora/om_datastream.rb +1 -1
  18. data/lib/active_fedora/rdf.rb +9 -0
  19. data/lib/active_fedora/rdf/configurable.rb +59 -0
  20. data/lib/active_fedora/rdf/identifiable.rb +59 -0
  21. data/lib/active_fedora/rdf/indexing.rb +24 -23
  22. data/lib/active_fedora/rdf/list.rb +154 -0
  23. data/lib/active_fedora/{ntriples_rdf_datastream.rb → rdf/ntriples_rdf_datastream.rb} +0 -0
  24. data/lib/active_fedora/rdf/object_resource.rb +20 -0
  25. data/lib/active_fedora/rdf/properties.rb +108 -0
  26. data/lib/active_fedora/rdf/rdf_datastream.rb +113 -0
  27. data/lib/active_fedora/{rdfxml_rdf_datastream.rb → rdf/rdfxml_rdf_datastream.rb} +0 -0
  28. data/lib/active_fedora/rdf/repositories.rb +36 -0
  29. data/lib/active_fedora/rdf/resource.rb +324 -0
  30. data/lib/active_fedora/rdf/term.rb +188 -0
  31. data/lib/active_fedora/relation.rb +1 -0
  32. data/lib/active_fedora/relation/finder_methods.rb +16 -17
  33. data/lib/active_fedora/relation/merger.rb +1 -1
  34. data/lib/active_fedora/relation/query_methods.rb +13 -5
  35. data/lib/active_fedora/reload_on_save.rb +16 -0
  36. data/lib/active_fedora/rubydora_connection.rb +0 -1
  37. data/lib/active_fedora/sharding.rb +1 -1
  38. data/lib/active_fedora/version.rb +1 -1
  39. data/script/console +10 -11
  40. data/spec/config_helper.rb +1 -1
  41. data/spec/fixtures/solr_rdf_descMetadata.nt +1 -1
  42. data/spec/integration/auditable_spec.rb +1 -1
  43. data/spec/integration/base_spec.rb +21 -3
  44. data/spec/integration/complex_rdf_datastream_spec.rb +32 -55
  45. data/spec/integration/field_to_solr_name_spec.rb +6 -8
  46. data/spec/integration/has_many_associations_spec.rb +10 -3
  47. data/spec/integration/load_from_solr_spec.rb +15 -17
  48. data/spec/integration/ntriples_datastream_spec.rb +19 -23
  49. data/spec/integration/om_datastream_spec.rb +1 -1
  50. data/spec/integration/rdf_nested_attributes_spec.rb +51 -70
  51. data/spec/integration/relation_spec.rb +24 -11
  52. data/spec/integration/scoped_query_spec.rb +5 -1
  53. data/spec/samples/hydra-mods_article_datastream.rb +4 -0
  54. data/spec/samples/hydra-rights_metadata_datastream.rb +5 -0
  55. data/spec/samples/marpa-dc_datastream.rb +6 -1
  56. data/spec/samples/special_thing.rb +5 -5
  57. data/spec/spec_helper.rb +0 -3
  58. data/spec/support/an_active_model.rb +5 -12
  59. data/spec/unit/active_fedora_spec.rb +2 -2
  60. data/spec/unit/attributes_spec.rb +4 -8
  61. data/spec/unit/base_datastream_management_spec.rb +5 -29
  62. data/spec/unit/base_spec.rb +4 -0
  63. data/spec/unit/code_configurator_spec.rb +2 -2
  64. data/spec/unit/config_spec.rb +2 -2
  65. data/spec/unit/core_spec.rb +2 -4
  66. data/spec/unit/datastream_spec.rb +15 -0
  67. data/spec/unit/datastreams_spec.rb +1 -12
  68. data/spec/unit/file_configurator_spec.rb +1 -1
  69. data/spec/unit/ntriples_datastream_spec.rb +52 -57
  70. data/spec/unit/om_datastream_spec.rb +3 -3
  71. data/spec/unit/query_spec.rb +3 -4
  72. data/spec/unit/rdf_configurable_spec.rb +37 -0
  73. data/spec/unit/rdf_datastream_spec.rb +5 -7
  74. data/spec/unit/rdf_list_nested_attributes_spec.rb +22 -36
  75. data/spec/unit/rdf_list_spec.rb +26 -38
  76. data/spec/unit/rdf_properties_spec.rb +70 -0
  77. data/spec/unit/rdf_repositories_spec.rb +28 -0
  78. data/spec/unit/rdf_resource_datastream_spec.rb +287 -0
  79. data/spec/unit/rdf_resource_spec.rb +341 -0
  80. data/spec/unit/rdfxml_rdf_datastream_spec.rb +10 -26
  81. data/spec/unit/reload_on_save_spec.rb +24 -0
  82. data/spec/unit/solr_service_spec.rb +3 -3
  83. metadata +45 -16
  84. data/lib/active_fedora/rdf_datastream.rb +0 -113
  85. data/lib/active_fedora/rdf_list.rb +0 -162
  86. data/lib/active_fedora/rdf_node.rb +0 -332
  87. data/lib/active_fedora/rdf_node/term_proxy.rb +0 -141
  88. data/lib/active_fedora/rdf_object.rb +0 -24
  89. data/lib/active_fedora/yaml_adaptor.rb +0 -12
  90. data/spec/unit/rdf_node_spec.rb +0 -36
@@ -4,9 +4,6 @@ require "bundler/setup"
4
4
 
5
5
  begin
6
6
  require 'simplecov'
7
- require 'simplecov-rcov'
8
-
9
- SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
10
7
  SimpleCov.start
11
8
  rescue LoadError
12
9
  #It's nbd if we don't have simplecov
@@ -1,17 +1,10 @@
1
1
  shared_examples_for "An ActiveModel" do
2
- begin
3
- require 'minitest/unit'
4
- include Minitest::Assertions
5
- rescue NameError
6
- puts "Unable to load minitest, here's hoping these methods are adequate"
7
-
8
- def assert(test, *args)
9
- expect(test).to eq(true)
10
- end
2
+ def assert(test, *args)
3
+ expect(test).to eq(true)
4
+ end
11
5
 
12
- def assert_kind_of(klass, inspected_object)
13
- expect(inspected_object).to be_kind_of(klass)
14
- end
6
+ def assert_kind_of(klass, inspected_object)
7
+ expect(inspected_object).to be_kind_of(klass)
15
8
  end
16
9
  include ActiveModel::Lint::Tests
17
10
 
@@ -112,8 +112,8 @@ describe ActiveFedora do
112
112
  end
113
113
  it "should return class constants based on strings" do
114
114
  ActiveFedora.class_from_string("Om").should == Om
115
- ActiveFedora.class_from_string("ActiveFedora::RdfNode::TermProxy").should == ActiveFedora::RdfNode::TermProxy
116
- ActiveFedora.class_from_string("TermProxy", ActiveFedora::RdfNode).should == ActiveFedora::RdfNode::TermProxy
115
+ ActiveFedora.class_from_string("ActiveFedora::Rdf::ObjectResource").should == ActiveFedora::Rdf::ObjectResource
116
+ ActiveFedora.class_from_string("ObjectResource", ActiveFedora::Rdf).should == ActiveFedora::Rdf::ObjectResource
117
117
  end
118
118
 
119
119
  it "should find sibling classes" do
@@ -211,10 +211,8 @@ describe ActiveFedora::Base do
211
211
  describe "with a RDF datastream" do
212
212
  before :all do
213
213
  class BarRdfDatastream < ActiveFedora::NtriplesRDFDatastream
214
- map_predicates do |map|
215
- map.title(in: RDF::DC)
216
- map.description(in: RDF::DC, multivalue: false)
217
- end
214
+ property :title, :predicate => RDF::DC.title
215
+ property :description, :predicate => RDF::DC.description, :multivalue => false
218
216
  end
219
217
  class BarHistory4 < ActiveFedora::Base
220
218
  has_metadata 'rdfish', :type=>BarRdfDatastream
@@ -287,10 +285,8 @@ describe ActiveFedora::Base do
287
285
  describe "when a datastream is specified as a symbol" do
288
286
  before :all do
289
287
  class BarRdfDatastream < ActiveFedora::NtriplesRDFDatastream
290
- map_predicates do |map|
291
- map.title(in: RDF::DC)
292
- map.description(in: RDF::DC)
293
- end
288
+ property :title, :predicate => RDF::DC.title
289
+ property :description, :predicate => RDF::DC.description
294
290
  end
295
291
  class BarHistory4 < ActiveFedora::Base
296
292
  has_metadata 'rdfish', :type=>BarRdfDatastream
@@ -6,26 +6,6 @@ describe ActiveFedora::Base do
6
6
  @test_object = ActiveFedora::Base.new
7
7
  end
8
8
 
9
- describe '.generate_dsid' do
10
- it "should return a dsid that is not currently in use" do
11
- dsids = Hash["DS1"=>1, "DS2"=>1]
12
- @test_object.should_receive(:datastreams).and_return(dsids)
13
- generated_id = @test_object.generate_dsid
14
- generated_id.should_not be_nil
15
- generated_id.should == "DS3"
16
- end
17
- it "should accept a prefix argument, default to using DS as prefix" do
18
- @test_object.generate_dsid("FOO").should == "FOO1"
19
- end
20
-
21
- it "if delete a datastream it should still use next index for a prefix" do
22
- dsids = Hash["DS2"=>1]
23
- @test_object.should_receive(:datastreams).and_return(dsids)
24
- generated_id = @test_object.generate_dsid
25
- generated_id.should_not be_nil
26
- generated_id.should == "DS3"
27
- end
28
- end
29
9
  describe '.add_datastream' do
30
10
  it "should not call Datastream.save" do
31
11
  ds = ActiveFedora::Datastream.new(@test_object.inner_object, 'ds_to_add')
@@ -40,18 +20,14 @@ describe ActiveFedora::Base do
40
20
  end
41
21
  it "should auto-assign dsids using auto-incremented integers if dsid is nil or an empty string" do
42
22
  ds = ActiveFedora::Datastream.new(@test_object.inner_object, nil)
43
- ds.dsid.should == nil
23
+ ds.dsid.should == 'DS1'
24
+ @test_object.add_datastream(ds).should == 'DS1'
44
25
  ds_emptystringid = ActiveFedora::Datastream.new(@test_object.inner_object, '')
45
- @test_object.stub(:generate_dsid => 'foo')
46
- # ds.should_receive(:dsid=).with("foo")
47
- @test_object.add_datastream(ds).should == 'foo'
48
- @test_object.add_datastream(ds_emptystringid).should == 'foo'
26
+ @test_object.add_datastream(ds_emptystringid).should == 'DS2'
49
27
  end
50
28
  it "should accept a prefix option and apply it to automatically assigned dsids" do
51
- ds = ActiveFedora::Datastream.new(@test_object.inner_object, nil)
52
- ds.dsid.should == nil
53
- @test_object.stub(:generate_dsid => "FOO")
54
- @test_object.add_datastream(ds, :prefix => "FOO").should == 'FOO'
29
+ ds = ActiveFedora::Datastream.new(@test_object.inner_object, nil, :prefix=> "FOO")
30
+ ds.dsid.should == 'FOO1'
55
31
  end
56
32
  end
57
33
  end
@@ -21,6 +21,7 @@ describe ActiveFedora::Base do
21
21
  ActiveFedora.config.stub(:sharded?).and_return(false)
22
22
  ActiveFedora::Base.fedora_connection = {}
23
23
  ActiveFedora.config.stub(:credentials).and_return(:url=>'myfedora')
24
+ Rubydora::Fc3Service.any_instance.stub(:repository_profile)
24
25
  end
25
26
  it { should be_kind_of Rubydora::Repository}
26
27
  it "should be the standard connection" do
@@ -66,6 +67,9 @@ describe ActiveFedora::Base do
66
67
  end
67
68
  end
68
69
  describe "the repository" do
70
+ before do
71
+ Rubydora::Fc3Service.any_instance.stub(:repository_profile)
72
+ end
69
73
  describe "for test:bar" do
70
74
  subject {ActiveFedora::Base.connection_for_pid('test:bar')}
71
75
  it "should be shard1" do
@@ -38,7 +38,7 @@ describe ActiveFedora::FileConfigurator do
38
38
  end
39
39
 
40
40
  it "should initialize from code" do
41
- YAMLAdaptor.should_receive(:load).never
41
+ Psych.should_receive(:load).never
42
42
  File.should_receive(:exists?).never
43
43
  File.should_receive(:read).never
44
44
  File.should_receive(:open).never
@@ -48,4 +48,4 @@ describe ActiveFedora::FileConfigurator do
48
48
  ActiveFedora::Predicates.predicate_mappings['info:fedora/fedora-system:def/relations-external#'].length.should == 1
49
49
  end
50
50
 
51
- end
51
+ end
@@ -2,13 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::Config do
4
4
  describe "with a single fedora instance" do
5
- conf = YAMLAdaptor.load(File.read('spec/fixtures/rails_root/config/fedora.yml'))['test']
5
+ conf = Psych.load(File.read('spec/fixtures/rails_root/config/fedora.yml'))['test']
6
6
  subject { ActiveFedora::Config.new(conf) }
7
7
  its(:credentials) { should == {:url => 'http://testhost.com:8983/fedora', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'}}
8
8
  it { should_not be_sharded }
9
9
  end
10
10
  describe "with several fedora shards" do
11
- conf = YAMLAdaptor.load(File.read('spec/fixtures/sharded_fedora.yml'))['test']
11
+ conf = Psych.load(File.read('spec/fixtures/sharded_fedora.yml'))['test']
12
12
  subject { ActiveFedora::Config.new(conf) }
13
13
  its(:credentials) { should == [{:url => 'http://127.0.0.1:8983/fedora1', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'},
14
14
  {:url => 'http://127.0.0.1:8983/fedora2', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'},
@@ -3,9 +3,7 @@ require 'spec_helper'
3
3
  describe ActiveFedora::Base do
4
4
  before do
5
5
  class MyDatastream < ActiveFedora::NtriplesRDFDatastream
6
- map_predicates do |map|
7
- map.publisher(:in => RDF::DC)
8
- end
6
+ property :publisher, :predicate => RDF::DC.publisher
9
7
  end
10
8
  class Library < ActiveFedora::Base
11
9
  end
@@ -58,7 +56,7 @@ describe ActiveFedora::Base do
58
56
  it "should make the RDF properties immutable" do
59
57
  expect {
60
58
  subject.publisher = "HEY"
61
- }.to raise_error RuntimeError, "can't modify frozen MyDatastream"
59
+ }.to raise_error TypeError
62
60
  expect(subject.publisher).to eq "Random House"
63
61
  end
64
62
 
@@ -28,6 +28,21 @@ describe ActiveFedora::Datastream do
28
28
  ds2.mimeType.should == "text/bar"
29
29
  end
30
30
 
31
+ describe "#generate_dsid" do
32
+ subject {ActiveFedora::Datastream.new(@test_object.inner_object) }
33
+ let(:digital_object) { double(datastreams: {})}
34
+ it "should create an autoincrementing dsid" do
35
+ subject.send(:generate_dsid, digital_object, 'FOO').should == 'FOO1'
36
+ end
37
+
38
+ describe "when some datastreams exist" do
39
+ let(:digital_object) { double(datastreams: {'FOO56' => double})}
40
+ it "should start from the highest existing dsid" do
41
+ subject.send(:generate_dsid, digital_object, 'FOO').should == 'FOO57'
42
+ end
43
+ end
44
+ end
45
+
31
46
  describe ".size" do
32
47
  it "should lazily load the datastream size attribute from the fedora repository" do
33
48
  ds_profile = <<-EOS
@@ -149,7 +149,7 @@ describe ActiveFedora::Datastreams do
149
149
  end
150
150
 
151
151
  it "should mint a dsid" do
152
- ds = ActiveFedora::Datastream.new
152
+ ds = ActiveFedora::Datastream.new(subject.inner_object)
153
153
  subject.add_datastream(ds).should == 'DS1'
154
154
  end
155
155
  end
@@ -168,17 +168,6 @@ describe ActiveFedora::Datastreams do
168
168
  end
169
169
  end
170
170
 
171
- describe "#generate_dsid" do
172
- it "should create an autoincrementing dsid" do
173
- subject.generate_dsid('FOO').should == 'FOO1'
174
- end
175
-
176
- it "should start from the highest existin dsid" do
177
- subject.stub(:datastreams => {'FOO56' => double()})
178
- subject.generate_dsid('FOO').should == 'FOO57'
179
- end
180
- end
181
-
182
171
  describe "#relsext" do
183
172
  it "should be the RELS-EXT datastream" do
184
173
  m = double
@@ -343,7 +343,7 @@ describe ActiveFedora::FileConfigurator do
343
343
  subject.instance_variable_set :@config_loaded, nil
344
344
  end
345
345
  it "should return the default mapping if it has not been initialized" do
346
- subject.predicate_config().should == YAMLAdaptor.load(File.read(default_predicate_mapping_file))
346
+ subject.predicate_config().should == Psych.load(File.read(default_predicate_mapping_file))
347
347
  end
348
348
  end
349
349
 
@@ -2,19 +2,17 @@ require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::NtriplesRDFDatastream do
4
4
  describe "an instance with content" do
5
- before do
5
+ before do
6
6
  class MyDatastream < ActiveFedora::NtriplesRDFDatastream
7
- map_predicates do |map|
8
- map.created(:in => RDF::DC)
9
- map.title(:in => RDF::DC)
10
- map.publisher(:in => RDF::DC)
11
- map.creator(:in => RDF::DC)
12
- map.educationLevel(:in => RDF::DC)
13
- map.based_near(:in => RDF::FOAF)
14
- map.related_url(:to => "seeAlso", :in => RDF::RDFS)
15
- end
7
+ property :created, predicate: RDF::DC.created
8
+ property :title, predicate: RDF::DC.title
9
+ property :publisher, predicate: RDF::DC.publisher
10
+ property :creator, predicate: RDF::DC.creator
11
+ property :educationLevel, predicate: RDF::DC.educationLevel
12
+ property :based_near, predicate: RDF::FOAF.based_near
13
+ property :related_url, predicate: RDF::RDFS.seeAlso
16
14
  end
17
- @subject = MyDatastream.new(double('inner object', :pid=>'test:1', :new_record? =>true), 'descMetadata')
15
+ @subject = MyDatastream.new(double('inner object', pid: 'test:1', :new_record? => true), 'descMetadata')
18
16
  @subject.content = File.new('spec/fixtures/mixed_rdf_descMetadata.nt').read
19
17
  end
20
18
  after do
@@ -33,18 +31,19 @@ describe ActiveFedora::NtriplesRDFDatastream do
33
31
  @subject.dsid.should == 'descMetadata'
34
32
  end
35
33
  it "should have fields" do
36
- @subject.created.should == ["2010-12-31"]
34
+ @subject.created.should == [Date.parse('2010-12-31')]
37
35
  @subject.title.should == ["Title of work"]
38
36
  @subject.publisher.should == ["Penn State"]
39
37
  @subject.based_near.should == ["New York, NY, US"]
40
- @subject.related_url.should == ["http://google.com/"]
38
+ @subject.related_url.length.should == 1
39
+ @subject.related_url.first.rdf_subject.should == "http://google.com/"
41
40
  end
42
41
 
43
42
  it "should be able to call enumerable methods on the fields" do
44
43
  @subject.title.join(', ').should == "Title of work"
45
- @subject.title.count.should == 1
46
- @subject.title.size.should == 1
47
- @subject.title[0].should == "Title of work"
44
+ @subject.title.count.should == 1
45
+ @subject.title.size.should == 1
46
+ @subject.title[0].should == "Title of work"
48
47
  @subject.title.to_a.should == ["Title of work"]
49
48
  val = []
50
49
  @subject.title.each_with_index {|v, i| val << "#{i}. #{v}"}
@@ -88,19 +87,18 @@ describe ActiveFedora::NtriplesRDFDatastream do
88
87
  end
89
88
 
90
89
  describe "an instance with a custom subject" do
91
- before do
90
+ before do
92
91
  class MyDatastream < ActiveFedora::NtriplesRDFDatastream
93
92
  rdf_subject { |ds| "info:fedora/#{ds.pid}/content" }
94
- map_predicates do |map|
95
- map.created(:in => RDF::DC)
96
- map.title(:in => RDF::DC)
97
- map.publisher(:in => RDF::DC)
98
- map.based_near(:in => RDF::FOAF)
99
- map.related_url(:to => "seeAlso", :in => RDF::RDFS)
100
- end
93
+ property :created, predicate: RDF::DC.created
94
+ property :title, predicate: RDF::DC.title
95
+ property :publisher, predicate: RDF::DC.publisher
96
+ property :based_near, predicate: RDF::FOAF.based_near
97
+ property :related_url, predicate: RDF::RDFS.seeAlso
101
98
  end
99
+ @inner_object = double('inner object', pid: 'test:1', :new_record? => true)
102
100
  @subject = MyDatastream.new(@inner_object, 'mixed_rdf')
103
- @subject.stub(:pid => 'test:1')
101
+ @subject.stub(pid: 'test:1')
104
102
  @subject.stub(:new_record? => false)
105
103
  @subject.content = File.new('spec/fixtures/mixed_rdf_descMetadata.nt').read
106
104
  end
@@ -121,12 +119,10 @@ describe ActiveFedora::NtriplesRDFDatastream do
121
119
  describe "a new instance" do
122
120
  before(:each) do
123
121
  class MyDatastream < ActiveFedora::NtriplesRDFDatastream
124
- map_predicates do |map|
125
- map.publisher(:in => RDF::DC)
126
- end
122
+ property :publisher, predicate: RDF::DC.publisher
127
123
  end
128
124
  @subject = MyDatastream.new(@inner_object, 'mixed_rdf')
129
- @subject.stub(:pid => 'test:1', :repository => ActiveFedora::Base.connection_for_pid(0))
125
+ @subject.stub(pid: 'test:1', repository: ActiveFedora::Base.connection_for_pid(0))
130
126
  end
131
127
  after(:each) do
132
128
  Object.send(:remove_const, :MyDatastream)
@@ -143,27 +139,25 @@ describe ActiveFedora::NtriplesRDFDatastream do
143
139
  describe "solr integration" do
144
140
  before(:all) do
145
141
  class MyDatastream < ActiveFedora::NtriplesRDFDatastream
146
- map_predicates do |map|
147
- map.created(:in => RDF::DC) do |index|
148
- index.as :sortable, :displayable
149
- index.type :date
150
- end
151
- map.title(:in => RDF::DC) do |index|
152
- index.as :stored_searchable, :sortable
153
- index.type :text
154
- end
155
- map.publisher(:in => RDF::DC) do |index|
156
- index.as :facetable, :sortable, :stored_searchable
157
- end
158
- map.based_near(:in => RDF::FOAF) do |index|
159
- index.as :facetable, :stored_searchable
160
- index.type :text
161
- end
162
- map.related_url(:to => "seeAlso", :in => RDF::RDFS) do |index|
163
- index.as :stored_searchable
164
- end
165
- map.rights(:in => RDF::DC)
142
+ property :created, predicate: RDF::DC.created do |index|
143
+ index.as :sortable, :displayable
144
+ index.type :date
166
145
  end
146
+ property :title, predicate: RDF::DC.title do |index|
147
+ index.as :stored_searchable, :sortable
148
+ index.type :text
149
+ end
150
+ property :publisher, predicate: RDF::DC.publisher do |index|
151
+ index.as :facetable, :sortable, :stored_searchable
152
+ end
153
+ property :based_near, predicate: RDF::FOAF.based_near do |index|
154
+ index.as :facetable, :stored_searchable
155
+ index.type :text
156
+ end
157
+ property :related_url, predicate: RDF::RDFS.seeAlso do |index|
158
+ index.as :stored_searchable
159
+ end
160
+ property :rights, predicate: RDF::DC.rights
167
161
  end
168
162
  @subject = MyDatastream.new(@inner_object, 'solr_rdf')
169
163
  @subject.content = File.new('spec/fixtures/solr_rdf_descMetadata.nt').read
@@ -171,8 +165,9 @@ describe ActiveFedora::NtriplesRDFDatastream do
171
165
  after(:all) do
172
166
  Object.send(:remove_const, :MyDatastream)
173
167
  end
174
- before(:each) do
175
- @subject.stub(:pid => 'test:1')
168
+ before(:each) do
169
+ @subject.stub(pid: 'test:1')
170
+ @subject.serialize
176
171
  end
177
172
  it "should provide .to_solr and return a SolrDocument" do
178
173
  @subject.should respond_to(:to_solr)
@@ -180,7 +175,7 @@ describe ActiveFedora::NtriplesRDFDatastream do
180
175
  end
181
176
 
182
177
  it "should have a solr_name method" do
183
- expect(MyDatastream.new(nil, 'descMetadata').primary_solr_name(:based_near)).to eq 'desc_metadata__based_near_sim'
178
+ expect(MyDatastream.new(nil, 'descMetadata').primary_solr_name(:based_near)).to eq 'desc_metadata__based_near_tesim'
184
179
  expect(MyDatastream.new(nil, 'props').primary_solr_name(:title)).to eq 'props__title_tesim'
185
180
  end
186
181
 
@@ -205,15 +200,15 @@ describe ActiveFedora::NtriplesRDFDatastream do
205
200
  describe "with an actual object" do
206
201
  before(:each) do
207
202
  class Foo < ActiveFedora::Base
208
- has_metadata :name => "descMetadata", :type => MyDatastream
203
+ has_metadata "descMetadata", type: MyDatastream
209
204
  has_attributes :created, :title, :publisher, :based_near, :related_url, :rights, datastream: :descMetadata, multiple: true
210
205
  end
211
206
  @obj = MyDatastream.new(@inner_object, 'solr_rdf')
212
207
  repository = double()
213
- @obj.stub(:repository => repository, :pid => 'test:1')
208
+ @obj.stub(repository: repository, pid: 'test:1')
214
209
  repository.stub(:modify_datastream)
215
210
  repository.stub(:add_datastream)
216
- @obj.created = "2012-03-04"
211
+ @obj.created = Date.parse("2012-03-04")
217
212
  @obj.title = "Of Mice and Men, The Sequel"
218
213
  @obj.publisher = "Bob's Blogtastic Publishing"
219
214
  @obj.based_near = ["Tacoma, WA", "Renton, WA"]
@@ -245,9 +240,9 @@ describe ActiveFedora::NtriplesRDFDatastream do
245
240
  @obj.to_solr.keys.should include(ActiveFedora::SolrService.solr_name("solr_rdf__related_url", type: :string),
246
241
  ActiveFedora::SolrService.solr_name("solr_rdf__publisher", type: :string),
247
242
  ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :sortable),
248
- ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :facetable),
243
+ ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :facetable),
249
244
  ActiveFedora::SolrService.solr_name("solr_rdf__created", :sortable, type: :date),
250
- ActiveFedora::SolrService.solr_name("solr_rdf__created", :displayable),
245
+ ActiveFedora::SolrService.solr_name("solr_rdf__created", :displayable),
251
246
  ActiveFedora::SolrService.solr_name("solr_rdf__title", type: :string),
252
247
  ActiveFedora::SolrService.solr_name("solr_rdf__title", :sortable),
253
248
  ActiveFedora::SolrService.solr_name("solr_rdf__based_near", type: :string),
@@ -47,7 +47,7 @@ describe ActiveFedora::OmDatastream do
47
47
  it 'should load xml from blob if provided' do
48
48
  test_ds1 = ActiveFedora::OmDatastream.new(nil, 'ds1')
49
49
  test_ds1.content="<xml><foo/></xml>"
50
- test_ds1.ng_xml.to_xml.should == "<?xml version=\"1.0\"?>\n<xml>\n <foo/>\n</xml>\n"
50
+ test_ds1.ng_xml.to_xml.should be_equivalent_to("<?xml version=\"1.0\"?>\n<xml>\n <foo/>\n</xml>\n")
51
51
  end
52
52
  it "should initialize from #xml_template if no xml is provided" do
53
53
  ActiveFedora::OmDatastream.should_receive(:xml_template).and_return("<fake template/>")
@@ -65,7 +65,7 @@ describe ActiveFedora::OmDatastream do
65
65
 
66
66
  describe '#xml_template' do
67
67
  it "should return an empty xml document" do
68
- ActiveFedora::OmDatastream.xml_template.to_xml.should == "<?xml version=\"1.0\"?>\n<xml/>\n"
68
+ ActiveFedora::OmDatastream.xml_template.to_xml.should be_equivalent_to("<?xml version=\"1.0\"?>\n<xml/>\n")
69
69
  end
70
70
  end
71
71
 
@@ -292,7 +292,7 @@ describe ActiveFedora::OmDatastream do
292
292
 
293
293
  describe '.get_values_from_solr' do
294
294
  before(:each) do
295
- @mods_ds = ActiveFedora::OmDatastream.new
295
+ @mods_ds = ActiveFedora::OmDatastream.new(nil, 'test_ds')
296
296
  @mods_ds.content=fixture(File.join("mods_articles","mods_article1.xml")).read
297
297
  end
298
298