active-fedora 8.2.1 → 8.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/active-fedora.gemspec +1 -2
- data/lib/active_fedora/datastream_collections.rb +4 -8
- data/lib/active_fedora/datastreams.rb +7 -9
- data/lib/active_fedora/version.rb +1 -1
- data/spec/config_helper.rb +3 -3
- data/spec/integration/associations_spec.rb +76 -76
- data/spec/integration/auditable_spec.rb +7 -7
- data/spec/integration/autosave_association_spec.rb +3 -3
- data/spec/integration/base_spec.rb +51 -51
- data/spec/integration/belongs_to_association_spec.rb +27 -27
- data/spec/integration/bug_spec.rb +1 -1
- data/spec/integration/collection_association_spec.rb +2 -2
- data/spec/integration/complex_rdf_datastream_spec.rb +32 -32
- data/spec/integration/datastream_collections_spec.rb +42 -42
- data/spec/integration/datastream_spec.rb +19 -19
- data/spec/integration/datastreams_spec.rb +25 -25
- data/spec/integration/delete_all_spec.rb +5 -5
- data/spec/integration/fedora_solr_sync_spec.rb +1 -1
- data/spec/integration/full_featured_model_spec.rb +9 -9
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +46 -47
- data/spec/integration/has_many_associations_spec.rb +17 -17
- data/spec/integration/json_serialization_spec.rb +2 -2
- data/spec/integration/load_from_solr_spec.rb +1 -1
- data/spec/integration/model_spec.rb +9 -9
- data/spec/integration/nested_attribute_spec.rb +17 -17
- data/spec/integration/ntriples_datastream_spec.rb +43 -43
- data/spec/integration/om_datastream_spec.rb +37 -37
- data/spec/integration/persistence_spec.rb +1 -1
- data/spec/integration/rdf_nested_attributes_spec.rb +9 -9
- data/spec/integration/relation_delegation_spec.rb +7 -7
- data/spec/integration/relation_spec.rb +2 -2
- data/spec/integration/rels_ext_datastream_spec.rb +3 -3
- data/spec/integration/scoped_query_spec.rb +14 -14
- data/spec/integration/solr_service_spec.rb +24 -24
- data/spec/support/mock_fedora.rb +9 -10
- data/spec/unit/active_fedora_spec.rb +20 -20
- data/spec/unit/attributes_spec.rb +24 -24
- data/spec/unit/base_active_model_spec.rb +6 -6
- data/spec/unit/base_cma_spec.rb +2 -2
- data/spec/unit/base_datastream_management_spec.rb +7 -7
- data/spec/unit/base_extra_spec.rb +20 -20
- data/spec/unit/base_spec.rb +141 -141
- data/spec/unit/builder/has_and_belongs_to_many_spec.rb +1 -1
- data/spec/unit/callback_spec.rb +12 -12
- data/spec/unit/code_configurator_spec.rb +7 -7
- data/spec/unit/config_spec.rb +2 -2
- data/spec/unit/content_model_spec.rb +19 -20
- data/spec/unit/core_spec.rb +1 -1
- data/spec/unit/datastream_collections_spec.rb +101 -101
- data/spec/unit/datastream_spec.rb +12 -12
- data/spec/unit/datastreams_spec.rb +39 -39
- data/spec/unit/file_configurator_spec.rb +117 -117
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +16 -16
- data/spec/unit/has_many_collection_spec.rb +5 -5
- data/spec/unit/inheritance_spec.rb +5 -5
- data/spec/unit/model_spec.rb +5 -5
- data/spec/unit/nom_datastream_spec.rb +5 -5
- data/spec/unit/ntriples_datastream_spec.rb +56 -56
- data/spec/unit/om_datastream_spec.rb +99 -99
- data/spec/unit/persistence_spec.rb +2 -2
- data/spec/unit/predicates_spec.rb +28 -28
- data/spec/unit/property_spec.rb +5 -5
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +10 -10
- data/spec/unit/query_spec.rb +66 -66
- data/spec/unit/rdf_datastream_spec.rb +10 -10
- data/spec/unit/rdf_resource_datastream_spec.rb +2 -2
- data/spec/unit/rdf_xml_writer_spec.rb +3 -3
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +9 -9
- data/spec/unit/relationship_graph_spec.rb +31 -31
- data/spec/unit/reload_on_save_spec.rb +3 -3
- data/spec/unit/rels_ext_datastream_spec.rb +28 -28
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +11 -11
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +11 -11
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +11 -11
- data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +7 -7
- data/spec/unit/rubydora_connection_spec.rb +3 -3
- data/spec/unit/semantic_node_spec.rb +17 -17
- data/spec/unit/serializers_spec.rb +1 -1
- data/spec/unit/service_definitions_spec.rb +11 -11
- data/spec/unit/simple_datastream_spec.rb +6 -6
- data/spec/unit/solr_config_options_spec.rb +10 -10
- data/spec/unit/solr_digital_object_spec.rb +4 -4
- data/spec/unit/solr_service_spec.rb +41 -41
- data/spec/unit/unsaved_digital_object_spec.rb +8 -8
- data/spec/unit/validations_spec.rb +6 -6
- metadata +4 -4
@@ -29,11 +29,11 @@ describe ActiveFedora::Model do
|
|
29
29
|
describe "#all" do
|
30
30
|
it "should return an array of instances of the calling Class" do
|
31
31
|
result = ModelIntegrationSpec::Basic.all.to_a
|
32
|
-
result.
|
32
|
+
expect(result).to be_instance_of(Array)
|
33
33
|
# this test is meaningless if the array length is zero
|
34
|
-
result.length.
|
34
|
+
expect(result.length).to be > 0
|
35
35
|
result.each do |obj|
|
36
|
-
obj.class.
|
36
|
+
expect(obj.class).to eq(ModelIntegrationSpec::Basic)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -41,31 +41,31 @@ describe ActiveFedora::Model do
|
|
41
41
|
describe '#find' do
|
42
42
|
describe "#find with a valid pid without cast" do
|
43
43
|
subject { ActiveFedora::Base.find(@test_instance.pid) }
|
44
|
-
it {
|
44
|
+
it { is_expected.to be_instance_of ModelIntegrationSpec::Basic}
|
45
45
|
end
|
46
46
|
describe "#find with a valid pid with cast of false" do
|
47
47
|
subject { ActiveFedora::Base.find(@test_instance.pid, cast: false) }
|
48
|
-
it {
|
48
|
+
it { is_expected.to be_instance_of ActiveFedora::Base}
|
49
49
|
end
|
50
50
|
describe "#find with a valid pid without cast on a model extending Base" do
|
51
51
|
subject { ModelIntegrationSpec::Basic.find(@test_instance.pid) }
|
52
|
-
it {
|
52
|
+
it { is_expected.to be_instance_of ModelIntegrationSpec::Basic}
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
describe "#load_instance_from_solr" do
|
57
57
|
describe "with a valid pid" do
|
58
58
|
subject { ActiveFedora::Base.load_instance_from_solr(@test_instance.pid) }
|
59
|
-
it {
|
59
|
+
it { is_expected.to be_instance_of ModelIntegrationSpec::Basic}
|
60
60
|
end
|
61
61
|
describe "with metadata datastream spec" do
|
62
62
|
subject { ActiveFedora::Base.load_instance_from_solr(@test_instance.pid) }
|
63
63
|
it "should create an xml datastream" do
|
64
|
-
subject.datastreams['properties'].
|
64
|
+
expect(subject.datastreams['properties']).to be_kind_of ActiveFedora::SimpleDatastream
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should know the datastreams properties" do
|
68
|
-
subject.properties.dsSize.
|
68
|
+
expect(subject.properties.dsSize).to eq(9)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
@@ -43,31 +43,31 @@ describe "NestedAttribute behavior" do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should have _destroy" do
|
46
|
-
Bar.new._destroy.
|
46
|
+
expect(Bar.new._destroy).to be_falsey
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should update the child objects" do
|
50
50
|
@car, @bar1, @bar2 = create_car_with_bars
|
51
51
|
|
52
52
|
@car.attributes = {:bars_attributes=>[{:id=>@bar1.pid, :uno=>"bar1 uno"}, {:uno=>"newbar uno"}, {:id=>@bar2.pid, :_destroy=>'1', :uno=>'bar2 uno'}]}
|
53
|
-
Bar.find(@bar1.pid).uno.
|
54
|
-
Bar.where(:id => @bar2.pid).first.
|
55
|
-
Bar.where(:uno => "newbar uno").first.
|
53
|
+
expect(Bar.find(@bar1.pid).uno).to eq('bar1 uno')
|
54
|
+
expect(Bar.where(:id => @bar2.pid).first).to be_nil
|
55
|
+
expect(Bar.where(:uno => "newbar uno").first).not_to be_nil
|
56
56
|
|
57
57
|
bars = @car.bars(true)
|
58
|
-
bars.
|
59
|
-
bars.
|
58
|
+
expect(bars).to include(@bar1)
|
59
|
+
expect(bars).not_to include(@bar2)
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should reject attributes when all blank" do
|
63
63
|
@car, @bar1, @bar2 = create_car_with_bars(CarAllBlank)
|
64
64
|
|
65
|
-
@car.bars.count.
|
65
|
+
expect(@car.bars.count).to eq(2)
|
66
66
|
@car.attributes = {:bars_attributes=>[{}, {:id=>@bar1.pid, :uno=>"bar1 uno"}]}
|
67
|
-
@car.bars(true).count.
|
67
|
+
expect(@car.bars(true).count).to eq(2)
|
68
68
|
|
69
69
|
@bar1.reload
|
70
|
-
@bar1.uno.
|
70
|
+
expect(@bar1.uno).to eq("bar1 uno")
|
71
71
|
end
|
72
72
|
|
73
73
|
it "should reject attributes based on proc" do
|
@@ -76,8 +76,8 @@ describe "NestedAttribute behavior" do
|
|
76
76
|
@car.attributes = {:bars_attributes=>[{}, {:id=>@bar1.pid, :uno=>"bar1 uno"}, {:id=>@bar2.pid, :dos=>"bar2 dos"}]}
|
77
77
|
@bar1.reload
|
78
78
|
@bar2.reload
|
79
|
-
@bar1.uno.
|
80
|
-
@bar2.dos.
|
79
|
+
expect(@bar1.uno).to eq("bar1 uno")
|
80
|
+
expect(@bar2.dos).to be_nil
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should reject attributes base on method name" do
|
@@ -86,20 +86,20 @@ describe "NestedAttribute behavior" do
|
|
86
86
|
@car.attributes = {:bars_attributes=>[{}, {:id=>@bar1.pid, :uno=>"bar1 uno"}, {:id=>@bar2.pid, :dos=>"bar2 dos"}]}
|
87
87
|
@bar1.reload
|
88
88
|
@bar2.reload
|
89
|
-
@bar1.uno.
|
90
|
-
@bar2.dos.
|
89
|
+
expect(@bar1.uno).to eq("bar1 uno")
|
90
|
+
expect(@bar2.dos).to be_nil
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should throw TooManyRecords" do
|
94
94
|
@car, @bar1, @bar2 = create_car_with_bars(CarWithLimit)
|
95
95
|
|
96
|
-
|
96
|
+
expect {
|
97
97
|
@car.attributes = {:bars_attributes=>[{}]}
|
98
|
-
}.
|
98
|
+
}.not_to raise_exception
|
99
99
|
|
100
|
-
|
100
|
+
expect {
|
101
101
|
@car.attributes = {:bars_attributes=>[{}, {}]}
|
102
|
-
}.
|
102
|
+
}.to raise_exception(ActiveFedora::NestedAttributes::TooManyRecords)
|
103
103
|
end
|
104
104
|
|
105
105
|
private
|
@@ -49,25 +49,25 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
49
49
|
foo = RdfTest.new(pid: 'test:1') #Pid needs to match the subject in the loaded file
|
50
50
|
foo.title = 'Hamlet'
|
51
51
|
foo.save
|
52
|
-
foo.title.
|
52
|
+
expect(foo.title).to eq('Hamlet')
|
53
53
|
foo.rdf.content = File.new('spec/fixtures/mixed_rdf_descMetadata.nt').read
|
54
54
|
foo.save
|
55
|
-
foo.title.
|
55
|
+
expect(foo.title).to eq('Title of work')
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should delegate as_json to the fields" do
|
59
59
|
@subject = RdfTest.new(title: "Title of work")
|
60
|
-
@subject.rdf.title.as_json.
|
61
|
-
@subject.rdf.title.to_json.
|
60
|
+
expect(@subject.rdf.title.as_json).to eq(["Title of work"])
|
61
|
+
expect(@subject.rdf.title.to_json).to eq("\[\"Title of work\"\]")
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should solrize even when the object is not new" do
|
65
65
|
foo = RdfTest.new
|
66
|
-
foo.
|
66
|
+
expect(foo).to receive(:update_index).once
|
67
67
|
foo.title = "title1"
|
68
68
|
foo.save
|
69
69
|
foo = RdfTest.find(foo.pid)
|
70
|
-
foo.
|
70
|
+
expect(foo).to receive(:update_index).once
|
71
71
|
foo.title = "The Work2"
|
72
72
|
foo.save
|
73
73
|
end
|
@@ -75,36 +75,36 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
75
75
|
describe "serializing" do
|
76
76
|
it "should handle dates" do
|
77
77
|
subject.date_uploaded = [Date.parse('2012-11-02')]
|
78
|
-
subject.date_uploaded.first.
|
78
|
+
expect(subject.date_uploaded.first).to be_kind_of Date
|
79
79
|
solr_document = subject.to_solr
|
80
|
-
solr_document[ActiveFedora::SolrService.solr_name('rdf__date_uploaded', type: :date)].
|
80
|
+
expect(solr_document[ActiveFedora::SolrService.solr_name('rdf__date_uploaded', type: :date)]).to eq(['2012-11-02T00:00:00Z'])
|
81
81
|
end
|
82
82
|
it "should handle integers" do
|
83
83
|
subject.filesize = 12345
|
84
|
-
subject.filesize.
|
84
|
+
expect(subject.filesize).to be_kind_of Fixnum
|
85
85
|
solr_document = subject.to_solr
|
86
|
-
solr_document[ActiveFedora::SolrService.solr_name('rdf__filesize', :stored_sortable, type: :integer)].
|
86
|
+
expect(solr_document[ActiveFedora::SolrService.solr_name('rdf__filesize', :stored_sortable, type: :integer)]).to eq('12345')
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should produce a solr document" do
|
91
91
|
@subject = RdfTest.new(title: "War and Peace")
|
92
92
|
solr_document = @subject.to_solr
|
93
|
-
solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :facetable)].
|
94
|
-
solr_document[ActiveFedora::SolrService.solr_name('rdf__title', type: :string)].
|
93
|
+
expect(solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :facetable)]).to eq(["War and Peace"])
|
94
|
+
expect(solr_document[ActiveFedora::SolrService.solr_name('rdf__title', type: :string)]).to eq(["War and Peace"])
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should set and recall values" do
|
98
98
|
@subject.title = 'War and Peace'
|
99
|
-
@subject.rdf.
|
99
|
+
expect(@subject.rdf).to be_changed
|
100
100
|
@subject.based_near = ["Moscow, Russia"]
|
101
101
|
@subject.related_url = ["http://en.wikipedia.org/wiki/War_and_Peace"]
|
102
102
|
@subject.part = ["this is a part"]
|
103
103
|
@subject.save
|
104
|
-
@subject.title.
|
105
|
-
@subject.based_near.
|
106
|
-
@subject.related_url.
|
107
|
-
@subject.part.
|
104
|
+
expect(@subject.title).to eq('War and Peace')
|
105
|
+
expect(@subject.based_near).to eq(["Moscow, Russia"])
|
106
|
+
expect(@subject.related_url).to eq(["http://en.wikipedia.org/wiki/War_and_Peace"])
|
107
|
+
expect(@subject.part).to eq(["this is a part"])
|
108
108
|
end
|
109
109
|
it "should set, persist, and recall values" do
|
110
110
|
@subject.title = 'War and Peace'
|
@@ -114,24 +114,24 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
114
114
|
@subject.save
|
115
115
|
|
116
116
|
loaded = RdfTest.find(@subject.pid)
|
117
|
-
loaded.title.
|
118
|
-
loaded.based_near.
|
119
|
-
loaded.related_url.
|
120
|
-
loaded.part.
|
117
|
+
expect(loaded.title).to eq('War and Peace')
|
118
|
+
expect(loaded.based_near).to eq(['Moscow, Russia'])
|
119
|
+
expect(loaded.related_url).to eq(['http://en.wikipedia.org/wiki/War_and_Peace'])
|
120
|
+
expect(loaded.part).to eq(['this is a part'])
|
121
121
|
end
|
122
122
|
it "should set multiple values" do
|
123
123
|
@subject.part = ["part 1", "part 2"]
|
124
124
|
@subject.save
|
125
125
|
|
126
126
|
loaded = RdfTest.find(@subject.pid)
|
127
|
-
loaded.part.
|
127
|
+
expect(loaded.part).to eq(['part 1', 'part 2'])
|
128
128
|
end
|
129
129
|
it "should append values" do
|
130
130
|
@subject.part = ["thing 1"]
|
131
131
|
@subject.save
|
132
132
|
|
133
133
|
@subject.part << "thing 2"
|
134
|
-
@subject.part.
|
134
|
+
expect(@subject.part).to eq(["thing 1", "thing 2"])
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should be able to save a blank document" do
|
@@ -144,7 +144,7 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
144
144
|
<http://oregondigital.org/ns/62> <http://purl.org/dc/terms/spatial> "Benton County (Ore.)" .
|
145
145
|
'
|
146
146
|
@subject.rdf.content = ntrip
|
147
|
-
@subject.rdf.graph.dump(:ntriples).
|
147
|
+
expect(@subject.rdf.graph.dump(:ntriples)).to eq(ntrip)
|
148
148
|
end
|
149
149
|
|
150
150
|
describe "using rdf_subject" do
|
@@ -165,7 +165,7 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
165
165
|
@subject.rdf.dctype = "Frog"
|
166
166
|
@subject.save!
|
167
167
|
@subject.reload
|
168
|
-
@subject.rdf.graph.dump(:ntriples).
|
168
|
+
expect(@subject.rdf.graph.dump(:ntriples)).to eq("<http://oregondigital.org/ns/99> <http://purl.org/dc/terms/type> \"Frog\" .\n")
|
169
169
|
@subject.rdf.dctype == ['Frog']
|
170
170
|
|
171
171
|
end
|
@@ -178,32 +178,32 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
178
178
|
@subject.related_url = ["http://psu.edu/"]
|
179
179
|
@subject.related_url << "http://projecthydra.org/"
|
180
180
|
|
181
|
-
@subject.title.
|
182
|
-
@subject.related_url.
|
183
|
-
@subject.related_url.
|
181
|
+
expect(@subject.title).to eq("Hamlet")
|
182
|
+
expect(@subject.related_url).to include("http://psu.edu/")
|
183
|
+
expect(@subject.related_url).to include("http://projecthydra.org/")
|
184
184
|
|
185
185
|
@subject.title = "" #empty string can be meaningful, don't assume delete.
|
186
|
-
@subject.title.
|
186
|
+
expect(@subject.title).to eq('')
|
187
187
|
|
188
188
|
@subject.title = nil
|
189
189
|
@subject.related_url.delete("http://projecthydra.org/")
|
190
190
|
|
191
|
-
@subject.title.
|
192
|
-
@subject.related_url.
|
191
|
+
expect(@subject.title).to be_nil
|
192
|
+
expect(@subject.related_url).to eq(["http://psu.edu/"])
|
193
193
|
end
|
194
194
|
it "should delete multiple values at once" do
|
195
195
|
@subject.part = ["MacBeth"]
|
196
196
|
@subject.part << "Hamlet"
|
197
197
|
@subject.part << "Romeo & Juliet"
|
198
|
-
@subject.part.first.
|
198
|
+
expect(@subject.part.first).to eq("MacBeth")
|
199
199
|
@subject.part.delete("MacBeth", "Romeo & Juliet")
|
200
|
-
@subject.part.
|
201
|
-
@subject.part.first.
|
200
|
+
expect(@subject.part).to eq(["Hamlet"])
|
201
|
+
expect(@subject.part.first).to eq("Hamlet")
|
202
202
|
end
|
203
203
|
it "should ignore values to be deleted that do not exist" do
|
204
204
|
@subject.part = ["title1", "title2", "title3"]
|
205
205
|
@subject.part.delete("title2", "title4", "title6")
|
206
|
-
@subject.part.
|
206
|
+
expect(@subject.part).to eq(["title1", "title3"])
|
207
207
|
end
|
208
208
|
describe "term proxy methods" do
|
209
209
|
before(:each) do
|
@@ -224,25 +224,25 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
224
224
|
end
|
225
225
|
|
226
226
|
it "should support the count method to determine # of values" do
|
227
|
-
@subject.title.count.
|
227
|
+
expect(@subject.title.count).to eq(3)
|
228
228
|
end
|
229
229
|
it "should iterate over multiple values" do
|
230
|
-
@subject.title.
|
230
|
+
expect(@subject.title).to respond_to(:each)
|
231
231
|
end
|
232
232
|
it "should get the first value" do
|
233
|
-
@subject.title.first.
|
233
|
+
expect(@subject.title.first).to eq("title1")
|
234
234
|
end
|
235
235
|
it "should evaluate equality predictably" do
|
236
|
-
@subject.title.
|
236
|
+
expect(@subject.title).to eq(["title1", "title2", "title3"])
|
237
237
|
end
|
238
238
|
it "should support the empty? method" do
|
239
|
-
@subject.title.
|
240
|
-
@subject.title.empty
|
239
|
+
expect(@subject.title).to respond_to(:empty?)
|
240
|
+
expect(@subject.title.empty?).to be_falsey
|
241
241
|
@subject.title.delete("title1", "title2", "title3")
|
242
|
-
@subject.title.empty
|
242
|
+
expect(@subject.title.empty?).to be_truthy
|
243
243
|
end
|
244
244
|
it "should support the is_a? method" do
|
245
|
-
@subject.title.is_a?(Array).
|
245
|
+
expect(@subject.title.is_a?(Array)).to eq(true)
|
246
246
|
end
|
247
247
|
end
|
248
248
|
end
|
@@ -26,28 +26,28 @@ describe ActiveFedora::OmDatastream do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should report being inline" do
|
29
|
-
@obj.descMetadata.
|
29
|
+
expect(@obj.descMetadata).to be_inline
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should not be changed when no fields have been set" do
|
33
|
-
@obj.descMetadata.
|
33
|
+
expect(@obj.descMetadata).not_to be_changed
|
34
34
|
end
|
35
35
|
it "should be changed when a field has been set" do
|
36
36
|
@obj.descMetadata.title = 'Foobar'
|
37
|
-
@obj.descMetadata.
|
37
|
+
expect(@obj.descMetadata).to be_changed
|
38
38
|
end
|
39
39
|
describe "#changed?" do
|
40
40
|
it "should not be changed if the new xml matches the old xml" do
|
41
41
|
@obj.descMetadata.content = @obj.descMetadata.content
|
42
|
-
@obj.descMetadata.
|
42
|
+
expect(@obj.descMetadata).not_to be_changed
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should not be changed if there are minor differences in whitespace" do
|
46
46
|
@obj.descMetadata.content = "<a><b>1</b></a>"
|
47
47
|
@obj.save
|
48
|
-
@obj.descMetadata.
|
48
|
+
expect(@obj.descMetadata).not_to be_changed
|
49
49
|
@obj.descMetadata.content = "<a>\n<b>1</b>\n</a>"
|
50
|
-
@obj.descMetadata.
|
50
|
+
expect(@obj.descMetadata).not_to be_changed
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -75,21 +75,21 @@ describe ActiveFedora::OmDatastream do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should not report being inline" do
|
78
|
-
@obj.descMetadata.
|
78
|
+
expect(@obj.descMetadata).to be_managed
|
79
79
|
end
|
80
80
|
|
81
81
|
describe "#changed?" do
|
82
82
|
it "should not be changed if the new xml matches the old xml" do
|
83
83
|
@obj.descMetadata.content = @obj.descMetadata.content
|
84
|
-
@obj.descMetadata.
|
84
|
+
expect(@obj.descMetadata).not_to be_changed
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should be changed if there are minor differences in whitespace" do
|
88
88
|
@obj.descMetadata.content = "<a><b>1</b></a>"
|
89
89
|
@obj.save
|
90
|
-
@obj.descMetadata.
|
90
|
+
expect(@obj.descMetadata).not_to be_changed
|
91
91
|
@obj.descMetadata.content = "<a>\n<b>1</b>\n</a>"
|
92
|
-
@obj.descMetadata.
|
92
|
+
expect(@obj.descMetadata).to be_changed
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -109,31 +109,31 @@ describe ActiveFedora::OmDatastream do
|
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should return the same values whether getting from solr or Fedora" do
|
112
|
-
@solr_obj.datastreams["descMetadata"].term_values(:name,:role,:text).
|
113
|
-
@solr_obj.datastreams["descMetadata"].term_values({:name=>0},:role,:text).
|
114
|
-
@solr_obj.datastreams["descMetadata"].term_values({:name=>1},:role,:text).
|
115
|
-
@solr_obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).
|
116
|
-
@solr_obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>0},:text).
|
117
|
-
@solr_obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>1},:text).
|
112
|
+
expect(@solr_obj.datastreams["descMetadata"].term_values(:name,:role,:text)).to eq(["Creator","Contributor","Funder","Host"])
|
113
|
+
expect(@solr_obj.datastreams["descMetadata"].term_values({:name=>0},:role,:text)).to eq(["Creator"])
|
114
|
+
expect(@solr_obj.datastreams["descMetadata"].term_values({:name=>1},:role,:text)).to eq(["Contributor"])
|
115
|
+
expect(@solr_obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text)).to eq(["Creator"])
|
116
|
+
expect(@solr_obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>0},:text)).to eq(["Contributor"])
|
117
|
+
expect(@solr_obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>1},:text)).to eq([])
|
118
118
|
ar = @solr_obj.datastreams["descMetadata"].term_values(:name,{:role=>0},:text)
|
119
|
-
ar.length.
|
120
|
-
ar.include?("Creator").
|
121
|
-
ar.include?("Contributor").
|
122
|
-
ar.include?("Funder").
|
123
|
-
ar.include?("Host").
|
124
|
-
|
125
|
-
@obj.datastreams["descMetadata"].term_values(:name,:role,:text).
|
126
|
-
@obj.datastreams["descMetadata"].term_values({:name=>0},:role,:text).
|
127
|
-
@obj.datastreams["descMetadata"].term_values({:name=>1},:role,:text).
|
128
|
-
@obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).
|
129
|
-
@obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>0},:text).
|
130
|
-
@obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>1},:text).
|
119
|
+
expect(ar.length).to eq(4)
|
120
|
+
expect(ar.include?("Creator")).to eq(true)
|
121
|
+
expect(ar.include?("Contributor")).to eq(true)
|
122
|
+
expect(ar.include?("Funder")).to eq(true)
|
123
|
+
expect(ar.include?("Host")).to eq(true)
|
124
|
+
|
125
|
+
expect(@obj.datastreams["descMetadata"].term_values(:name,:role,:text)).to eq(["Creator","Contributor","Funder","Host"])
|
126
|
+
expect(@obj.datastreams["descMetadata"].term_values({:name=>0},:role,:text)).to eq(["Creator"])
|
127
|
+
expect(@obj.datastreams["descMetadata"].term_values({:name=>1},:role,:text)).to eq(["Contributor"])
|
128
|
+
expect(@obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text)).to eq(["Creator"])
|
129
|
+
expect(@obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>0},:text)).to eq(["Contributor"])
|
130
|
+
expect(@obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>1},:text)).to eq([])
|
131
131
|
ar = @obj.datastreams["descMetadata"].term_values(:name,{:role=>0},:text)
|
132
|
-
ar.length.
|
133
|
-
ar.include?("Creator").
|
134
|
-
ar.include?("Contributor").
|
135
|
-
ar.include?("Funder").
|
136
|
-
ar.include?("Host").
|
132
|
+
expect(ar.length).to eq(4)
|
133
|
+
expect(ar.include?("Creator")).to eq(true)
|
134
|
+
expect(ar.include?("Contributor")).to eq(true)
|
135
|
+
expect(ar.include?("Funder")).to eq(true)
|
136
|
+
expect(ar.include?("Host")).to eq(true)
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -146,10 +146,10 @@ describe ActiveFedora::OmDatastream do
|
|
146
146
|
|
147
147
|
it "should not be dirty after .update_values is saved" do
|
148
148
|
@obj.datastreams["descMetadata"].update_values([{:name=>0},{:role=>0},:text] =>"Funder")
|
149
|
-
@obj.datastreams["descMetadata"].
|
149
|
+
expect(@obj.datastreams["descMetadata"]).to be_changed
|
150
150
|
@obj.save
|
151
|
-
@obj.datastreams["descMetadata"].
|
152
|
-
@obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).
|
151
|
+
expect(@obj.datastreams["descMetadata"]).not_to be_changed
|
152
|
+
expect(@obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text)).to eq(["Funder"])
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
@@ -161,7 +161,7 @@ describe ActiveFedora::OmDatastream do
|
|
161
161
|
@obj.reload
|
162
162
|
end
|
163
163
|
it "should solrize terms with :type=>'date' to *_dt solr terms" do
|
164
|
-
@obj.to_solr[ActiveFedora::SolrService.solr_name('desc_metadata__journal_issue_publication_date', type: :date)].
|
164
|
+
expect(@obj.to_solr[ActiveFedora::SolrService.solr_name('desc_metadata__journal_issue_publication_date', type: :date)]).to eq(['2012-11-02T00:00:00Z'])
|
165
165
|
end
|
166
166
|
end
|
167
167
|
end
|