active-fedora 6.2.0 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mailmap +9 -0
- data/CONTRIBUTORS.md +25 -0
- data/History.txt +52 -0
- data/active-fedora.gemspec +1 -1
- data/config/jetty.yml +1 -1
- data/gemfiles/gemfile.rails4 +1 -1
- data/lib/active_fedora/associations.rb +16 -1
- data/lib/active_fedora/associations/association_collection.rb +20 -2
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +7 -0
- data/lib/active_fedora/base.rb +32 -8
- data/lib/active_fedora/datastream.rb +7 -0
- data/lib/active_fedora/datastreams.rb +1 -0
- data/lib/active_fedora/nested_attributes.rb +34 -9
- data/lib/active_fedora/reflection.rb +7 -25
- data/lib/active_fedora/solr_digital_object.rb +4 -0
- data/lib/active_fedora/solr_service.rb +12 -9
- data/lib/active_fedora/unsaved_digital_object.rb +3 -0
- data/lib/active_fedora/validations.rb +7 -0
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora_dev.rake +2 -11
- data/spec/fixtures/mods_articles/{hydrangea_article1.xml → mods_article1.xml} +0 -0
- data/spec/fixtures/{hydrangea_fixture_mods_article1.foxml.xml → test_fixture_mods_article1.foxml.xml} +5 -5
- data/spec/fixtures/{hydrangea_fixture_mods_article2.foxml.xml → test_fixture_mods_article2.foxml.xml} +5 -5
- data/spec/integration/associations_spec.rb +116 -33
- data/spec/integration/base_spec.rb +13 -35
- data/spec/integration/datastream_collections_spec.rb +6 -5
- data/spec/integration/datastream_spec.rb +21 -18
- data/spec/integration/datastreams_spec.rb +1 -3
- data/spec/integration/model_spec.rb +6 -6
- data/spec/integration/mods_article_integration_spec.rb +2 -2
- data/spec/integration/nested_attribute_spec.rb +88 -10
- data/spec/integration/ntriples_datastream_spec.rb +1 -1
- data/spec/integration/om_datastream_spec.rb +22 -22
- data/spec/integration/solr_instance_loader_spec.rb +4 -4
- data/spec/integration/solr_service_spec.rb +1 -1
- data/spec/samples/models/{hydrangea_article.rb → mods_article.rb} +2 -2
- data/spec/samples/samples.rb +1 -1
- data/spec/unit/base_spec.rb +12 -12
- data/spec/unit/datastreams_spec.rb +0 -10
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +0 -27
- data/spec/unit/has_many_collection_spec.rb +0 -28
- data/spec/unit/om_datastream_spec.rb +6 -6
- data/spec/unit/query_spec.rb +2 -2
- data/spec/unit/solr_config_options_spec.rb +1 -1
- data/spec/unit/solr_service_spec.rb +9 -1
- data/spec/unit/validations_spec.rb +18 -11
- metadata +18 -10
@@ -116,16 +116,17 @@ describe ActiveFedora::DatastreamCollections do
|
|
116
116
|
describe '#named_datastreams_ids' do
|
117
117
|
it 'should return a hash of datastream name to an array of dsids' do
|
118
118
|
@test_object2 = MockAFBaseDatastream.new
|
119
|
-
# @test_object2.new_object = true
|
120
119
|
f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
|
121
120
|
f2 = File.open(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ), 'rb')
|
122
|
-
|
123
|
-
f.stub(:content_type).and_return("image/jpeg")
|
124
|
-
@test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f, :label=>"testDS"})
|
121
|
+
@test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f})
|
125
122
|
@test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f2})
|
126
123
|
@test_object2.save
|
127
124
|
@test_object2 = MockAFBaseDatastream.find(@test_object2.pid)
|
128
|
-
@test_object2.named_datastreams_ids
|
125
|
+
named_datastreams_ids = @test_object2.named_datastreams_ids
|
126
|
+
|
127
|
+
expect(named_datastreams_ids.keys.sort).to eq(['high', 'thumbnail'])
|
128
|
+
expect(named_datastreams_ids['high']).to eq([])
|
129
|
+
expect(named_datastreams_ids['thumbnail'].sort).to eq(["THUMB1", "THUMB2"])
|
129
130
|
end
|
130
131
|
end
|
131
132
|
|
@@ -4,42 +4,45 @@ require 'active_fedora'
|
|
4
4
|
require "rexml/document"
|
5
5
|
|
6
6
|
describe ActiveFedora::Datastream do
|
7
|
+
|
8
|
+
before(:all) do
|
9
|
+
class MockAFBase < ActiveFedora::Base
|
10
|
+
has_metadata :name => "descMetadata", :type => ActiveFedora::QualifiedDublinCoreDatastream, :autocreate => true
|
11
|
+
end
|
12
|
+
end
|
7
13
|
|
8
14
|
before(:each) do
|
9
|
-
@test_object =
|
15
|
+
@test_object = MockAFBase.new
|
10
16
|
@test_object.save
|
11
17
|
end
|
12
18
|
|
13
19
|
after(:each) do
|
14
20
|
@test_object.delete
|
15
21
|
end
|
16
|
-
|
17
|
-
it "should be able to access Datastreams using datastreams method" do
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
dc.pid.should_not be_nil
|
22
|
-
# dc.control_group.should == "X"
|
22
|
+
|
23
|
+
it "should be able to access Datastreams using datastreams method" do
|
24
|
+
descMetadata = @test_object.datastreams["descMetadata"]
|
25
|
+
descMetadata.should be_a_kind_of(ActiveFedora::Datastream)
|
26
|
+
descMetadata.dsid.should eql("descMetadata")
|
23
27
|
end
|
24
|
-
|
28
|
+
|
25
29
|
it "should be able to access Datastream content using content method" do
|
26
|
-
|
27
|
-
|
30
|
+
descMetadata = @test_object.datastreams["descMetadata"].content
|
31
|
+
descMetadata.should_not be_nil
|
28
32
|
end
|
29
33
|
|
30
34
|
it "should be able to update XML Datastream content and save to Fedora" do
|
31
|
-
xml_content = Nokogiri::XML::Document.parse(@test_object.datastreams["
|
35
|
+
xml_content = Nokogiri::XML::Document.parse(@test_object.datastreams["descMetadata"].content)
|
32
36
|
title = Nokogiri::XML::Element.new "title", xml_content
|
33
37
|
title.content = "Test Title"
|
34
|
-
title.namespace = xml_content.xpath('//oai_dc:dc/dc:identifier').first.namespace
|
35
38
|
xml_content.root.add_child title
|
36
39
|
|
37
|
-
@test_object.datastreams["
|
38
|
-
@test_object.datastreams["
|
39
|
-
@test_object.datastreams["
|
40
|
+
@test_object.datastreams["descMetadata"].stub(:before_save)
|
41
|
+
@test_object.datastreams["descMetadata"].content = xml_content.to_s
|
42
|
+
@test_object.datastreams["descMetadata"].save
|
40
43
|
|
41
|
-
found = Nokogiri::XML::Document.parse(@test_object.class.find(@test_object.pid).datastreams['
|
42
|
-
found.xpath('
|
44
|
+
found = Nokogiri::XML::Document.parse(@test_object.class.find(@test_object.pid).datastreams['descMetadata'].content)
|
45
|
+
found.xpath('//dc/title/text()').first.inner_text.should == title.content
|
43
46
|
end
|
44
47
|
|
45
48
|
it "should be able to update Blob Datastream content and save to Fedora" do
|
@@ -107,7 +107,6 @@ describe ActiveFedora::Datastreams do
|
|
107
107
|
@has_file.file_ds.versionable.should be_false
|
108
108
|
test_obj = HasFile.find(@has_file.pid)
|
109
109
|
test_obj.file_ds.versionable.should be_false
|
110
|
-
test_obj.dc.changed?.should be_false
|
111
110
|
test_obj.rels_ext.changed?.should be_false
|
112
111
|
test_obj.file_ds.changed?.should be_false
|
113
112
|
test_obj.file_ds2.changed?.should be_false
|
@@ -116,7 +115,6 @@ describe ActiveFedora::Datastreams do
|
|
116
115
|
|
117
116
|
it "should use ds_specs on migrated objects" do
|
118
117
|
test_obj = HasFile.find(@base.pid)
|
119
|
-
test_obj.dc.changed?.should be_false
|
120
118
|
test_obj.file_ds.versionable.should be_false
|
121
119
|
test_obj.file_ds.new?.should be_true
|
122
120
|
test_obj.file_ds.content = "blah blah blah"
|
@@ -131,4 +129,4 @@ describe ActiveFedora::Datastreams do
|
|
131
129
|
test_obj.file_ds.dsLabel.should == "Pre-existing DS"
|
132
130
|
end
|
133
131
|
end
|
134
|
-
end
|
132
|
+
end
|
@@ -38,22 +38,22 @@ describe ActiveFedora::Model do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
describe "#find with a valid pid with cast" do
|
41
|
-
subject { ActiveFedora::Base.find('
|
42
|
-
it { should be_instance_of
|
41
|
+
subject { ActiveFedora::Base.find('test:fixture_mods_article1', :cast=>true) }
|
42
|
+
it { should be_instance_of ModsArticle}
|
43
43
|
end
|
44
44
|
describe "#find with a valid pid without cast" do
|
45
|
-
subject { ActiveFedora::Base.find('
|
45
|
+
subject { ActiveFedora::Base.find('test:fixture_mods_article1') }
|
46
46
|
it { should be_instance_of ActiveFedora::Base}
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe "#load_instance_from_solr" do
|
51
51
|
describe "with a valid pid" do
|
52
|
-
subject { ActiveFedora::Base.load_instance_from_solr('
|
53
|
-
it { should be_instance_of
|
52
|
+
subject { ActiveFedora::Base.load_instance_from_solr('test:fixture_mods_article1') }
|
53
|
+
it { should be_instance_of ModsArticle}
|
54
54
|
end
|
55
55
|
describe "with metadata datastream spec" do
|
56
|
-
subject { ActiveFedora::Base.load_instance_from_solr('
|
56
|
+
subject { ActiveFedora::Base.load_instance_from_solr('test:fixture_mods_article1') }
|
57
57
|
it "should create an xml datastream" do
|
58
58
|
subject.datastreams['properties'].should be_kind_of ActiveFedora::SimpleDatastream
|
59
59
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe ActiveFedora::Base do
|
4
4
|
describe ".update_indexed_attributes" do
|
5
5
|
before(:each) do
|
6
|
-
@test_article =
|
6
|
+
@test_article = ModsArticle.find("test:fixture_mods_article1")
|
7
7
|
@test_article.update_indexed_attributes({[{:person=>0}, :first_name] => "GIVEN NAMES"}, :datastreams=>"descMetadata")
|
8
8
|
end
|
9
9
|
after(:each) do
|
@@ -15,7 +15,7 @@ describe ActiveFedora::Base do
|
|
15
15
|
@test_article.update_indexed_attributes(test_args[:params], test_args[:opts])
|
16
16
|
@test_article.get_values_from_datastream("descMetadata", [{:person=>0}, :first_name]).should == ["Replacement FirstName"]
|
17
17
|
@test_article.save
|
18
|
-
retrieved_article =
|
18
|
+
retrieved_article = ModsArticle.find("test:fixture_mods_article1")
|
19
19
|
retrieved_article.get_values_from_datastream("descMetadata", [{:person=>0}, :first_name]).should == ["Replacement FirstName"]
|
20
20
|
end
|
21
21
|
end
|
@@ -11,30 +11,108 @@ describe "NestedAttribute behavior" do
|
|
11
11
|
delegate :uno, :to=>'someData', :unique=>true
|
12
12
|
delegate :dos, :to=>'someData', :unique=>true
|
13
13
|
end
|
14
|
+
|
15
|
+
# base Car class, used in test for association updates and :allow_destroy flag
|
14
16
|
class Car < ActiveFedora::Base
|
15
17
|
has_many :bars, :property=>:has_member
|
16
|
-
accepts_nested_attributes_for :bars
|
18
|
+
accepts_nested_attributes_for :bars, :allow_destroy=>true
|
19
|
+
end
|
20
|
+
|
21
|
+
# class used in test for :reject_if=>:all_blank
|
22
|
+
class CarAllBlank < Car
|
23
|
+
accepts_nested_attributes_for :bars, :reject_if=>:all_blank
|
17
24
|
end
|
18
25
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
26
|
+
# class used in test for :reject_if with proc object
|
27
|
+
class CarProc < Car
|
28
|
+
accepts_nested_attributes_for :bars, :reject_if=>proc { |attributes| attributes['uno'].blank? }
|
29
|
+
end
|
23
30
|
|
24
|
-
|
25
|
-
|
31
|
+
# class used in test for :reject_if with method name as symbol
|
32
|
+
class CarSymbol < Car
|
33
|
+
accepts_nested_attributes_for :bars, :reject_if=>:uno_blank
|
34
|
+
|
35
|
+
def uno_blank(attributes)
|
36
|
+
attributes['uno'].blank?
|
37
|
+
end
|
38
|
+
end
|
26
39
|
|
40
|
+
# class used in test for :limit
|
41
|
+
class CarWithLimit < Car
|
42
|
+
accepts_nested_attributes_for :bars, :limit => 1
|
43
|
+
end
|
27
44
|
end
|
28
45
|
|
29
46
|
it "should update the child objects" do
|
47
|
+
@car, @bar1, @bar2 = create_car_with_bars
|
48
|
+
|
30
49
|
@car.attributes = {:bars_attributes=>[{:id=>@bar1.pid, :uno=>"bar1 uno"}, {:uno=>"newbar uno"}, {:id=>@bar2.pid, :_destroy=>'1', :uno=>'bar2 uno'}]}
|
31
50
|
Bar.find(@bar1.pid).uno.should == 'bar1 uno'
|
32
|
-
|
33
|
-
|
51
|
+
Bar.where(:id => @bar2.pid).first.should be_nil
|
52
|
+
Bar.where(:uno => "newbar uno").first.should_not be_nil
|
53
|
+
|
54
|
+
bars = @car.bars(true)
|
55
|
+
bars.should include(@bar1)
|
56
|
+
bars.should_not include(@bar2)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should reject attributes when all blank" do
|
60
|
+
@car, @bar1, @bar2 = create_car_with_bars(CarAllBlank)
|
61
|
+
|
62
|
+
@car.bars.count.should == 2
|
63
|
+
@car.attributes = {:bars_attributes=>[{}, {:id=>@bar1.pid, :uno=>"bar1 uno"}]}
|
64
|
+
@car.bars(true).count.should == 2
|
34
65
|
|
66
|
+
@bar1.reload
|
67
|
+
@bar1.uno.should == "bar1 uno"
|
35
68
|
end
|
36
69
|
|
37
|
-
|
70
|
+
it "should reject attributes based on proc" do
|
71
|
+
@car, @bar1, @bar2 = create_car_with_bars(CarProc)
|
38
72
|
|
73
|
+
@car.attributes = {:bars_attributes=>[{}, {:id=>@bar1.pid, :uno=>"bar1 uno"}, {:id=>@bar2.pid, :dos=>"bar2 dos"}]}
|
74
|
+
@bar1.reload
|
75
|
+
@bar2.reload
|
76
|
+
@bar1.uno.should == "bar1 uno"
|
77
|
+
@bar2.dos.should be_nil
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should reject attributes base on method name" do
|
81
|
+
@car, @bar1, @bar2 = create_car_with_bars(CarSymbol)
|
82
|
+
|
83
|
+
@car.attributes = {:bars_attributes=>[{}, {:id=>@bar1.pid, :uno=>"bar1 uno"}, {:id=>@bar2.pid, :dos=>"bar2 dos"}]}
|
84
|
+
@bar1.reload
|
85
|
+
@bar2.reload
|
86
|
+
@bar1.uno.should == "bar1 uno"
|
87
|
+
@bar2.dos.should be_nil
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should throw TooManyRecords" do
|
91
|
+
@car, @bar1, @bar2 = create_car_with_bars(CarWithLimit)
|
92
|
+
|
93
|
+
lambda {
|
94
|
+
@car.attributes = {:bars_attributes=>[{}]}
|
95
|
+
}.should_not raise_exception
|
96
|
+
|
97
|
+
lambda {
|
98
|
+
@car.attributes = {:bars_attributes=>[{}, {}]}
|
99
|
+
}.should raise_exception(ActiveFedora::NestedAttributes::TooManyRecords)
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
# Helper method used to create 1 Car and 2 Bars (with option to provide classes for both models)
|
105
|
+
#
|
106
|
+
# @param car_class [class] class for new `car` object, default Car
|
107
|
+
# @param bar_class [class] class for new `bar` object, default Bar
|
108
|
+
#
|
109
|
+
# @return [car,bar,bar] returns 1 Car and 2 Bars
|
110
|
+
def create_car_with_bars(car_class = Car, bar_class = Bar)
|
111
|
+
car = car_class.new; car.save
|
112
|
+
|
113
|
+
bar1 = bar_class.new(:car=>car); bar1.save
|
114
|
+
bar2 = bar_class.new(:car=>car); bar2.save
|
115
|
+
[car, bar1, bar2]
|
116
|
+
end
|
39
117
|
|
40
118
|
end
|
@@ -148,7 +148,7 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
148
148
|
|
149
149
|
it "should write rdf with proper subjects" do
|
150
150
|
@subject.rdf.type = "Frog"
|
151
|
-
@subject.inner_object.pid = '
|
151
|
+
@subject.inner_object.pid = 'test:99'
|
152
152
|
@subject.save!
|
153
153
|
@subject.reload
|
154
154
|
@subject.rdf.graph.dump(:ntriples).should == "<http://oregondigital.org/ns/99> <http://purl.org/dc/terms/type> \"Frog\" .\n"
|
@@ -5,19 +5,19 @@ describe ActiveFedora::OmDatastream do
|
|
5
5
|
|
6
6
|
describe "an new instance with a inline datastream" do
|
7
7
|
before do
|
8
|
-
class
|
8
|
+
class ModsArticle3 < ActiveFedora::Base
|
9
9
|
# Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
|
10
10
|
has_metadata :name => "descMetadata", :type => Hydra::ModsArticleDatastream, :control_group => 'X'
|
11
11
|
|
12
12
|
end
|
13
13
|
|
14
|
-
@obj =
|
14
|
+
@obj = ModsArticle3.new
|
15
15
|
@obj.save
|
16
16
|
@obj.descMetadata.should be_inline
|
17
17
|
end
|
18
18
|
after do
|
19
19
|
@obj.destroy
|
20
|
-
Object.send(:remove_const, :
|
20
|
+
Object.send(:remove_const, :ModsArticle3)
|
21
21
|
end
|
22
22
|
it "should not be changed when no fields have been set" do
|
23
23
|
@obj.descMetadata.should_not be_content_changed
|
@@ -28,15 +28,15 @@ describe ActiveFedora::OmDatastream do
|
|
28
28
|
end
|
29
29
|
describe "#changed?" do
|
30
30
|
it "should not be changed if the new xml matches the old xml" do
|
31
|
-
@pid = "
|
32
|
-
@test_object =
|
31
|
+
@pid = "test:fixture_mods_article2"
|
32
|
+
@test_object = ModsArticle3.find(@pid)
|
33
33
|
|
34
34
|
@test_object.descMetadata.ng_xml = @test_object.descMetadata.ng_xml
|
35
35
|
@test_object.descMetadata.should_not be_changed
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should not be changed if there are minor differences in whitespace" do
|
39
|
-
obj =
|
39
|
+
obj = ModsArticle3.new
|
40
40
|
obj.descMetadata.content = "<a>1</a>"
|
41
41
|
obj.save
|
42
42
|
obj.descMetadata.should_not be_changed
|
@@ -49,27 +49,27 @@ describe ActiveFedora::OmDatastream do
|
|
49
49
|
|
50
50
|
describe "an instance that is a managed datastream" do
|
51
51
|
before(:all) do
|
52
|
-
class
|
52
|
+
class ModsArticle2 < ActiveFedora::Base
|
53
53
|
# Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
|
54
54
|
has_metadata :name => "descMetadata", :type => Hydra::ModsArticleDatastream
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
after(:all) do
|
59
|
-
Object.send(:remove_const, :
|
59
|
+
Object.send(:remove_const, :ModsArticle2)
|
60
60
|
end
|
61
61
|
|
62
62
|
describe "#changed?" do
|
63
63
|
it "should not be changed if the new xml matches the old xml" do
|
64
|
-
@pid = "
|
65
|
-
@test_object =
|
64
|
+
@pid = "test:fixture_mods_article2"
|
65
|
+
@test_object = ModsArticle2.find(@pid)
|
66
66
|
|
67
67
|
@test_object.descMetadata.ng_xml = @test_object.descMetadata.ng_xml
|
68
68
|
@test_object.descMetadata.should_not be_changed
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should be changed if there are minor differences in whitespace" do
|
72
|
-
obj =
|
72
|
+
obj = ModsArticle2.new
|
73
73
|
obj.descMetadata.content = "<a>1</a>"
|
74
74
|
obj.save
|
75
75
|
obj.descMetadata.should_not be_changed
|
@@ -82,7 +82,7 @@ describe ActiveFedora::OmDatastream do
|
|
82
82
|
|
83
83
|
describe "empty datastream content" do
|
84
84
|
it "should not break when there is empty datastream content" do
|
85
|
-
obj =
|
85
|
+
obj = ModsArticle2.new
|
86
86
|
obj.descMetadata.content = ""
|
87
87
|
obj.save
|
88
88
|
|
@@ -91,11 +91,11 @@ describe ActiveFedora::OmDatastream do
|
|
91
91
|
|
92
92
|
describe '.term_values' do
|
93
93
|
before do
|
94
|
-
@pid = "
|
95
|
-
@test_object =
|
96
|
-
@test_object.descMetadata.content = File.read(fixture('mods_articles/
|
94
|
+
@pid = "test:fixture_mods_article2"
|
95
|
+
@test_object = ModsArticle2.find(@pid)
|
96
|
+
@test_object.descMetadata.content = File.read(fixture('mods_articles/mods_article1.xml'))
|
97
97
|
@test_object.save
|
98
|
-
@test_object =
|
98
|
+
@test_object = ModsArticle2.find(@pid)
|
99
99
|
@test_solr_object = ActiveFedora::Base.load_instance_from_solr(@pid)
|
100
100
|
end
|
101
101
|
|
@@ -130,11 +130,11 @@ describe ActiveFedora::OmDatastream do
|
|
130
130
|
|
131
131
|
describe '.update_values' do
|
132
132
|
before do
|
133
|
-
@pid = "
|
134
|
-
@test_object =
|
135
|
-
@test_object.descMetadata.content = File.read(fixture('mods_articles/
|
133
|
+
@pid = "test:fixture_mods_article2"
|
134
|
+
@test_object = ModsArticle2.find(@pid)
|
135
|
+
@test_object.descMetadata.content = File.read(fixture('mods_articles/mods_article1.xml'))
|
136
136
|
@test_object.save
|
137
|
-
@test_object =
|
137
|
+
@test_object = ModsArticle2.find(@pid)
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should not be dirty after .update_values is saved" do
|
@@ -149,10 +149,10 @@ describe ActiveFedora::OmDatastream do
|
|
149
149
|
|
150
150
|
describe ".to_solr" do
|
151
151
|
before do
|
152
|
-
object =
|
152
|
+
object = ModsArticle2.new
|
153
153
|
object.descMetadata.journal.issue.publication_date = Date.parse('2012-11-02')
|
154
154
|
object.save!
|
155
|
-
@test_object =
|
155
|
+
@test_object = ModsArticle2.find(object.pid)
|
156
156
|
|
157
157
|
end
|
158
158
|
it "should solrize terms with :type=>'date' to *_dt solr terms" do
|
@@ -10,7 +10,7 @@ describe ActiveFedora::SolrInstanceLoader do
|
|
10
10
|
subject { ActiveFedora::SolrInstanceLoader.new(context, pid, solr_doc) }
|
11
11
|
|
12
12
|
describe 'existing pid' do
|
13
|
-
let(:pid) { '
|
13
|
+
let(:pid) { 'test:fixture_mods_article1' }
|
14
14
|
describe 'without a solr document' do
|
15
15
|
it 'it finds the SOLR document and casts into an AF::Base object' do
|
16
16
|
expect(subject.object).to eq(active_fedora_object)
|
@@ -23,7 +23,7 @@ describe ActiveFedora::SolrInstanceLoader do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
describe 'with a mismatching solr document' do
|
26
|
-
let(:mismatching_pid) { '
|
26
|
+
let(:mismatching_pid) { 'test:fixture_mods_article2' }
|
27
27
|
let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id=>mismatching_pid).first }
|
28
28
|
it 'it raise ObjectNotFoundError' do
|
29
29
|
expect {
|
@@ -33,7 +33,7 @@ describe ActiveFedora::SolrInstanceLoader do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
describe 'missing pid' do
|
36
|
-
let(:pid) { '
|
36
|
+
let(:pid) { 'test:fixture_mods_article8675309' }
|
37
37
|
describe 'without a solr document' do
|
38
38
|
it 'it raise ObjectNotFoundError' do
|
39
39
|
expect {
|
@@ -50,7 +50,7 @@ describe ActiveFedora::SolrInstanceLoader do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
describe 'with a mismatching solr document' do
|
53
|
-
let(:mismatching_pid) { '
|
53
|
+
let(:mismatching_pid) { 'test:fixture_mods_article2' }
|
54
54
|
let(:solr_doc) { ActiveFedora::Base.find_with_conditions(:id=>mismatching_pid).first }
|
55
55
|
it 'it raise ObjectNotFoundError' do
|
56
56
|
expect {
|
@@ -68,7 +68,7 @@ describe ActiveFedora::SolrService do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'should instantiate all datastreams in the solr doc, even ones undeclared by the class' do
|
71
|
-
obj = ActiveFedora::Base.load_instance_from_solr "
|
71
|
+
obj = ActiveFedora::Base.load_instance_from_solr "test:fixture_mods_article1"
|
72
72
|
obj.datastreams.keys.should include('descMetadata')
|
73
73
|
end
|
74
74
|
|