active-fedora 13.1.2 → 13.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/.github_changelog_generator +2 -0
  3. data/CHANGELOG.md +3362 -0
  4. data/CONTRIBUTING.md +23 -1
  5. data/README.md +4 -0
  6. data/active-fedora.gemspec +14 -13
  7. data/lib/active_fedora/version.rb +1 -1
  8. metadata +104 -206
  9. data/spec/config_helper.rb +0 -17
  10. data/spec/fixtures/dino.jpg +0 -0
  11. data/spec/fixtures/dino_jpg_no_file_ext +0 -0
  12. data/spec/fixtures/minivan.jpg +0 -0
  13. data/spec/fixtures/rails_root/config/fake_fedora.yml +0 -7
  14. data/spec/fixtures/rails_root/config/fedora.yml +0 -12
  15. data/spec/fixtures/rails_root/config/solr.yml +0 -15
  16. data/spec/fixtures/rails_root/config/solr_mappings.yml +0 -16
  17. data/spec/fixtures/rails_root/config/solr_mappings_af_0.1.yml +0 -9
  18. data/spec/fixtures/rails_root/config/solr_mappings_bl_2.4.yml +0 -17
  19. data/spec/integration/associations/rdf_spec.rb +0 -61
  20. data/spec/integration/associations_spec.rb +0 -680
  21. data/spec/integration/attached_files_spec.rb +0 -146
  22. data/spec/integration/attributes_spec.rb +0 -73
  23. data/spec/integration/autosave_association_spec.rb +0 -24
  24. data/spec/integration/base_spec.rb +0 -184
  25. data/spec/integration/basic_contains_association_spec.rb +0 -121
  26. data/spec/integration/belongs_to_association_spec.rb +0 -260
  27. data/spec/integration/caching_spec.rb +0 -59
  28. data/spec/integration/clean_connection_spec.rb +0 -21
  29. data/spec/integration/collection_association_spec.rb +0 -166
  30. data/spec/integration/date_time_properties_spec.rb +0 -41
  31. data/spec/integration/delete_all_spec.rb +0 -64
  32. data/spec/integration/direct_container_spec.rb +0 -250
  33. data/spec/integration/directly_contains_one_association_spec.rb +0 -96
  34. data/spec/integration/eradicate_spec.rb +0 -52
  35. data/spec/integration/fedora_solr_sync_spec.rb +0 -30
  36. data/spec/integration/file_fixity_spec.rb +0 -36
  37. data/spec/integration/file_spec.rb +0 -221
  38. data/spec/integration/generators/fedora_generator_spec.rb +0 -26
  39. data/spec/integration/generators/solr_generator_spec.rb +0 -23
  40. data/spec/integration/gone_spec.rb +0 -41
  41. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +0 -414
  42. data/spec/integration/has_many_associations_spec.rb +0 -436
  43. data/spec/integration/has_subresource_spec.rb +0 -34
  44. data/spec/integration/indexing/descendant_fetcher_spec.rb +0 -64
  45. data/spec/integration/indexing_spec.rb +0 -110
  46. data/spec/integration/indirect_container_spec.rb +0 -290
  47. data/spec/integration/json_serialization_spec.rb +0 -32
  48. data/spec/integration/marshal_spec.rb +0 -39
  49. data/spec/integration/nested_attribute_spec.rb +0 -177
  50. data/spec/integration/nested_hash_resources_spec.rb +0 -43
  51. data/spec/integration/persistence_spec.rb +0 -37
  52. data/spec/integration/query_result_builder_spec.rb +0 -37
  53. data/spec/integration/rdf_nested_attributes_spec.rb +0 -85
  54. data/spec/integration/relation_delegation_spec.rb +0 -52
  55. data/spec/integration/relation_spec.rb +0 -117
  56. data/spec/integration/scoped_query_spec.rb +0 -134
  57. data/spec/integration/scoping_spec.rb +0 -48
  58. data/spec/integration/solr_hit_spec.rb +0 -32
  59. data/spec/integration/versionable_spec.rb +0 -256
  60. data/spec/integration/with_metadata_spec.rb +0 -111
  61. data/spec/lib/active_fedora/null_logger_spec.rb +0 -10
  62. data/spec/rcov.opts +0 -2
  63. data/spec/spec.opts +0 -5
  64. data/spec/spec_helper.rb +0 -106
  65. data/spec/support/an_active_model.rb +0 -29
  66. data/spec/unit/active_fedora/indexing/inserter_spec.rb +0 -35
  67. data/spec/unit/active_fedora_spec.rb +0 -118
  68. data/spec/unit/aggregation/list_source_spec.rb +0 -134
  69. data/spec/unit/aggregation/ordered_reader_spec.rb +0 -43
  70. data/spec/unit/association_hash_spec.rb +0 -64
  71. data/spec/unit/attached_files_spec.rb +0 -218
  72. data/spec/unit/attributes_spec.rb +0 -146
  73. data/spec/unit/base_active_model_spec.rb +0 -28
  74. data/spec/unit/base_cma_spec.rb +0 -15
  75. data/spec/unit/base_extra_spec.rb +0 -33
  76. data/spec/unit/base_spec.rb +0 -328
  77. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +0 -8
  78. data/spec/unit/callback_spec.rb +0 -65
  79. data/spec/unit/change_set_spec.rb +0 -60
  80. data/spec/unit/checksum_spec.rb +0 -25
  81. data/spec/unit/code_configurator_spec.rb +0 -41
  82. data/spec/unit/collection_proxy_spec.rb +0 -25
  83. data/spec/unit/config_spec.rb +0 -18
  84. data/spec/unit/core/fedora_id_translator_spec.rb +0 -29
  85. data/spec/unit/core/fedora_uri_translator_spec.rb +0 -19
  86. data/spec/unit/core/logger_spec.rb +0 -18
  87. data/spec/unit/core_spec.rb +0 -242
  88. data/spec/unit/default_model_mapper_spec.rb +0 -39
  89. data/spec/unit/fedora_spec.rb +0 -31
  90. data/spec/unit/file/streaming_spec.rb +0 -33
  91. data/spec/unit/file_configurator_spec.rb +0 -295
  92. data/spec/unit/file_io_spec.rb +0 -137
  93. data/spec/unit/file_path_builder_spec.rb +0 -18
  94. data/spec/unit/file_spec.rb +0 -489
  95. data/spec/unit/files_hash_spec.rb +0 -52
  96. data/spec/unit/filter_spec.rb +0 -133
  97. data/spec/unit/finder_methods_spec.rb +0 -154
  98. data/spec/unit/fixity_service_spec.rb +0 -128
  99. data/spec/unit/forbidden_attributes_protection_spec.rb +0 -50
  100. data/spec/unit/has_and_belongs_to_many_association_spec.rb +0 -125
  101. data/spec/unit/has_many_association_spec.rb +0 -131
  102. data/spec/unit/indexers/global_indexer_spec.rb +0 -41
  103. data/spec/unit/indexing/map/index_object_spec.rb +0 -25
  104. data/spec/unit/indexing/map_spec.rb +0 -27
  105. data/spec/unit/indexing_service_spec.rb +0 -28
  106. data/spec/unit/indexing_spec.rb +0 -86
  107. data/spec/unit/inheritance_spec.rb +0 -60
  108. data/spec/unit/ldp_resource_spec.rb +0 -15
  109. data/spec/unit/loadable_from_json_spec.rb +0 -40
  110. data/spec/unit/logger_spec.rb +0 -19
  111. data/spec/unit/model_classifier_spec.rb +0 -49
  112. data/spec/unit/ordered_spec.rb +0 -367
  113. data/spec/unit/orders/list_node_spec.rb +0 -151
  114. data/spec/unit/orders/ordered_list_spec.rb +0 -335
  115. data/spec/unit/orders/reflection_spec.rb +0 -22
  116. data/spec/unit/pathing_spec.rb +0 -35
  117. data/spec/unit/persistence_spec.rb +0 -115
  118. data/spec/unit/property_predicate_spec.rb +0 -35
  119. data/spec/unit/property_spec.rb +0 -25
  120. data/spec/unit/query_result_builder_spec.rb +0 -31
  121. data/spec/unit/query_spec.rb +0 -307
  122. data/spec/unit/querying_spec.rb +0 -24
  123. data/spec/unit/rdf/indexing_service_spec.rb +0 -114
  124. data/spec/unit/rdf_vocab_spec.rb +0 -30
  125. data/spec/unit/readonly_spec.rb +0 -24
  126. data/spec/unit/reflection_spec.rb +0 -42
  127. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +0 -37
  128. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +0 -38
  129. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +0 -38
  130. data/spec/unit/schema_indexing_strategy_spec.rb +0 -68
  131. data/spec/unit/scoping_spec.rb +0 -67
  132. data/spec/unit/serializers_spec.rb +0 -19
  133. data/spec/unit/solr_config_options_spec.rb +0 -57
  134. data/spec/unit/solr_hit_spec.rb +0 -57
  135. data/spec/unit/solr_query_builder_spec.rb +0 -18
  136. data/spec/unit/solr_service_spec.rb +0 -165
  137. data/spec/unit/sparql_insert_spec.rb +0 -31
  138. data/spec/unit/validations_spec.rb +0 -92
  139. data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +0 -29
  140. data/spec/unit/with_metadata/metadata_node_spec.rb +0 -69
