active-fedora 3.2.0.pre1 → 3.2.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/History.txt +3 -1
- data/lib/active_fedora.rb +3 -3
- data/lib/active_fedora/associations.rb +0 -2
- data/lib/active_fedora/associations/association_collection.rb +15 -1
- data/lib/active_fedora/associations/belongs_to_association.rb +5 -1
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +5 -1
- data/lib/active_fedora/base.rb +36 -92
- data/lib/active_fedora/datastream.rb +1 -2
- data/lib/active_fedora/file_management.rb +73 -0
- data/lib/active_fedora/metadata_datastream_helper.rb +3 -1
- data/lib/active_fedora/model.rb +6 -18
- data/lib/active_fedora/relationships.rb +634 -0
- data/lib/active_fedora/samples/special_thing.rb +4 -4
- data/lib/active_fedora/semantic_node.rb +97 -236
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/base_file_management_spec.rb +1 -0
- data/spec/integration/base_spec.rb +114 -68
- data/spec/integration/full_featured_model_spec.rb +0 -1
- data/spec/integration/mods_article_integration_spec.rb +0 -1
- data/spec/integration/nokogiri_datastream_spec.rb +0 -1
- data/spec/integration/rels_ext_datastream_spec.rb +10 -7
- data/spec/integration/semantic_node_spec.rb +10 -16
- data/spec/samples/models/hydrangea_article.rb +1 -2
- data/spec/samples/oral_history_sample_model.rb +1 -1
- data/spec/unit/base_spec.rb +26 -16
- data/spec/unit/metadata_datastream_spec.rb +1 -0
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -0
- data/spec/unit/relationship_spec.rb +1 -0
- data/spec/unit/relationships_spec.rb +846 -0
- data/spec/unit/semantic_node_spec.rb +2 -338
- metadata +8 -7
- data/lib/active_fedora/relationships_helper.rb +0 -881
- data/spec/unit/relationships_helper_spec.rb +0 -800
@@ -1,800 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'active_fedora'
|
4
|
-
require 'xmlsimple'
|
5
|
-
|
6
|
-
@@last_pid = 0
|
7
|
-
|
8
|
-
class SpecNamedNode
|
9
|
-
include ActiveFedora::SemanticNode
|
10
|
-
include ActiveFedora::RelationshipsHelper
|
11
|
-
|
12
|
-
attr_accessor :pid
|
13
|
-
def internal_uri
|
14
|
-
'info:fedora/' + pid.to_s
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe ActiveFedora::RelationshipsHelper do
|
19
|
-
|
20
|
-
def increment_pid
|
21
|
-
@@last_pid += 1
|
22
|
-
end
|
23
|
-
|
24
|
-
before(:each) do
|
25
|
-
@test_object = SpecNamedNode.new
|
26
|
-
@test_object.pid = increment_pid
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '#relationship_predicates' do
|
30
|
-
class MockNamedRelationshipPredicates < SpecNamedNode
|
31
|
-
register_relationship_desc(:self, "testing", :has_part, :type=>SpecNamedNode)
|
32
|
-
create_relationship_name_methods("testing")
|
33
|
-
register_relationship_desc(:self, "testing2", :has_member, :type=>SpecNamedNode)
|
34
|
-
create_relationship_name_methods("testing2")
|
35
|
-
register_relationship_desc(:inbound, "testing_inbound", :has_part, :type=>SpecNamedNode)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should provide #relationship_predicates' do
|
39
|
-
@test_object.should respond_to(:relationship_predicates)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should return a map of subject to relationship name to fedora ontology relationship predicate' do
|
43
|
-
@test_object2 = MockNamedRelationshipPredicates.new
|
44
|
-
@test_object2.relationship_predicates.should == {:self=>{"testing"=>:has_part,"testing2"=>:has_member},
|
45
|
-
:inbound=>{"testing_inbound"=>:has_part}}
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '#conforms_to?' do
|
51
|
-
it 'should provide #conforms_to?' do
|
52
|
-
@test_object.should respond_to(:conforms_to?)
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'should check if current object is the kind of model class supplied' do
|
56
|
-
#has_model relationship does not get created until save called
|
57
|
-
graph = RDF::Graph.new
|
58
|
-
subject = RDF::URI.new "info:fedora/test:sample_pid"
|
59
|
-
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new(ActiveFedora::ContentModel.pid_from_ruby_class(SpecNamedNode)))
|
60
|
-
@test_object.expects(:relationships).returns(graph).at_least_once
|
61
|
-
@test_object.conforms_to?(SpecNamedNode).should == true
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe '#assert_conforms_to' do
|
66
|
-
it 'should provide #assert_conforms_to' do
|
67
|
-
@test_object.should respond_to(:assert_conforms_to)
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'should correctly assert if an object is the type of model supplied' do
|
71
|
-
@test_object3 = SpecNamedNode.new
|
72
|
-
@test_object3.pid = increment_pid
|
73
|
-
#has_model relationship does not get created until save called so need to add the has model rel here, is fine since not testing save
|
74
|
-
graph = RDF::Graph.new
|
75
|
-
subject = RDF::URI.new "info:fedora/test:sample_pid"
|
76
|
-
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new(ActiveFedora::ContentModel.pid_from_ruby_class(SpecNamedNode)))
|
77
|
-
@test_object.expects(:relationships).returns(graph).at_least_once
|
78
|
-
@test_object3.assert_conforms_to('object',@test_object,SpecNamedNode)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'should provide #class_from_name' do
|
83
|
-
@test_object.should respond_to(:class_from_name)
|
84
|
-
end
|
85
|
-
|
86
|
-
describe '#class_from_name' do
|
87
|
-
it 'should return a class constant for a string passed in' do
|
88
|
-
@test_object.class_from_name("SpecNamedNode").should == SpecNamedNode
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe '#relationships_by_name' do
|
93
|
-
|
94
|
-
class MockNamedRelationships3 < SpecNamedNode
|
95
|
-
register_relationship_desc(:self, "testing", :has_part, :type=>SpecNamedNode)
|
96
|
-
create_relationship_name_methods("testing")
|
97
|
-
register_relationship_desc(:self, "testing2", :has_member, :type=>SpecNamedNode)
|
98
|
-
create_relationship_name_methods("testing2")
|
99
|
-
register_relationship_desc(:inbound, "testing_inbound", :has_part, :type=>SpecNamedNode)
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'should provide #relationships_by_name' do
|
103
|
-
@test_object.should respond_to(:relationships_by_name)
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'should return current named relationships' do
|
107
|
-
@test_object2 = MockNamedRelationships3.new
|
108
|
-
@test_object2.pid = increment_pid
|
109
|
-
@test_object3 = MockNamedRelationships3.new
|
110
|
-
@test_object3.pid = increment_pid
|
111
|
-
model_pid = ActiveFedora::ContentModel.pid_from_ruby_class(MockNamedRelationships3)
|
112
|
-
graph = RDF::Graph.new
|
113
|
-
subject = RDF::URI.new "info:fedora/test:sample_pid"
|
114
|
-
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new(model_pid))
|
115
|
-
@test_object2.expects(:relationships).returns(graph).at_least_once
|
116
|
-
#should return expected named relationships
|
117
|
-
@test_object2.relationships_by_name.should == {:self=>{"testing"=>[],"testing2"=>[]}}
|
118
|
-
graph = RDF::Graph.new
|
119
|
-
subject = RDF::URI.new "info:fedora/test:sample_pid"
|
120
|
-
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new(model_pid))
|
121
|
-
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_part), RDF::URI.new(@test_object.internal_uri))
|
122
|
-
@test_object3.expects(:relationships).returns(graph).at_least_once
|
123
|
-
@test_object3.relationships_by_name.should == {:self=>{"testing"=>[@test_object.internal_uri],"testing2"=>[]}}
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'should provide #relationship_names' do
|
128
|
-
@test_object.should respond_to(:relationship_names)
|
129
|
-
end
|
130
|
-
|
131
|
-
describe '#relationship_names' do
|
132
|
-
class MockRelationshipNames < SpecNamedNode
|
133
|
-
register_relationship_desc(:self, "testing", :has_part, :type=>SpecNamedNode)
|
134
|
-
create_relationship_name_methods("testing")
|
135
|
-
register_relationship_desc(:self, "testing2", :has_member, :type=>SpecNamedNode)
|
136
|
-
create_relationship_name_methods("testing2")
|
137
|
-
register_relationship_desc(:inbound, "testing_inbound", :has_part, :type=>SpecNamedNode)
|
138
|
-
register_relationship_desc(:inbound, "testing_inbound2", :has_member, :type=>SpecNamedNode)
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'should return an array of relationship names for this model' do
|
142
|
-
@test_object2 = MockRelationshipNames.new
|
143
|
-
@test_object2.pid = increment_pid
|
144
|
-
@test_object2.relationship_names.include?("testing").should == true
|
145
|
-
@test_object2.relationship_names.include?("testing2").should == true
|
146
|
-
@test_object2.relationship_names.include?("testing_inbound").should == true
|
147
|
-
@test_object2.relationship_names.include?("testing_inbound2").should == true
|
148
|
-
@test_object2.relationship_names.size.should == 4
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
it 'should provide #inbound_relationship_names' do
|
153
|
-
@test_object.should respond_to(:inbound_relationship_names)
|
154
|
-
end
|
155
|
-
|
156
|
-
describe '#inbound_relationship_names' do
|
157
|
-
it 'should return an array of inbound relationship names for this model' do
|
158
|
-
@test_object2 = MockRelationshipNames.new
|
159
|
-
@test_object2.pid = increment_pid
|
160
|
-
@test_object2.inbound_relationship_names.include?("testing_inbound").should == true
|
161
|
-
@test_object2.inbound_relationship_names.include?("testing_inbound2").should == true
|
162
|
-
@test_object2.inbound_relationship_names.size.should == 2
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
it 'should provide #outbound_relationship_names' do
|
167
|
-
@test_object.should respond_to(:outbound_relationship_names)
|
168
|
-
end
|
169
|
-
|
170
|
-
describe '#outbound_relationship_names' do
|
171
|
-
it 'should return an array of outbound relationship names for this model' do
|
172
|
-
@test_object2 = MockRelationshipNames.new
|
173
|
-
@test_object2.pid = increment_pid
|
174
|
-
@test_object2.outbound_relationship_names.include?("testing").should == true
|
175
|
-
@test_object2.outbound_relationship_names.include?("testing2").should == true
|
176
|
-
@test_object2.outbound_relationship_names.size.should == 2
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
it 'should provide #outbound_relationships_by_name' do
|
181
|
-
@test_object.should respond_to(:outbound_relationships_by_name)
|
182
|
-
end
|
183
|
-
|
184
|
-
describe '#outbound_relationships_by_name' do
|
185
|
-
it 'should return hash of outbound relationship names to arrays of object uri' do
|
186
|
-
@test_object2 = MockRelationshipNames.new
|
187
|
-
@test_object2.pid = increment_pid
|
188
|
-
graph = RDF::Graph.new
|
189
|
-
subject = RDF::URI.new "info:fedora/test:sample_pid"
|
190
|
-
@test_object2.expects(:relationships).returns(graph).at_least_once
|
191
|
-
@test_object2.outbound_relationships_by_name.should == {"testing"=>[],
|
192
|
-
"testing2"=>[]}
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
it 'should provide #inbound_relationships_by_name' do
|
197
|
-
#testing execution of this in integration since touches solr
|
198
|
-
@test_object.should respond_to(:inbound_relationships_by_name)
|
199
|
-
end
|
200
|
-
|
201
|
-
it 'should provide #find_relationship_by_name' do
|
202
|
-
@test_object.should respond_to(:find_relationship_by_name)
|
203
|
-
end
|
204
|
-
|
205
|
-
describe '#find_relationship_by_name' do
|
206
|
-
it 'should return an array of object uri for a given relationship name' do
|
207
|
-
@test_object2 = MockRelationshipNames.new
|
208
|
-
@test_object2.pid = increment_pid
|
209
|
-
@test_object3 = SpecNamedNode.new
|
210
|
-
@test_object3.pid = increment_pid
|
211
|
-
@test_object4 = SpecNamedNode.new
|
212
|
-
@test_object4.pid = increment_pid
|
213
|
-
#add relationships that mirror 'testing' and 'testing2'
|
214
|
-
graph = RDF::Graph.new
|
215
|
-
subject = RDF::URI.new "info:fedora/test:sample_pid"
|
216
|
-
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new(ActiveFedora::ContentModel.pid_from_ruby_class(MockRelationshipNames)))
|
217
|
-
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_member), RDF::URI.new(@test_object4.internal_uri))
|
218
|
-
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_part), RDF::URI.new(@test_object3.internal_uri))
|
219
|
-
@test_object2.expects(:relationships).returns(graph).at_least_once
|
220
|
-
@test_object2.find_relationship_by_name("testing").should == [@test_object3.internal_uri]
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
describe "relationship_query" do
|
225
|
-
class MockNamedRelationshipQuery < SpecNamedNode
|
226
|
-
register_relationship_desc(:inbound, "testing_inbound_query", :is_part_of, :type=>SpecNamedNode, :solr_fq=>"has_model_s:info\\:fedora/SpecialPart")
|
227
|
-
register_relationship_desc(:inbound, "testing_inbound_no_solr_fq", :is_part_of, :type=>SpecNamedNode)
|
228
|
-
register_relationship_desc(:self, "testing_outbound_query", :is_part_of, :type=>SpecNamedNode, :solr_fq=>"has_model_s:info\\:fedora/SpecialPart")
|
229
|
-
register_relationship_desc(:self, "testing_outbound_no_solr_fq", :is_part_of, :type=>SpecNamedNode)
|
230
|
-
#for bidirectional relationship testing need to register both outbound and inbound names
|
231
|
-
register_relationship_desc(:self, "testing_bi_query_outbound", :has_part, :type=>SpecNamedNode, :solr_fq=>"has_model_s:info\\:fedora/SpecialPart")
|
232
|
-
register_relationship_desc(:inbound, "testing_bi_query_inbound", :is_part_of, :type=>SpecNamedNode, :solr_fq=>"has_model_s:info\\:fedora/SpecialPart")
|
233
|
-
register_relationship_desc(:self, "testing_bi_no_solr_fq_outbound", :has_part, :type=>SpecNamedNode)
|
234
|
-
register_relationship_desc(:inbound, "testing_bi_no_solr_fq_inbound", :is_part_of, :type=>SpecNamedNode)
|
235
|
-
end
|
236
|
-
|
237
|
-
before(:each) do
|
238
|
-
@mockrelsquery = MockNamedRelationshipQuery.new
|
239
|
-
end
|
240
|
-
|
241
|
-
it "should call bidirectional_relationship_query if a bidirectional relationship" do
|
242
|
-
ids = ["changeme:1","changeme:2","changeme:3","changeme:4"]
|
243
|
-
@mockrelsquery.expects(:ids_for_outbound).with(:has_part).returns(ids).at_least_once
|
244
|
-
@mockrelsquery.expects(:pid).returns("changeme:5")
|
245
|
-
MockNamedRelationshipQuery.expects(:bidirectional_relationship_query).with("changeme:5","testing_bi_query",ids)
|
246
|
-
@mockrelsquery.relationship_query("testing_bi_query")
|
247
|
-
end
|
248
|
-
|
249
|
-
it "should call outbound_relationship_query if an outbound relationship" do
|
250
|
-
ids = ["changeme:1","changeme:2","changeme:3","changeme:4"]
|
251
|
-
@mockrelsquery.expects(:ids_for_outbound).with(:is_part_of).returns(ids).at_least_once
|
252
|
-
MockNamedRelationshipQuery.expects(:outbound_relationship_query).with("testing_outbound_no_solr_fq",ids)
|
253
|
-
@mockrelsquery.relationship_query("testing_outbound_no_solr_fq")
|
254
|
-
end
|
255
|
-
|
256
|
-
it "should call inbound_relationship_query if an inbound relationship" do
|
257
|
-
@mockrelsquery.expects(:pid).returns("changeme:5")
|
258
|
-
MockNamedRelationshipQuery.expects(:inbound_relationship_query).with("changeme:5","testing_inbound_query")
|
259
|
-
@mockrelsquery.relationship_query("testing_inbound_query")
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
describe ActiveFedora::RelationshipsHelper::ClassMethods do
|
264
|
-
|
265
|
-
after(:each) do
|
266
|
-
begin
|
267
|
-
@test_object2.delete
|
268
|
-
rescue
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
describe '#relationships_desc' do
|
273
|
-
it 'should initialize relationships_desc to a new hash containing self' do
|
274
|
-
@test_object2 = SpecNamedNode.new
|
275
|
-
@test_object2.pid = increment_pid
|
276
|
-
@test_object2.relationships_desc.should == {:self=>{}}
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
describe '#register_relationship_desc_subject' do
|
281
|
-
|
282
|
-
class MockRegisterNamedSubject < SpecNamedNode
|
283
|
-
register_relationship_desc_subject :test
|
284
|
-
end
|
285
|
-
|
286
|
-
it 'should add a new named subject to the named relationships only if it does not already exist' do
|
287
|
-
@test_object2 = MockRegisterNamedSubject.new
|
288
|
-
@test_object2.pid = increment_pid
|
289
|
-
@test_object2.relationships_desc.should == {:self=>{}, :test=>{}}
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
describe '#register_relationship_desc' do
|
294
|
-
|
295
|
-
class MockRegisterNamedRelationship < SpecNamedNode
|
296
|
-
register_relationship_desc :self, "testing", :is_part_of, :type=>SpecNamedNode
|
297
|
-
register_relationship_desc :inbound, "testing2", :has_part, :type=>SpecNamedNode
|
298
|
-
end
|
299
|
-
|
300
|
-
it 'should add a new named subject to the named relationships only if it does not already exist' do
|
301
|
-
@test_object2 = MockRegisterNamedRelationship.new
|
302
|
-
@test_object2.pid = increment_pid
|
303
|
-
@test_object2.relationships_desc.should == {:inbound=>{"testing2"=>{:type=>SpecNamedNode, :predicate=>:has_part}}, :self=>{"testing"=>{:type=>SpecNamedNode, :predicate=>:is_part_of}}}
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
describe "#is_bidirectional_relationship?" do
|
308
|
-
|
309
|
-
class MockIsBiRegisterNamedRelationship < SpecNamedNode
|
310
|
-
register_relationship_desc(:self, "testing_outbound", :is_part_of, :type=>SpecNamedNode)
|
311
|
-
register_relationship_desc(:inbound, "testing_inbound", :has_part, :type=>SpecNamedNode)
|
312
|
-
register_relationship_desc(:self, "testing2", :is_member_of,{})
|
313
|
-
end
|
314
|
-
|
315
|
-
it "should return true if both inbound and outbound predicates exist, otherwise false" do
|
316
|
-
MockIsBiRegisterNamedRelationship.is_bidirectional_relationship?("testing").should == true
|
317
|
-
MockIsBiRegisterNamedRelationship.is_bidirectional_relationship?("testing2").should == false
|
318
|
-
#the inbound and outbound internal relationships will not be bidirectional by themselves
|
319
|
-
MockIsBiRegisterNamedRelationship.is_bidirectional_relationship?("testing_inbound").should == false
|
320
|
-
MockIsBiRegisterNamedRelationship.is_bidirectional_relationship?("testing_outbound").should == false
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
describe '#relationship_has_solr_filter_query' do
|
325
|
-
class RelsHasSolrFilter < SpecNamedNode
|
326
|
-
register_relationship_desc :self, "testing", :is_part_of, :solr_fq=>"testing:value"
|
327
|
-
register_relationship_desc :self, "no_query_testing", :is_part_of
|
328
|
-
register_relationship_desc :inbound, "inbound_testing", :has_part, :solr_fq=>"in_testing:value_in"
|
329
|
-
register_relationship_desc :inbound, "inbound_testing_no_query", :has_part
|
330
|
-
end
|
331
|
-
|
332
|
-
it 'should return true if an object has an inbound relationship with solr filter query' do
|
333
|
-
RelsHasSolrFilter.relationship_has_solr_filter_query?(:inbound,"inbound_testing").should == true
|
334
|
-
end
|
335
|
-
|
336
|
-
it 'should return false if an object does not have inbound relationship with solr filter query' do
|
337
|
-
RelsHasSolrFilter.relationship_has_solr_filter_query?(:inbound,"inbound_testing_no_query").should == false
|
338
|
-
end
|
339
|
-
|
340
|
-
it 'should return true if an object has an outbound relationship with solr filter query' do
|
341
|
-
RelsHasSolrFilter.relationship_has_solr_filter_query?(:self,"testing").should == true
|
342
|
-
end
|
343
|
-
|
344
|
-
it 'should return false if an object does not have outbound relationship with solr filter query' do
|
345
|
-
RelsHasSolrFilter.relationship_has_solr_filter_query?(:self,"testing_no_query").should == false
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
describe '#create_relationship_name_methods' do
|
350
|
-
class MockCreateNamedRelationshipMethods < SpecNamedNode
|
351
|
-
register_relationship_desc :self, "testing", :is_part_of, :type=>SpecNamedNode
|
352
|
-
create_relationship_name_methods "testing"
|
353
|
-
end
|
354
|
-
|
355
|
-
it 'should create an append and remove method for each outbound relationship' do
|
356
|
-
@test_object2 = MockCreateNamedRelationshipMethods.new
|
357
|
-
@test_object2.pid = increment_pid
|
358
|
-
@test_object2.should respond_to(:testing_append)
|
359
|
-
@test_object2.should respond_to(:testing_remove)
|
360
|
-
#test execution in base_spec since method definitions include methods in ActiveFedora::Base
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
|
-
describe '#create_bidirectional_relationship_name_methods' do
|
365
|
-
class MockCreateNamedRelationshipMethods < SpecNamedNode
|
366
|
-
register_relationship_desc(:self, "testing_outbound", :is_part_of, :type=>SpecNamedNode)
|
367
|
-
create_bidirectional_relationship_name_methods "testing", "testing_outbound"
|
368
|
-
end
|
369
|
-
|
370
|
-
it 'should create an append and remove method for each outbound relationship' do
|
371
|
-
@test_object2 = MockCreateNamedRelationshipMethods.new
|
372
|
-
@test_object2.pid = increment_pid
|
373
|
-
@test_object2.should respond_to(:testing_append)
|
374
|
-
@test_object2.should respond_to(:testing_remove)
|
375
|
-
#test execution in base_spec since method definitions include methods in ActiveFedora::Base
|
376
|
-
end
|
377
|
-
end
|
378
|
-
|
379
|
-
describe '#def predicate_exists_with_different_relationship_name?' do
|
380
|
-
|
381
|
-
it 'should return true if a predicate exists for same subject and different name but not different subject' do
|
382
|
-
class MockPredicateExists < SpecNamedNode
|
383
|
-
register_relationship_desc :self, "testing", :has_part, :type=>SpecNamedNode
|
384
|
-
register_relationship_desc :self, "testing2", :has_member, :type=>SpecNamedNode
|
385
|
-
register_relationship_desc :inbound, "testing_inbound", :is_part_of, :type=>SpecNamedNode
|
386
|
-
|
387
|
-
predicate_exists_with_different_relationship_name?(:self,"testing",:has_part).should == false
|
388
|
-
predicate_exists_with_different_relationship_name?(:self,"testing3",:has_part).should == true
|
389
|
-
predicate_exists_with_different_relationship_name?(:inbound,"testing",:has_part).should == false
|
390
|
-
predicate_exists_with_different_relationship_name?(:self,"testing2",:has_member).should == false
|
391
|
-
predicate_exists_with_different_relationship_name?(:self,"testing3",:has_member).should == true
|
392
|
-
predicate_exists_with_different_relationship_name?(:inbound,"testing2",:has_member).should == false
|
393
|
-
predicate_exists_with_different_relationship_name?(:self,"testing_inbound",:is_part_of).should == false
|
394
|
-
predicate_exists_with_different_relationship_name?(:inbound,"testing_inbound",:is_part_of).should == false
|
395
|
-
predicate_exists_with_different_relationship_name?(:inbound,"testing_inbound2",:is_part_of).should == true
|
396
|
-
end
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
|
-
#
|
401
|
-
# HYDRA-541
|
402
|
-
#
|
403
|
-
|
404
|
-
describe "bidirectional_relationship_query" do
|
405
|
-
class MockBiNamedRelationshipQuery < SpecNamedNode
|
406
|
-
register_relationship_desc(:self, "testing_query_outbound", :has_part, :type=>SpecNamedNode, :solr_fq=>"has_model_s:info\\:fedora/SpecialPart")
|
407
|
-
register_relationship_desc(:inbound, "testing_query_inbound", :is_part_of, :type=>SpecNamedNode, :solr_fq=>"has_model_s:info\\:fedora/SpecialPart")
|
408
|
-
create_bidirectional_relationship_name_methods("testing","testing_outbound")
|
409
|
-
register_relationship_desc(:self, "testing_no_solr_fq_outbound", :has_part, :type=>SpecNamedNode)
|
410
|
-
register_relationship_desc(:inbound, "testing_no_solr_fq_inbound", :is_part_of, :type=>SpecNamedNode)
|
411
|
-
create_bidirectional_relationship_name_methods("testing_no_solr_fq","testing_no_solr_fq_outbound")
|
412
|
-
end
|
413
|
-
|
414
|
-
#
|
415
|
-
# HYDRA-541
|
416
|
-
#
|
417
|
-
it "should rely on outbound query if inbound query is empty" do
|
418
|
-
query = MockBiNamedRelationshipQuery.bidirectional_relationship_query("PID",:testing_query,[])
|
419
|
-
query.should_not include("OR ()")
|
420
|
-
query2 = MockBiNamedRelationshipQuery.bidirectional_relationship_query("PID",:testing_no_solr_fq,[])
|
421
|
-
query2.should_not include("OR ()")
|
422
|
-
end
|
423
|
-
|
424
|
-
it "should return a properly formatted query for a relationship that has a solr filter query defined" do
|
425
|
-
expected_string = ""
|
426
|
-
ids = ["changeme:1","changeme:2","changeme:3","changeme:4","changeme:5"]
|
427
|
-
ids.each_with_index do |id,index|
|
428
|
-
expected_string << " OR " if index > 0
|
429
|
-
expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND has_model_s:info\\:fedora/SpecialPart)"
|
430
|
-
end
|
431
|
-
expected_string << " OR "
|
432
|
-
expected_string << "(is_part_of_s:info\\:fedora/changeme\\:6 AND has_model_s:info\\:fedora/SpecialPart)"
|
433
|
-
MockBiNamedRelationshipQuery.bidirectional_relationship_query("changeme:6","testing_query",ids).should == expected_string
|
434
|
-
end
|
435
|
-
|
436
|
-
it "should return a properly formatted query for a relationship that does not have a solr filter query defined" do
|
437
|
-
expected_string = ""
|
438
|
-
ids = ["changeme:1","changeme:2","changeme:3","changeme:4","changeme:5"]
|
439
|
-
ids.each_with_index do |id,index|
|
440
|
-
expected_string << " OR " if index > 0
|
441
|
-
expected_string << "id:" + id.gsub(/(:)/, '\\:')
|
442
|
-
end
|
443
|
-
expected_string << " OR "
|
444
|
-
expected_string << "(is_part_of_s:info\\:fedora/changeme\\:6)"
|
445
|
-
MockBiNamedRelationshipQuery.bidirectional_relationship_query("changeme:6","testing_no_solr_fq",ids).should == expected_string
|
446
|
-
end
|
447
|
-
end
|
448
|
-
|
449
|
-
describe "inbound_relationship_query" do
|
450
|
-
class MockInboundNamedRelationshipQuery < SpecNamedNode
|
451
|
-
register_relationship_desc(:inbound, "testing_inbound_query", :is_part_of, :type=>SpecNamedNode, :solr_fq=>"has_model_s:info\\:fedora/SpecialPart")
|
452
|
-
register_relationship_desc(:inbound, "testing_inbound_no_solr_fq", :is_part_of, :type=>SpecNamedNode)
|
453
|
-
end
|
454
|
-
|
455
|
-
it "should return a properly formatted query for a relationship that has a solr filter query defined" do
|
456
|
-
MockInboundNamedRelationshipQuery.inbound_relationship_query("changeme:1","testing_inbound_query").should == "is_part_of_s:info\\:fedora/changeme\\:1 AND has_model_s:info\\:fedora/SpecialPart"
|
457
|
-
end
|
458
|
-
|
459
|
-
it "should return a properly formatted query for a relationship that does not have a solr filter query defined" do
|
460
|
-
MockInboundNamedRelationshipQuery.inbound_relationship_query("changeme:1","testing_inbound_no_solr_fq").should == "is_part_of_s:info\\:fedora/changeme\\:1"
|
461
|
-
end
|
462
|
-
end
|
463
|
-
|
464
|
-
describe "outbound_relationship_query" do
|
465
|
-
class MockOutboundNamedRelationshipQuery < SpecNamedNode
|
466
|
-
register_relationship_desc(:self, "testing_query", :is_part_of, :type=>SpecNamedNode, :solr_fq=>"has_model_s:info\\:fedora/SpecialPart")
|
467
|
-
register_relationship_desc(:self,"testing_no_solr_fq", :is_part_of, :type=>SpecNamedNode)
|
468
|
-
end
|
469
|
-
|
470
|
-
it "should return a properly formatted query for a relationship that has a solr filter query defined" do
|
471
|
-
ids = ["changeme:1","changeme:2","changeme:3","changeme:4"]
|
472
|
-
expected_string = ""
|
473
|
-
ids.each_with_index do |id,index|
|
474
|
-
expected_string << " OR " if index > 0
|
475
|
-
expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND has_model_s:info\\:fedora/SpecialPart)"
|
476
|
-
end
|
477
|
-
MockOutboundNamedRelationshipQuery.outbound_relationship_query("testing_query",ids).should == expected_string
|
478
|
-
end
|
479
|
-
|
480
|
-
it "should return a properly formatted query for a relationship that does not have a solr filter query defined" do
|
481
|
-
expected_string = ""
|
482
|
-
ids = ["changeme:1","changeme:2","changeme:3","changeme:4"]
|
483
|
-
ids.each_with_index do |id,index|
|
484
|
-
expected_string << " OR " if index > 0
|
485
|
-
expected_string << "id:" + id.gsub(/(:)/, '\\:')
|
486
|
-
end
|
487
|
-
MockOutboundNamedRelationshipQuery.outbound_relationship_query("testing_no_solr_fq",ids).should == expected_string
|
488
|
-
end
|
489
|
-
end
|
490
|
-
|
491
|
-
### Deprecated class method checks for HYDRA-541 methods renamed
|
492
|
-
# named_relationships_desc
|
493
|
-
# register_named_subject(subject)
|
494
|
-
# register_named_relationship(subject, name, predicate, opts={})
|
495
|
-
# create_named_relationship_methods(name)
|
496
|
-
# create_bidirectional_named_relationship_methods(name,outbound_name)
|
497
|
-
# outbound_named_relationship_query(relationship_name,outbound_pids)
|
498
|
-
# inbound_named_relationship_query(pid,relationship_name)
|
499
|
-
# bidirectional_named_relationship_query(pid,relationship_name,outbound_pids)
|
500
|
-
# named_predicate_exists_with_different_name?(subject,name,predicate)
|
501
|
-
describe "named_relationships_desc" do
|
502
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
503
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: named_relationships_desc has been deprecated. Please call relationships_desc instead.")
|
504
|
-
@test_object.class.respond_to?(:relationships_desc)
|
505
|
-
obj = mock()
|
506
|
-
@test_object.class.expects(:relationships_desc)
|
507
|
-
@test_object.class.named_relationships_desc
|
508
|
-
end
|
509
|
-
end
|
510
|
-
|
511
|
-
describe "register_named_subject" do
|
512
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
513
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: register_named_subject has been deprecated. Please call register_relationship_desc_subject instead.")
|
514
|
-
@test_object.class.respond_to?(:register_relationship_desc_subject)
|
515
|
-
obj = mock()
|
516
|
-
@test_object.class.expects(:register_relationship_desc_subject).with(:self)
|
517
|
-
@test_object.class.register_named_subject(:self)
|
518
|
-
end
|
519
|
-
end
|
520
|
-
|
521
|
-
describe "register_named_relationship" do
|
522
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
523
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: register_named_relationship has been deprecated. Please call register_relationship_desc instead.")
|
524
|
-
@test_object.class.respond_to?(:register_relationship_desc)
|
525
|
-
obj = mock()
|
526
|
-
@test_object.class.expects(:register_relationship_desc).with(:self,"testing",:has_member,{})
|
527
|
-
@test_object.class.register_named_relationship(:self,"testing",:has_member,{})
|
528
|
-
end
|
529
|
-
end
|
530
|
-
|
531
|
-
describe "create_named_relationship_methods" do
|
532
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
533
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: create_named_relationship_methods has been deprecated. Please call create_relationship_name_methods instead.")
|
534
|
-
@test_object.class.respond_to?(:create_relationship_name_methods)
|
535
|
-
obj = mock()
|
536
|
-
@test_object.class.expects(:create_relationship_name_methods).with("testing")
|
537
|
-
@test_object.class.create_named_relationship_methods("testing")
|
538
|
-
end
|
539
|
-
end
|
540
|
-
|
541
|
-
describe "create_bidirectional_named_relationship_methods" do
|
542
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
543
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: create_bidirectional_named_relationship_methods has been deprecated. Please call create_bidirectional_relationship_name_methods instead.")
|
544
|
-
@test_object.class.respond_to?(:create_bidirectional_relationship_name_methods)
|
545
|
-
obj = mock()
|
546
|
-
@test_object.class.expects(:create_bidirectional_relationship_name_methods).with("testing","testing_outbound")
|
547
|
-
@test_object.class.create_bidirectional_named_relationship_methods("testing","testing_outbound")
|
548
|
-
end
|
549
|
-
end
|
550
|
-
|
551
|
-
describe "outbound_named_relationship_query" do
|
552
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
553
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: outbound_named_relationship_query has been deprecated. Please call outbound_relationship_query instead.")
|
554
|
-
@test_object.class.respond_to?(:outbound_relationship_query)
|
555
|
-
obj = mock()
|
556
|
-
@test_object.class.expects(:outbound_relationship_query).with("testing",["testid"])
|
557
|
-
@test_object.class.outbound_named_relationship_query("testing",["testid"])
|
558
|
-
end
|
559
|
-
end
|
560
|
-
|
561
|
-
describe "inbound_named_relationship_query" do
|
562
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
563
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: inbound_named_relationship_query has been deprecated. Please call inbound_relationship_query instead.")
|
564
|
-
@test_object.class.respond_to?(:inbound_relationship_query)
|
565
|
-
obj = mock()
|
566
|
-
@test_object.class.expects(:inbound_relationship_query).with("testid","testing")
|
567
|
-
@test_object.class.inbound_named_relationship_query("testid","testing")
|
568
|
-
end
|
569
|
-
end
|
570
|
-
|
571
|
-
describe "bidirectional_named_relationship_query" do
|
572
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
573
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: bidirectional_named_relationship_query has been deprecated. Please call bidirectional_relationship_query instead.")
|
574
|
-
@test_object.class.respond_to?(:bidirectional_relationship_query)
|
575
|
-
obj = mock()
|
576
|
-
@test_object.class.expects(:bidirectional_relationship_query).with("testid","testing",["testid2"])
|
577
|
-
@test_object.class.bidirectional_named_relationship_query("testid","testing",["testid2"])
|
578
|
-
end
|
579
|
-
end
|
580
|
-
|
581
|
-
describe "named_predicate_exists_with_different_name?" do
|
582
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
583
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: named_predicate_exists_with_different_name? has been deprecated. Please call predicate_exists_with_different_relationship_name? instead.")
|
584
|
-
@test_object.class.respond_to?(:predicate_exists_with_different_relationship_name?)
|
585
|
-
obj = mock()
|
586
|
-
@test_object.class.expects(:predicate_exists_with_different_relationship_name?).with(:subject,"testing",:has_member)
|
587
|
-
@test_object.class.named_predicate_exists_with_different_name?(:subject,"testing",:has_member)
|
588
|
-
end
|
589
|
-
end
|
590
|
-
end
|
591
|
-
|
592
|
-
## Deprecated method checks for HYDRA-541 methods renamed
|
593
|
-
#
|
594
|
-
# Old Name New Name
|
595
|
-
# named_relationship find_relationship_by_name
|
596
|
-
# register_named_subject register_relationship_desc_subject
|
597
|
-
# register_named_relationship register_relationship_desc
|
598
|
-
# named_relationships relationships_by_name
|
599
|
-
# named_relationships_from_class relationships_by_name_from_class
|
600
|
-
# named_inbound_relationships inbound_relationship_names
|
601
|
-
# outbound_named_relationship_predicates outbound_relationship_predicates
|
602
|
-
# inbound_named_relationship_predicates inbound_relationship_predicates
|
603
|
-
# named_relationship_predicates relationship_predicates
|
604
|
-
# named_relationship_predicates_from_class relationship_predicates_from_class
|
605
|
-
# named_outbound_relationships outbound_relationships_by_name
|
606
|
-
# is_named_relationship? is_relationship_name?
|
607
|
-
# named_relationships_desc relationships_desc
|
608
|
-
# named_relationships_desc_from_class relationships_desc_from_class
|
609
|
-
# named_relationship_type relationship_model_type
|
610
|
-
# add_named_relationship add_relationship_by_name
|
611
|
-
# remove_named_relationship remove_relationship_by_name
|
612
|
-
# assert_kind_of_model assert_conforms_to
|
613
|
-
# kind_of_model? conforms_to?
|
614
|
-
# named_relationship_query relationship_query
|
615
|
-
|
616
|
-
describe "named_relationship" do
|
617
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
618
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: named_relationship has been deprecated. Please call find_relationship_by_name instead.")
|
619
|
-
@test_object.respond_to?(:find_relationship_by_name).should == true
|
620
|
-
@test_object.expects(:find_relationship_by_name).with("testing")
|
621
|
-
@test_object.named_relationship("testing")
|
622
|
-
end
|
623
|
-
end
|
624
|
-
|
625
|
-
describe "register_named_subject" do
|
626
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
627
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: register_named_subject has been deprecated. Please call register_relationship_desc_subject instead.")
|
628
|
-
@test_object.respond_to?(:register_relationship_desc_subject).should == true
|
629
|
-
@test_object.expects(:register_relationship_desc_subject).with(:self)
|
630
|
-
@test_object.register_named_subject(:self)
|
631
|
-
end
|
632
|
-
end
|
633
|
-
|
634
|
-
describe "register_named_relationship" do
|
635
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
636
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: register_named_relationship has been deprecated. Please call register_relationship_desc instead.")
|
637
|
-
@test_object.respond_to?(:register_relationship_desc).should == true
|
638
|
-
@test_object.expects(:register_relationship_desc).with(:self,"testing",:has_member,{})
|
639
|
-
@test_object.register_named_relationship(:self,"testing",:has_member,{})
|
640
|
-
end
|
641
|
-
end
|
642
|
-
|
643
|
-
describe "named_relationships" do
|
644
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
645
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: named_relationships has been deprecated. Please call relationships_by_name instead.")
|
646
|
-
@test_object.respond_to?(:relationships_by_name).should == true
|
647
|
-
@test_object.expects(:relationships_by_name)
|
648
|
-
@test_object.named_relationships
|
649
|
-
end
|
650
|
-
end
|
651
|
-
|
652
|
-
describe "named_relationships_from_class" do
|
653
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
654
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: named_relationships_from_class has been deprecated. Please call relationships_by_name_from_class instead.")
|
655
|
-
@test_object.respond_to?(:relationships_by_name_from_class).should == true
|
656
|
-
@test_object.expects(:relationships_by_name_from_class)
|
657
|
-
@test_object.named_relationships_from_class
|
658
|
-
end
|
659
|
-
end
|
660
|
-
|
661
|
-
describe "named_inbound_relationships" do
|
662
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
663
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: named_inbound_relationships has been deprecated. Please call inbound_relationships_by_name instead.")
|
664
|
-
@test_object.respond_to?(:inbound_relationships_by_name).should == true
|
665
|
-
@test_object.expects(:inbound_relationships_by_name)
|
666
|
-
@test_object.named_inbound_relationships
|
667
|
-
end
|
668
|
-
end
|
669
|
-
|
670
|
-
describe "named_outbound_relationships" do
|
671
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
672
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: named_outbound_relationships has been deprecated. Please call outbound_relationships_by_name instead.")
|
673
|
-
@test_object.respond_to?(:outbound_relationships_by_name).should == true
|
674
|
-
@test_object.expects(:outbound_relationships_by_name)
|
675
|
-
@test_object.named_outbound_relationships
|
676
|
-
end
|
677
|
-
end
|
678
|
-
|
679
|
-
describe "outbound_named_relationship_predicates" do
|
680
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
681
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: outbound_named_relationship_predicates has been deprecated. Please call outbound_relationship_predicates instead.")
|
682
|
-
@test_object.respond_to?(:outbound_relationship_predicates).should == true
|
683
|
-
@test_object.expects(:outbound_relationship_predicates)
|
684
|
-
@test_object.outbound_named_relationship_predicates
|
685
|
-
end
|
686
|
-
end
|
687
|
-
|
688
|
-
describe "inbound_named_relationship_predicates" do
|
689
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
690
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: inbound_named_relationship_predicates has been deprecated. Please call inbound_relationship_predicates instead.")
|
691
|
-
@test_object.respond_to?(:inbound_relationship_predicates).should == true
|
692
|
-
@test_object.expects(:inbound_relationship_predicates)
|
693
|
-
@test_object.inbound_named_relationship_predicates
|
694
|
-
end
|
695
|
-
end
|
696
|
-
|
697
|
-
describe "named_relationship_predicates" do
|
698
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
699
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: named_relationship_predicates has been deprecated. Please call relationship_predicates instead.")
|
700
|
-
@test_object.respond_to?(:relationship_predicates).should == true
|
701
|
-
@test_object.expects(:relationship_predicates)
|
702
|
-
@test_object.named_relationship_predicates
|
703
|
-
end
|
704
|
-
end
|
705
|
-
|
706
|
-
describe "named_relationship_predicates_from_class" do
|
707
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
708
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: named_relationship_predicates_from_class has been deprecated. Please call relationship_predicates_from_class instead.")
|
709
|
-
@test_object.respond_to?(:relationship_predicates_from_class).should == true
|
710
|
-
@test_object.expects(:relationship_predicates_from_class)
|
711
|
-
@test_object.named_relationship_predicates_from_class
|
712
|
-
end
|
713
|
-
end
|
714
|
-
|
715
|
-
describe "is_named_relationship?" do
|
716
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
717
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: is_named_relationship? has been deprecated. Please call is_relationship_name? instead.")
|
718
|
-
@test_object.respond_to?(:is_relationship_name?).should == true
|
719
|
-
@test_object.expects(:is_relationship_name?)
|
720
|
-
@test_object.is_named_relationship?("testing",true)
|
721
|
-
end
|
722
|
-
end
|
723
|
-
|
724
|
-
describe "named_relationships_desc" do
|
725
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
726
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: named_relationships_desc has been deprecated. Please call relationships_desc instead.")
|
727
|
-
@test_object.respond_to?(:relationships_desc)
|
728
|
-
@test_object.expects(:relationships_desc)
|
729
|
-
@test_object.named_relationships_desc
|
730
|
-
end
|
731
|
-
end
|
732
|
-
|
733
|
-
describe "named_relationships_desc_from_class" do
|
734
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
735
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: named_relationships_desc_from_class has been deprecated. Please call relationships_desc_from_class instead.")
|
736
|
-
@test_object.respond_to?(:relationships_desc_from_class)
|
737
|
-
@test_object.expects(:relationships_desc_from_class)
|
738
|
-
@test_object.named_relationships_desc_from_class
|
739
|
-
end
|
740
|
-
end
|
741
|
-
|
742
|
-
describe "named_relationship_type" do
|
743
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
744
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: named_relationship_type has been deprecated. Please call relationship_model_type instead.")
|
745
|
-
@test_object.respond_to?(:relationship_model_type)
|
746
|
-
@test_object.expects(:relationship_model_type).with("testing")
|
747
|
-
@test_object.named_relationship_type("testing")
|
748
|
-
end
|
749
|
-
end
|
750
|
-
|
751
|
-
describe "add_named_relationship" do
|
752
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
753
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: add_named_relationship has been deprecated. Please call add_relationship_by_name instead.")
|
754
|
-
@test_object.respond_to?(:add_relationship_by_name)
|
755
|
-
obj = mock()
|
756
|
-
@test_object.expects(:add_relationship_by_name).with("testing",obj)
|
757
|
-
@test_object.add_named_relationship("testing",obj)
|
758
|
-
end
|
759
|
-
end
|
760
|
-
|
761
|
-
describe "remove_named_relationship" do
|
762
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
763
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: remove_named_relationship has been deprecated. Please call remove_relationship_by_name instead.")
|
764
|
-
@test_object.respond_to?(:remove_relationship_by_name)
|
765
|
-
obj = mock()
|
766
|
-
@test_object.expects(:remove_relationship_by_name).with("testing",obj)
|
767
|
-
@test_object.remove_named_relationship("testing",obj)
|
768
|
-
end
|
769
|
-
end
|
770
|
-
|
771
|
-
describe "assert_kind_of_model" do
|
772
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
773
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: assert_kind_of_model has been deprecated. Please call assert_conforms_to instead.")
|
774
|
-
@test_object.respond_to?(:assert_conforms_to)
|
775
|
-
obj = mock()
|
776
|
-
@test_object.expects(:assert_conforms_to).with("testing",obj,ActiveFedora::Base)
|
777
|
-
@test_object.assert_kind_of_model("testing",obj,ActiveFedora::Base)
|
778
|
-
end
|
779
|
-
end
|
780
|
-
|
781
|
-
describe "kind_of_model?" do
|
782
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
783
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: kind_of_model? has been deprecated. Please call conforms_to? instead.")
|
784
|
-
@test_object.respond_to?(:conforms_to?)
|
785
|
-
obj = mock()
|
786
|
-
@test_object.expects(:conforms_to?).with(ActiveFedora::Base)
|
787
|
-
@test_object.kind_of_model?(ActiveFedora::Base)
|
788
|
-
end
|
789
|
-
end
|
790
|
-
|
791
|
-
describe "named_relationship_query" do
|
792
|
-
it 'should throw deprecation warning if old method name called and should call new method name' do
|
793
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: named_relationship_query has been deprecated. Please call relationship_query instead.")
|
794
|
-
@test_object.respond_to?(:relationship_query)
|
795
|
-
obj = mock()
|
796
|
-
@test_object.expects(:relationship_query).with("testing")
|
797
|
-
@test_object.named_relationship_query("testing")
|
798
|
-
end
|
799
|
-
end
|
800
|
-
end
|