active-fedora 11.0.0.rc1 → 11.0.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/active_fedora/railtie.rb +2 -2
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/associations_spec.rb +17 -18
- data/spec/integration/attached_files_spec.rb +4 -4
- data/spec/integration/attributes_spec.rb +12 -16
- data/spec/integration/autosave_association_spec.rb +5 -5
- data/spec/integration/base_spec.rb +2 -2
- data/spec/integration/collection_association_spec.rb +2 -5
- data/spec/integration/datastream_rdf_nested_attributes_spec.rb +23 -23
- data/spec/integration/date_time_properties_spec.rb +1 -2
- data/spec/integration/direct_container_spec.rb +8 -8
- data/spec/integration/directly_contains_one_association_spec.rb +11 -13
- data/spec/integration/fedora_solr_sync_spec.rb +2 -2
- data/spec/integration/file_fixity_spec.rb +6 -8
- data/spec/integration/file_spec.rb +9 -10
- data/spec/integration/has_many_associations_spec.rb +6 -8
- data/spec/integration/indirect_container_spec.rb +8 -9
- data/spec/integration/json_serialization_spec.rb +4 -4
- data/spec/integration/ntriples_datastream_spec.rb +74 -74
- data/spec/integration/om_datastream_spec.rb +13 -13
- data/spec/integration/rdf_nested_attributes_spec.rb +6 -6
- data/spec/integration/relation_delegation_spec.rb +8 -8
- data/spec/integration/relation_spec.rb +13 -16
- data/spec/integration/solr_hit_spec.rb +4 -4
- data/spec/integration/versionable_spec.rb +132 -132
- data/spec/unit/aggregation/list_source_spec.rb +37 -37
- data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
- data/spec/unit/association_hash_spec.rb +15 -15
- data/spec/unit/attached_files_spec.rb +19 -19
- data/spec/unit/attributes_spec.rb +25 -25
- data/spec/unit/base_active_model_spec.rb +8 -8
- data/spec/unit/base_extra_spec.rb +5 -4
- data/spec/unit/base_spec.rb +9 -9
- data/spec/unit/change_set_spec.rb +5 -5
- data/spec/unit/core_spec.rb +26 -26
- data/spec/unit/default_model_mapper_spec.rb +3 -3
- data/spec/unit/fedora_spec.rb +2 -2
- data/spec/unit/file_configurator_spec.rb +92 -92
- data/spec/unit/file_spec.rb +60 -60
- data/spec/unit/files_hash_spec.rb +7 -7
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +12 -12
- data/spec/unit/has_many_association_spec.rb +2 -2
- data/spec/unit/indexers/global_indexer_spec.rb +6 -6
- data/spec/unit/indexing_service_spec.rb +5 -5
- data/spec/unit/indexing_spec.rb +4 -4
- data/spec/unit/loadable_from_json_spec.rb +4 -4
- data/spec/unit/model_classifier_spec.rb +4 -4
- data/spec/unit/nom_datastream_spec.rb +8 -8
- data/spec/unit/om_datastream_spec.rb +43 -43
- data/spec/unit/ordered_spec.rb +142 -142
- data/spec/unit/orders/list_node_spec.rb +20 -20
- data/spec/unit/orders/ordered_list_spec.rb +96 -96
- data/spec/unit/orders/reflection_spec.rb +3 -3
- data/spec/unit/pathing_spec.rb +4 -4
- data/spec/unit/persistence_spec.rb +28 -28
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +8 -8
- data/spec/unit/query_spec.rb +5 -5
- data/spec/unit/rdf/indexing_service_spec.rb +17 -17
- data/spec/unit/rdf_datastream_spec.rb +10 -10
- data/spec/unit/rdf_resource_datastream_spec.rb +37 -37
- data/spec/unit/rdfxml_datastream_spec.rb +14 -14
- data/spec/unit/readonly_spec.rb +5 -4
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
- data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
- data/spec/unit/serializers_spec.rb +3 -4
- data/spec/unit/solr_hit_spec.rb +9 -9
- data/spec/unit/sparql_insert_spec.rb +2 -2
- data/spec/unit/validations_spec.rb +9 -9
- data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +2 -1
- data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
- metadata +2 -2
@@ -1,67 +1,67 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe ActiveFedora::Aggregation::ListSource do
|
4
|
-
subject { described_class.new }
|
4
|
+
subject(:list_source) { described_class.new }
|
5
5
|
|
6
6
|
describe "#head" do
|
7
7
|
it "is nil by default" do
|
8
|
-
expect(
|
8
|
+
expect(list_source.head).to eq nil
|
9
9
|
end
|
10
10
|
|
11
11
|
it "is settable" do
|
12
|
-
|
12
|
+
list_source.head = RDF::URI("test.org")
|
13
13
|
|
14
|
-
expect(
|
14
|
+
expect(list_source.head_id.first).to eq RDF::URI("test.org")
|
15
15
|
end
|
16
16
|
|
17
17
|
it "maps to IANA.first" do
|
18
|
-
expect(
|
18
|
+
expect(list_source.class.properties["head"].predicate).to eq ::RDF::Vocab::IANA["first"]
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "#order_will_change!" do
|
23
23
|
it "marks it as changed" do
|
24
|
-
expect(
|
25
|
-
|
26
|
-
expect(
|
27
|
-
expect(
|
24
|
+
expect(list_source).not_to be_changed
|
25
|
+
list_source.order_will_change!
|
26
|
+
expect(list_source).to be_changed
|
27
|
+
expect(list_source.ordered_self).to be_changed
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "#tail" do
|
32
32
|
it "is nil by default" do
|
33
|
-
expect(
|
33
|
+
expect(list_source.tail).to eq nil
|
34
34
|
end
|
35
35
|
|
36
36
|
it "is settable" do
|
37
|
-
|
37
|
+
list_source.tail = RDF::URI("test.org")
|
38
38
|
|
39
|
-
expect(
|
39
|
+
expect(list_source.tail_id.first).to eq RDF::URI("test.org")
|
40
40
|
end
|
41
41
|
|
42
42
|
it "maps to IANA.last" do
|
43
|
-
expect(
|
43
|
+
expect(list_source.class.properties["tail"].predicate).to eq ::RDF::Vocab::IANA["last"]
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe "#changed?" do
|
48
48
|
context "when nothing has changed" do
|
49
49
|
it "is false" do
|
50
|
-
expect(
|
50
|
+
expect(list_source).not_to be_changed
|
51
51
|
end
|
52
52
|
end
|
53
53
|
context "when the ordered list is changed" do
|
54
54
|
it "is true" do
|
55
|
-
allow(
|
55
|
+
allow(list_source.ordered_self).to receive(:changed?).and_return(true)
|
56
56
|
|
57
|
-
expect(
|
57
|
+
expect(list_source).to be_changed
|
58
58
|
end
|
59
59
|
end
|
60
60
|
context "when the ordered list is not changed" do
|
61
61
|
it "is false" do
|
62
|
-
allow(
|
62
|
+
allow(list_source.ordered_self).to receive(:changed?).and_return(false)
|
63
63
|
|
64
|
-
expect(
|
64
|
+
expect(list_source).not_to be_changed
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -69,50 +69,50 @@ RSpec.describe ActiveFedora::Aggregation::ListSource do
|
|
69
69
|
describe "#save" do
|
70
70
|
context "when nothing has changed" do
|
71
71
|
it "does not persist ordered_self" do
|
72
|
-
allow(
|
72
|
+
allow(list_source.ordered_self).to receive(:to_graph)
|
73
73
|
|
74
|
-
|
74
|
+
list_source.save
|
75
75
|
|
76
|
-
expect(
|
76
|
+
expect(list_source.ordered_self).not_to have_received(:to_graph)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
context "when attributes have changed, but not ordered list" do
|
80
80
|
it "does not persist ordered self" do
|
81
|
-
allow(
|
82
|
-
|
81
|
+
allow(list_source.ordered_self).to receive(:to_graph)
|
82
|
+
list_source.nodes += [RDF::URI("http://test.org")]
|
83
83
|
|
84
|
-
|
84
|
+
list_source.save
|
85
85
|
|
86
|
-
expect(
|
86
|
+
expect(list_source.ordered_self).not_to have_received(:to_graph)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
context "when ordered list has changed" do
|
90
90
|
it "persists it" do
|
91
|
-
allow(
|
92
|
-
allow(
|
91
|
+
allow(list_source.ordered_self).to receive(:to_graph).and_call_original
|
92
|
+
allow(list_source.ordered_self).to receive(:changed?).and_return(true)
|
93
93
|
|
94
|
-
|
94
|
+
list_source.save
|
95
95
|
|
96
|
-
expect(
|
96
|
+
expect(list_source.ordered_self).to have_received(:to_graph)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
101
|
describe "#serializable_hash" do
|
102
102
|
it "does not serialize nodes" do
|
103
|
-
|
103
|
+
list_source.nodes += [RDF::URI("http://test.org")]
|
104
104
|
|
105
|
-
expect(
|
105
|
+
expect(list_source.serializable_hash).not_to have_key "nodes"
|
106
106
|
end
|
107
107
|
it "does not serialize head" do
|
108
|
-
|
108
|
+
list_source.head = RDF::URI("http://test.org")
|
109
109
|
|
110
|
-
expect(
|
110
|
+
expect(list_source.serializable_hash).not_to have_key "head"
|
111
111
|
end
|
112
112
|
it "does not serialize tail" do
|
113
|
-
|
113
|
+
list_source.tail = RDF::URI("http://test.org")
|
114
114
|
|
115
|
-
expect(
|
115
|
+
expect(list_source.serializable_hash).not_to have_key "tail"
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -127,8 +127,8 @@ RSpec.describe ActiveFedora::Aggregation::ListSource do
|
|
127
127
|
it "can index" do
|
128
128
|
m = Member.create
|
129
129
|
proxy_in = RDF::URI(ActiveFedora::Base.translate_id_to_uri.call("banana"))
|
130
|
-
|
131
|
-
expect(
|
130
|
+
list_source.ordered_self.append_target m, proxy_in: proxy_in
|
131
|
+
expect(list_source.to_solr).to include ordered_targets_ssim: [m.id], proxy_in_ssi: "banana"
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe ActiveFedora::Aggregation::OrderedReader do
|
4
|
-
subject { described_class.new(root) }
|
4
|
+
subject(:ordered_reader) { described_class.new(root) }
|
5
5
|
let(:root) { instance_double(ActiveFedora::Aggregation::ListSource) }
|
6
6
|
|
7
7
|
describe "#each" do
|
@@ -10,14 +10,14 @@ RSpec.describe ActiveFedora::Aggregation::OrderedReader do
|
|
10
10
|
tail = build_node(prev_node: head)
|
11
11
|
allow(head).to receive(:next).and_return(tail)
|
12
12
|
allow(root).to receive(:head).and_return(head)
|
13
|
-
expect(
|
13
|
+
expect(ordered_reader.to_a).to eq [head, tail]
|
14
14
|
end
|
15
15
|
it "only goes as deep as necessary" do
|
16
16
|
head = build_node
|
17
17
|
tail = build_node(prev_node: head)
|
18
18
|
allow(head).to receive(:next).and_return(tail)
|
19
19
|
allow(root).to receive(:head).and_return(head)
|
20
|
-
expect(
|
20
|
+
expect(ordered_reader.first).to eq head
|
21
21
|
expect(head).not_to have_received(:next)
|
22
22
|
end
|
23
23
|
context "when the prev is wrong" do
|
@@ -28,7 +28,7 @@ RSpec.describe ActiveFedora::Aggregation::OrderedReader do
|
|
28
28
|
allow(head).to receive(:next).and_return(tail)
|
29
29
|
allow(root).to receive(:head).and_return(head)
|
30
30
|
allow(tail).to receive(:prev=)
|
31
|
-
expect(
|
31
|
+
expect(ordered_reader.to_a).to eq [head, tail]
|
32
32
|
expect(tail).to have_received(:prev=).with(head)
|
33
33
|
end
|
34
34
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::AssociationHash do
|
4
|
-
subject { described_class.new(model, reflections) }
|
4
|
+
subject(:association_hash) { described_class.new(model, reflections) }
|
5
5
|
|
6
6
|
let(:model) { double(association: nil) }
|
7
7
|
let(:reflections) { double(keys: [:foo]) }
|
@@ -12,18 +12,18 @@ describe ActiveFedora::AssociationHash do
|
|
12
12
|
describe "key reader" do
|
13
13
|
describe "when the association exists" do
|
14
14
|
before do
|
15
|
-
allow(
|
15
|
+
allow(association_hash).to receive(:association).with("foo") { association }
|
16
16
|
end
|
17
17
|
it "calls the association reader" do
|
18
|
-
expect(
|
18
|
+
expect(association_hash["foo"]).to eq(reader)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
describe "when the association does not exist" do
|
22
22
|
before do
|
23
|
-
allow(
|
23
|
+
allow(association_hash).to receive(:association).with("foo") { nil }
|
24
24
|
end
|
25
25
|
it "returns nil" do
|
26
|
-
expect(
|
26
|
+
expect(association_hash["foo"]).to be_nil
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -35,20 +35,20 @@ describe ActiveFedora::AssociationHash do
|
|
35
35
|
end
|
36
36
|
describe "when the association exists" do
|
37
37
|
before do
|
38
|
-
allow(
|
38
|
+
allow(association_hash).to receive(:association).with("foo") { association }
|
39
39
|
end
|
40
40
|
it "calls the association writer" do
|
41
41
|
expect(association).to receive(:writer).with(obj)
|
42
|
-
|
42
|
+
association_hash["foo"] = obj
|
43
43
|
end
|
44
44
|
end
|
45
45
|
describe "when the association does not exist" do
|
46
46
|
before do
|
47
|
-
allow(
|
47
|
+
allow(association_hash).to receive(:association).with("foo") { nil }
|
48
48
|
end
|
49
49
|
it "doesn't call the association writer" do
|
50
50
|
expect(association).not_to receive(:writer).with(obj)
|
51
|
-
|
51
|
+
association_hash["foo"] = obj
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -58,21 +58,21 @@ describe ActiveFedora::AssociationHash do
|
|
58
58
|
allow(model).to receive(:association).with(:foo) { association }
|
59
59
|
end
|
60
60
|
it "works with a string key" do
|
61
|
-
expect(
|
61
|
+
expect(association_hash.association("foo")).to eq(association)
|
62
62
|
end
|
63
63
|
it "works with a symbol key" do
|
64
|
-
expect(
|
64
|
+
expect(association_hash.association(:foo)).to eq(association)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
describe "#key?" do
|
69
69
|
it "works with a string" do
|
70
|
-
expect(
|
71
|
-
expect(
|
70
|
+
expect(association_hash.key?("foo")).to be true
|
71
|
+
expect(association_hash.key?("bar")).to be false
|
72
72
|
end
|
73
73
|
it "works with a symbol" do
|
74
|
-
expect(
|
75
|
-
expect(
|
74
|
+
expect(association_hash.key?(:foo)).to be true
|
75
|
+
expect(association_hash.key?(:bar)).to be false
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::AttachedFiles do
|
4
|
-
subject { ActiveFedora::Base.new }
|
4
|
+
subject(:af_base) { ActiveFedora::Base.new }
|
5
5
|
describe "has_subresource" do
|
6
6
|
before do
|
7
7
|
class Z < ActiveFedora::File
|
@@ -101,33 +101,33 @@ describe ActiveFedora::AttachedFiles do
|
|
101
101
|
|
102
102
|
expect(m1).to receive(:serialize!)
|
103
103
|
expect(m2).to receive(:serialize!)
|
104
|
-
allow(
|
105
|
-
|
104
|
+
allow(af_base).to receive(:declared_attached_files).and_return(m1: m1, m2: m2)
|
105
|
+
af_base.serialize_attached_files
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
109
|
describe "#accessor_name" do
|
110
110
|
it "uses the name" do
|
111
|
-
expect(
|
111
|
+
expect(af_base.send(:accessor_name, 'abc')).to eq 'abc'
|
112
112
|
end
|
113
113
|
|
114
114
|
it "uses the name" do
|
115
|
-
expect(
|
115
|
+
expect(af_base.send(:accessor_name, 'ARCHIVAL_XML')).to eq 'ARCHIVAL_XML'
|
116
116
|
end
|
117
117
|
|
118
118
|
it "uses the name" do
|
119
|
-
expect(
|
119
|
+
expect(af_base.send(:accessor_name, 'descMetadata')).to eq 'descMetadata'
|
120
120
|
end
|
121
121
|
|
122
122
|
it "hash-erizes underscores" do
|
123
|
-
expect(
|
123
|
+
expect(af_base.send(:accessor_name, 'a-b')).to eq 'a_b'
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
127
|
describe "#attached_files" do
|
128
128
|
it "returns the datastream hash proxy" do
|
129
|
-
allow(
|
130
|
-
expect(
|
129
|
+
allow(af_base).to receive(:load_datastreams)
|
130
|
+
expect(af_base.attached_files).to be_a_kind_of(ActiveFedora::FilesHash)
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
@@ -136,37 +136,37 @@ describe ActiveFedora::AttachedFiles do
|
|
136
136
|
|
137
137
|
it "does not call save on the file" do
|
138
138
|
expect(file).to receive(:save).never
|
139
|
-
|
139
|
+
af_base.attach_file(file, 'part1')
|
140
140
|
end
|
141
141
|
|
142
142
|
it "adds the file to the attached_files hash" do
|
143
143
|
expect {
|
144
|
-
|
145
|
-
}.to change {
|
144
|
+
af_base.attach_file(file, 'part1')
|
145
|
+
}.to change { af_base.attached_files.key?(:part1) }.from(false).to(true)
|
146
146
|
end
|
147
147
|
|
148
148
|
context "after attaching the file" do
|
149
149
|
let(:dsid) { 'Abc' }
|
150
150
|
before do
|
151
|
-
|
151
|
+
af_base.attach_file(file, dsid)
|
152
152
|
end
|
153
153
|
|
154
154
|
it "adds the datastream to the object" do
|
155
|
-
expect(
|
155
|
+
expect(af_base.attached_files['Abc']).to eq file
|
156
156
|
end
|
157
157
|
|
158
158
|
describe "dynamic accessors" do
|
159
159
|
context "when the file is named with dash" do
|
160
160
|
let(:dsid) { 'eac-cpf' }
|
161
161
|
it "converts dashes to underscores" do
|
162
|
-
expect(
|
162
|
+
expect(af_base.eac_cpf).to eq file
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
166
|
context "when the file is named with underscore" do
|
167
167
|
let(:dsid) { 'foo_bar' }
|
168
168
|
it "preserves the underscore" do
|
169
|
-
expect(
|
169
|
+
expect(af_base.foo_bar).to eq file
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
@@ -179,9 +179,9 @@ describe ActiveFedora::AttachedFiles do
|
|
179
179
|
ds2 = double(metadata?: true)
|
180
180
|
ds3 = double(metadata?: true)
|
181
181
|
file_ds = double(metadata?: false)
|
182
|
-
allow(
|
183
|
-
expect(
|
184
|
-
expect(
|
182
|
+
allow(af_base).to receive(:attached_files).and_return(a: ds1, b: ds2, c: ds3, e: file_ds)
|
183
|
+
expect(af_base.metadata_streams).to include(ds1, ds2, ds3)
|
184
|
+
expect(af_base.metadata_streams).to_not include(file_ds)
|
185
185
|
end
|
186
186
|
end
|
187
187
|
end
|
@@ -16,12 +16,12 @@ describe ActiveFedora::Base do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
let(:obj) { BarHistory4.new(title: ['test1']) }
|
19
|
-
subject { obj }
|
19
|
+
subject(:history) { obj }
|
20
20
|
|
21
21
|
describe "#attribute_names" do
|
22
22
|
context "on an instance" do
|
23
23
|
it "lists the attributes" do
|
24
|
-
expect(
|
24
|
+
expect(history.attribute_names).to eq ["title", "abstract"]
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -34,21 +34,21 @@ describe ActiveFedora::Base do
|
|
34
34
|
|
35
35
|
describe "#inspect" do
|
36
36
|
it "shows the attributes" do
|
37
|
-
expect(
|
37
|
+
expect(history.inspect).to eq "#<BarHistory4 id: nil, title: [\"test1\"], abstract: nil>"
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "with a id" do
|
41
|
-
before { allow(
|
41
|
+
before { allow(history).to receive(:id).and_return('test:123') }
|
42
42
|
|
43
43
|
it "shows a id" do
|
44
|
-
expect(
|
44
|
+
expect(history.inspect).to eq "#<BarHistory4 id: \"test:123\", title: [\"test1\"], abstract: nil>"
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "with no attributes" do
|
49
|
-
subject { described_class.new }
|
49
|
+
subject(:object) { described_class.new }
|
50
50
|
it "shows a id" do
|
51
|
-
expect(
|
51
|
+
expect(object.inspect).to eq "#<ActiveFedora::Base id: nil>"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -57,18 +57,18 @@ describe ActiveFedora::Base do
|
|
57
57
|
class BarHistory2 < BarHistory4
|
58
58
|
belongs_to :library, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasConstituent, class_name: 'BarHistory4'
|
59
59
|
end
|
60
|
-
|
60
|
+
history.library = library
|
61
61
|
end
|
62
62
|
|
63
63
|
let(:library) { BarHistory4.create }
|
64
|
-
subject { BarHistory2.new }
|
64
|
+
subject(:history) { BarHistory2.new }
|
65
65
|
|
66
66
|
after do
|
67
67
|
Object.send(:remove_const, :BarHistory2)
|
68
68
|
end
|
69
69
|
|
70
70
|
it "shows the library_id" do
|
71
|
-
expect(
|
71
|
+
expect(history.inspect).to eq "#<BarHistory2 id: nil, title: [], abstract: nil, library_id: \"#{library.id}\">"
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -83,36 +83,36 @@ describe ActiveFedora::Base do
|
|
83
83
|
describe "accessing attributes" do
|
84
84
|
context "using generated methods" do
|
85
85
|
it "returns values" do
|
86
|
-
expect(
|
86
|
+
expect(history.title).to eq ['test1']
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
context "using hash accessors" do
|
91
91
|
context "on single value fields" do
|
92
92
|
it "has a default value" do
|
93
|
-
expect(
|
93
|
+
expect(history[:abstract]).to be_nil
|
94
94
|
end
|
95
95
|
|
96
96
|
context "when there are two assertions for the predicate" do
|
97
97
|
before do
|
98
|
-
|
98
|
+
history.resource[:abstract] = ['foo', 'bar']
|
99
99
|
end
|
100
100
|
it "raises an error if just returning the first value would cause data loss" do
|
101
|
-
expect {
|
101
|
+
expect { history[:abstract] }.to raise_error ActiveFedora::ConstraintError, "Expected \"abstract\" to have 0-1 statements, but there are 2"
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
context "multiple values" do
|
107
107
|
it "returns values" do
|
108
|
-
expect(
|
108
|
+
expect(history[:title]).to eq ['test1']
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
112
|
context "on Fedora attributes" do
|
113
113
|
it "return values" do
|
114
|
-
expect(
|
115
|
-
expect(
|
114
|
+
expect(history[:type]).to be_empty
|
115
|
+
expect(history[:rdf_label]).to contain_exactly("test1")
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
@@ -121,8 +121,8 @@ describe ActiveFedora::Base do
|
|
121
121
|
describe 'change tracking' do
|
122
122
|
it "is able to track change status" do
|
123
123
|
expect {
|
124
|
-
|
125
|
-
}.to change {
|
124
|
+
history.abstract = "Moo"
|
125
|
+
}.to change { history.abstract_changed? }.from(false).to(true)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -136,16 +136,16 @@ describe ActiveFedora::Base do
|
|
136
136
|
|
137
137
|
describe "when an object of the wrong cardinality is set" do
|
138
138
|
it "does not allow passing a string to a multiple property writer" do
|
139
|
-
expect {
|
140
|
-
expect {
|
141
|
-
expect {
|
139
|
+
expect { history.title = "Quack" }.to raise_error ArgumentError
|
140
|
+
expect { history.title = ["Quack"] }.not_to raise_error
|
141
|
+
expect { history.title = nil }.not_to raise_error
|
142
142
|
end
|
143
143
|
|
144
144
|
it "does not allow an enumerable to a unique attribute writer" do
|
145
|
-
expect {
|
146
|
-
expect {
|
145
|
+
expect { history.abstract = "Low" }.not_to raise_error
|
146
|
+
expect { history.abstract = ["Low"]
|
147
147
|
}.to raise_error ArgumentError, "You attempted to set the property `abstract' to an enumerable value. However, this property is declared as singular."
|
148
|
-
expect {
|
148
|
+
expect { history.abstract = nil }.not_to raise_error
|
149
149
|
end
|
150
150
|
end
|
151
151
|
end
|