@@ -1,151 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ActiveFedora::Orders::ListNode do
4
- let(:list_node) { described_class.new(node_cache, rdf_subject, graph) }
5
- let(:node_cache) { {} }
6
- let(:rdf_subject) { RDF::URI("#bla") }
7
- let(:graph) { ActiveTriples::Resource.new }
8
-
9
- describe "#target" do
10
- context "when a target is set" do
11
- it "returns it" do
12
- member = instance_double("member")
13
- list_node.target = member
14
- expect(list_node.target).to eq member
15
- end
16
- end
17
- context "when no target is set" do
18
- context "and it's not in the graph" do
19
- it "returns nil" do
20
- expect(list_node.target).to eq nil
21
- end
22
- end
23
- context "and it's set in the graph" do
24
- before do
25
- class Member < ActiveFedora::Base
26
- end
27
- end
28
- after do
29
- Object.send(:remove_const, :Member)
30
- end
31
- it "returns it" do
32
- member = Member.create
33
- graph << [rdf_subject, RDF::Vocab::ORE.proxyFor, member.resource.rdf_subject]
34
- expect(list_node.target).to eq member
35
- end
36
- context "and it doesn't exist" do
37
- it "returns an AT::Resource" do
38
- member = Member.new(id: "testing")
39
- graph << [rdf_subject, RDF::Vocab::ORE.proxyFor, member.resource.rdf_subject]
40
- expect(list_node.target.rdf_subject).to eq member.uri
41
- end
42
- end
43
- end
44
- end
45
- end
46
-
47
- describe "#target_uri" do
48
- context "with a null target_id" do
49
- it "returns nil" do
50
- expect(list_node.target_uri).to eq nil
51
- end
52
- end
53
- context "with a target" do
54
- before do
55
- class Member < ActiveFedora::Base
56
- end
57
- end
58
- after do
59
- Object.send(:remove_const, :Member)
60
- end
61
- it "returns a built URI" do
62
- m = Member.new
63
- allow(m).to receive(:id).and_return("test")
64
- list_node.target = m
65
-
66
- expect(list_node.target_uri).to eq ActiveFedora::Base.translate_id_to_uri.call("test")
67
- end
68
- end
69
- end
70
-
71
- describe "#target_id" do
72
- context "when a target is set" do
73
- it "returns its id" do
74
- member = instance_double("member", id: "member1")
75
- list_node.target = member
76
- expect(list_node.target_id).to eq "member1"
77
- end
78
- end
79
- context "when a target is from the graph" do
80
- before do
81
- class Member < ActiveFedora::Base
82
- end
83
- end
84
- after do
85
- Object.send(:remove_const, :Member)
86
- end
87
- context "and it's cached but missing" do
88
- it "works" do
89
- member = Member.create
90
- graph << [rdf_subject, RDF::Vocab::ORE.proxyFor, member.resource.rdf_subject]
91
- allow(ActiveFedora::Base).to receive(:from_uri).and_return(ActiveTriples::Resource.new(member.resource.rdf_subject))
92
- list_node.target
93
-
94
- expect(list_node.target_id).to eq member.id
95
- end
96
- end
97
- it "doesn't re-ify the target" do
98
- member = Member.create
99
- graph << [rdf_subject, RDF::Vocab::ORE.proxyFor, member.resource.rdf_subject]
100
- allow(ActiveFedora::Base).to receive(:from_uri).and_call_original
101
-
102
- expect(list_node.target_id).to eq member.id
103
- expect(ActiveFedora::Base).not_to have_received(:from_uri)
104
- end
105
- end
106
- end
107
- describe "#proxy_in_id" do
108
- context "when a target is set" do
109
- it "returns its id" do
110
- member = instance_double("member", id: "member1")
111
- list_node.proxy_in = member
112
- expect(list_node.proxy_in_id).to eq "member1"
113
- end
114
- end
115
- context "when a proxy_in is from the graph" do
116
- before do
117
- class Member < ActiveFedora::Base
118
- end
119
- end
120
- after do
121
- Object.send(:remove_const, :Member)
122
- end
123
- context "and it's cached but missing" do
124
- it "works" do
125
- member = Member.create
126
- graph << [rdf_subject, RDF::Vocab::ORE.proxyIn, member.resource.rdf_subject]
127
- allow(ActiveFedora::Base).to receive(:from_uri).and_return(ActiveTriples::Resource.new(member.resource.rdf_subject))
128
- list_node.target
129
-
130
- expect(list_node.proxy_in_id).to eq member.id
131
- end
132
- end
133
- it "doesn't re-ify the target" do
134
- member = Member.create
135
- graph << [rdf_subject, RDF::Vocab::ORE.proxyIn, member.resource.rdf_subject]
136
- allow(ActiveFedora::Base).to receive(:from_uri).and_call_original
137
-
138
- expect(list_node.proxy_in_id).to eq member.id
139
- expect(ActiveFedora::Base).not_to have_received(:from_uri)
140
- end
141
- end
142
- end
143
-
144
- describe "#to_graph" do
145
- context "with no data" do
146
- it "returns an empty graph" do
147
- expect(list_node.to_graph.statements.to_a.length).to eq 0
148
- end
149
- end
150
- end
151
- end
@@ -1,335 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ActiveFedora::Orders::OrderedList do
4
- let(:ordered_list) { described_class.new(graph, head_uri, tail_uri) }
5
-
6
- let(:graph) { ActiveTriples::Resource.new(RDF::URI("stuff")) }
7
- let(:head_uri) { nil }
8
- let(:tail_uri) { nil }
9
- describe "#last" do
10
- context "with no nodes" do
11
- it "is nil" do
12
- expect(ordered_list.last).to eq nil
13
- end
14
- end
15
- context "with one node" do
16
- it "is that node" do
17
- member = instance_double(ActiveFedora::Base)
18
- ordered_list.append_target member
19
-
20
- expect(ordered_list.last.target).to eq member
21
- end
22
- end
23
- context "with two nodes" do
24
- it "is the last node" do
25
- member = instance_double(ActiveFedora::Base)
26
- member_2 = instance_double(ActiveFedora::Base)
27
- ordered_list.append_target member
28
- ordered_list.append_target member_2
29
-
30
- expect(ordered_list.last.target).to eq member_2
31
- end
32
- end
33
- end
34
-
35
- describe "#order_will_change!" do
36
- it "marks it as changed" do
37
- expect(ordered_list).not_to be_changed
38
- ordered_list.order_will_change!
39
- expect(ordered_list).to be_changed
40
- end
41
- end
42
-
43
- describe "#target_ids" do
44
- context "from a graph" do
45
- let(:head_uri) { RDF::URI.new("parent#bla") }
46
- let(:tail_uri) { RDF::URI.new("parent#bla") }
47
- it "returns the IDs without building the object" do
48
- node_subject = RDF::URI.new("parent#bla")
49
- member_uri = RDF::URI.new(ActiveFedora::Base.translate_id_to_uri.call("member1"))
50
- parent_uri = RDF::URI.new("parent")
51
- graph << [node_subject, RDF::Vocab::ORE.proxyFor, member_uri]
52
- graph << [node_subject, RDF::Vocab::ORE.proxyIn, parent_uri]
53
- allow(ActiveFedora::Base).to receive(:from_uri)
54
-
55
- expect(ordered_list.target_ids).to eq ["member1"]
56
- expect(ActiveFedora::Base).not_to have_received(:from_uri)
57
- end
58
- end
59
- context "from a built up list" do
60
- it "returns the IDs" do
61
- member = instance_double(ActiveFedora::Base, id: "member1")
62
- ordered_list.append_target member
63
-
64
- expect(ordered_list.target_ids).to eq ["member1"]
65
- end
66
- end
67
- end
68
-
69
- describe "#proxy_in" do
70
- context "when there's one proxy in" do
71
- it "returns it" do
72
- member = instance_double(ActiveFedora::Base)
73
- ordered_list.append_target member, proxy_in: RDF::URI("http://tar.dis")
74
-
75
- expect(ordered_list.proxy_in).to eq RDF::URI("http://tar.dis")
76
- end
77
- end
78
- context "when the proxy in is an AF::Base object" do
79
- it "returns the ID" do
80
- member = instance_double(ActiveFedora::Base)
81
- owner = instance_double(ActiveFedora::Base, id: "member1")
82
- ordered_list.append_target member, proxy_in: owner
83
-
84
- expect(ordered_list.proxy_in).to eq "member1"
85
- end
86
- end
87
- context "when there's two proxy ins" do
88
- it "returns the first and throws a warning" do
89
- member = instance_double(ActiveFedora::Base)
90
- ordered_list.append_target member, proxy_in: RDF::URI("http://tar.dis")
91
- ordered_list.append_target member, proxy_in: RDF::URI("http://tar.di")
92
- ActiveFedora::Base.logger = Logger.new(STDERR)
93
- allow(ActiveFedora::Base.logger).to receive(:warn)
94
-
95
- expect(ordered_list.proxy_in).to eq RDF::URI("http://tar.dis")
96
- expect(ActiveFedora::Base.logger).to have_received(:warn).with("WARNING: List contains nodes aggregated under different URIs. Returning only the first.")
97
- end
98
- end
99
- end
100
-
101
- describe "#[]" do
102
- context "with no nodes" do
103
- it "is always nil" do
104
- expect(ordered_list[0]).to eq nil
105
- end
106
- end
107
- context "with two nodes" do
108
- let(:member) { instance_double(ActiveFedora::Base) }
109
- let(:member_2) { instance_double(ActiveFedora::Base) }
110
- before do
111
- ordered_list.append_target member
112
- ordered_list.append_target member_2
113
- end
114
- it "can return the first" do
115
- expect(ordered_list[0].target).to eq member
116
- end
117
- it "can return the last" do
118
- expect(ordered_list[1].target).to eq member_2
119
- end
120
- it "returns nil for out of bounds values" do
121
- expect(ordered_list[3]).to eq nil
122
- end
123
- end
124
- end
125
- describe "#first" do
126
- context "with no nodes" do
127
- it "is nil" do
128
- expect(ordered_list.first).to eq nil
129
- end
130
- end
131
- context "with a node" do
132
- it "returns that node" do
133
- member = instance_double(ActiveFedora::Base)
134
- ordered_list.append_target member
135
- expect(ordered_list.first.target).to eq member
136
- expect(ordered_list).to be_changed
137
- end
138
- end
139
- context "with an item from the graph" do
140
- let(:head_uri) { RDF::URI.new("parent#bla") }
141
- let(:tail_uri) { RDF::URI.new("parent#bla") }
142
- it "builds the node" do
143
- node_subject = RDF::URI.new("parent#bla")
144
- member_uri = RDF::URI.new("member1")
145
- parent_uri = RDF::URI.new("parent")
146
- graph << [node_subject, RDF::Vocab::ORE.proxyFor, member_uri]
147
- graph << [node_subject, RDF::Vocab::ORE.proxyIn, parent_uri]
148
- expect(ordered_list.first.proxy_for).to eq member_uri
149
- expect(ordered_list.first.proxy_for).to be_kind_of RDF::URI
150
- expect(ordered_list.first.proxy_in).to eq parent_uri
151
- expect(ordered_list.first).not_to eq nil
152
- end
153
- it "is changed by a delete" do
154
- node_subject = RDF::URI.new("parent#bla")
155
- member_uri = RDF::URI.new("member1")
156
- parent_uri = RDF::URI.new("parent")
157
- graph << [node_subject, RDF::Vocab::ORE.proxyFor, member_uri]
158
- graph << [node_subject, RDF::Vocab::ORE.proxyIn, parent_uri]
159
-
160
- expect(ordered_list).not_to be_changed
161
- ordered_list.delete_at(0)
162
- expect(ordered_list).to be_changed
163
- end
164
- context "with multiple nodes" do
165
- let(:tail_uri) { RDF::URI.new("parent#bla2") }
166
- it "can build multiple nodes" do
167
- node_subject = RDF::URI.new("parent#bla")
168
- node_2_subject = RDF::URI.new("parent#bla2")
169
- member_uri = RDF::URI.new("member1")
170
- parent_uri = RDF::URI.new("parent")
171
- graph << [node_subject, RDF::Vocab::ORE.proxyFor, member_uri]
172
- graph << [node_subject, RDF::Vocab::ORE.proxyIn, parent_uri]
173
- graph << [node_subject, RDF::Vocab::IANA.next, node_2_subject]
174
- graph << [node_2_subject, RDF::Vocab::IANA.prev, node_subject]
175
- graph << [node_2_subject, RDF::Vocab::ORE.proxyFor, member_uri]
176
- graph << [node_2_subject, RDF::Vocab::ORE.proxyIn, parent_uri]
177
- expect(ordered_list.length).to eq 2
178
- expect(ordered_list.tail.prev.prev).to eq ordered_list.head.next
179
- expect(ordered_list.map(&:target).map(&:rdf_subject)).to eq [member_uri, member_uri]
180
- expect(ordered_list).not_to be_changed
181
- end
182
- end
183
- end
184
- end
185
-
186
- describe "#append_target" do
187
- it "appends multiple targets" do
188
- member = instance_double(ActiveFedora::Base)
189
- proxy_in = instance_double(ActiveFedora::Base, uri: RDF::URI("obj1"))
190
- 600.times do
191
- ordered_list.append_target member, proxy_in: proxy_in
192
- end
193
- expect(ordered_list.length).to eq 600
194
- expect(ordered_list.to_a.last.next).not_to eq nil
195
- expect(ordered_list.to_a.last.proxy_in).to eq proxy_in
196
- end
197
- end
198
-
199
- describe "#insert_at" do
200
- it "can insert in the middle" do
201
- member = instance_double(ActiveFedora::Base)
202
- member_2 = instance_double(ActiveFedora::Base)
203
- 3.times do
204
- ordered_list.append_target member
205
- end
206
-
207
- ordered_list.insert_at(1, member_2)
208
-
209
- expect(ordered_list.to_a.map(&:target)).to eq [member, member_2, member, member]
210
- expect(ordered_list).to be_changed
211
- end
212
- it "can insert at the beginning" do
213
- member = instance_double(ActiveFedora::Base)
214
- member_2 = instance_double(ActiveFedora::Base)
215
- 2.times do
216
- ordered_list.append_target member
217
- end
218
-
219
- ordered_list.insert_at(0, member_2)
220
-
221
- expect(ordered_list.to_a.map(&:target)).to eq [member_2, member, member]
222
- end
223
- end
224
-
225
- describe "#delete_node" do
226
- it "can delete a node in the middle" do
227
- member = instance_double(ActiveFedora::Base)
228
- member_2 = instance_double(ActiveFedora::Base)
229
- ordered_list.append_target member
230
- ordered_list.append_target member_2
231
- ordered_list.append_target member
232
-
233
- ordered_list.delete_node(ordered_list.to_a[1])
234
-
235
- expect(ordered_list.map(&:target)).to eq [member, member]
236
- end
237
- it "can delete a node at the start" do
238
- member = instance_double(ActiveFedora::Base)
239
- member_2 = instance_double(ActiveFedora::Base)
240
- ordered_list.append_target member_2
241
- ordered_list.append_target member
242
- ordered_list.append_target member
243
-
244
- ordered_list.delete_node(ordered_list.to_a[0])
245
-
246
- expect(ordered_list.map(&:target)).to eq [member, member]
247
- end
248
- it "can delete a node at the end" do
249
- member = instance_double(ActiveFedora::Base)
250
- member_2 = instance_double(ActiveFedora::Base)
251
- ordered_list.append_target member
252
- ordered_list.append_target member
253
- ordered_list.append_target member_2
254
-
255
- ordered_list.delete_node(ordered_list.to_a[2])
256
-
257
- expect(ordered_list.map(&:target)).to eq [member, member]
258
- end
259
- end
260
-
261
- describe "#delete_at" do
262
- it "can delete a node in the middle" do
263
- member = instance_double(ActiveFedora::Base)
264
- member_2 = instance_double(ActiveFedora::Base)
265
- ordered_list.append_target member
266
- ordered_list.append_target member_2
267
- ordered_list.append_target member
268
-
269
- ordered_list.delete_at(1)
270
-
271
- expect(ordered_list.map(&:target)).to eq [member, member]
272
- end
273
- it "can delete a node at the start" do
274
- member = instance_double(ActiveFedora::Base)
275
- member_2 = instance_double(ActiveFedora::Base)
276
- ordered_list.append_target member_2
277
- ordered_list.append_target member
278
- ordered_list.append_target member
279
-
280
- ordered_list.delete_at(0)
281
-
282
- expect(ordered_list.map(&:target)).to eq [member, member]
283
- end
284
- it "can delete a node at the end" do
285
- member = instance_double(ActiveFedora::Base)
286
- member_2 = instance_double(ActiveFedora::Base)
287
- ordered_list.append_target member
288
- ordered_list.append_target member
289
- ordered_list.append_target member_2
290
-
291
- ordered_list.delete_at(2)
292
-
293
- expect(ordered_list.map(&:target)).to eq [member, member]
294
- end
295
- it "does not delete nodes if the loc is out of bounds" do
296
- member = instance_double(ActiveFedora::Base)
297
- member_2 = instance_double(ActiveFedora::Base)
298
- ordered_list.append_target member
299
- ordered_list.append_target member
300
- ordered_list.append_target member_2
301
-
302
- ordered_list.delete_at(3)
303
- ordered_list.delete_at(nil)
304
-
305
- expect(ordered_list.map(&:target)).to eq [member, member, member_2]
306
- end
307
- end
308
-
309
- describe "#to_graph" do
310
- it "creates a good graph" do
311
- member = instance_double(ActiveFedora::Base, id: '123/456')
312
- owner = instance_double(ActiveFedora::Base, uri: RDF::URI("http://owner.org"))
313
- ordered_list.append_target member
314
- ordered_list.append_target member, proxy_in: owner
315
-
316
- graph = ordered_list.to_graph
317
-
318
- expect(graph.statements.to_a.length).to eq 5
319
- expect(graph.subjects.to_a).to contain_exactly(*ordered_list.to_a.map(&:rdf_subject))
320
- expect(graph.query([nil, RDF::Vocab::ORE.proxyFor, nil]).to_a.last.object).to be_kind_of RDF::URI
321
- end
322
- end
323
-
324
- describe "#changes_committed!" do
325
- it "sets changed back to false" do
326
- member = instance_double(ActiveFedora::Base, uri: RDF::URI("http://test.org"))
327
- ordered_list.append_target member
328
- expect(ordered_list).to be_changed
329
-
330
- ordered_list.changes_committed!
331
-
332
- expect(ordered_list).not_to be_changed
333
- end
334
- end
335
- end