active-fedora 11.0.0.rc1 → 11.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- 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,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe ActiveFedora::Reflection::OrdersReflection do
|
4
|
-
|
4
|
+
let(:orders_reflection) { described_class.new(name, scope, options, active_fedora) }
|
5
5
|
let(:macro) { :orders }
|
6
6
|
let(:name) { "ordered_member_proxies" }
|
7
7
|
let(:options) { {} }
|
@@ -10,13 +10,13 @@ RSpec.describe ActiveFedora::Reflection::OrdersReflection do
|
|
10
10
|
|
11
11
|
describe "#klass" do
|
12
12
|
it "is a proxy" do
|
13
|
-
expect(
|
13
|
+
expect(orders_reflection.klass).to eq ActiveFedora::Orders::ListNode
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
describe "#class_name" do
|
18
18
|
it "is a list node" do
|
19
|
-
expect(
|
19
|
+
expect(orders_reflection.class_name).to eq "ActiveFedora::Orders::ListNode"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/spec/unit/pathing_spec.rb
CHANGED
@@ -17,19 +17,19 @@ describe ActiveFedora::Base do
|
|
17
17
|
Object.send(:remove_const, :FooHistory)
|
18
18
|
end
|
19
19
|
|
20
|
-
subject { FooHistory.new(title: ["Root foo"]) }
|
20
|
+
subject(:history) { FooHistory.new(title: ["Root foo"]) }
|
21
21
|
|
22
22
|
it { is_expected.to have_uri_prefix }
|
23
23
|
|
24
24
|
it "uses the root path in the uri" do
|
25
|
-
expect(
|
25
|
+
expect(history.uri_prefix).to eql path
|
26
26
|
end
|
27
27
|
|
28
28
|
context "when the object is saved" do
|
29
|
-
before {
|
29
|
+
before { history.save }
|
30
30
|
|
31
31
|
it "persists the path in the uri" do
|
32
|
-
expect(
|
32
|
+
expect(history.uri.to_s).to include(path)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -3,27 +3,27 @@ require 'spec_helper'
|
|
3
3
|
describe ActiveFedora::Persistence do
|
4
4
|
describe '#new_record?' do
|
5
5
|
context 'with an new object' do
|
6
|
-
subject { ActiveFedora::Base.new }
|
6
|
+
subject(:persistence) { ActiveFedora::Base.new }
|
7
7
|
it { is_expected.to be_new_record }
|
8
8
|
end
|
9
9
|
|
10
10
|
context 'with an destroyed object' do
|
11
|
-
subject { ActiveFedora::Base.create }
|
12
|
-
before {
|
11
|
+
subject(:persistence) { ActiveFedora::Base.create }
|
12
|
+
before { persistence.delete }
|
13
13
|
it { is_expected.not_to be_new_record }
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
describe '.delete' do
|
18
18
|
context 'with an unsaved object' do
|
19
|
-
subject { ActiveFedora::Base.new }
|
20
|
-
before {
|
21
|
-
it { is_expected.to eq
|
19
|
+
subject(:persistence) { ActiveFedora::Base.new }
|
20
|
+
before { persistence.delete }
|
21
|
+
it { is_expected.to eq persistence }
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'with a saved object' do
|
25
|
-
subject { ActiveFedora::Base.create! }
|
26
|
-
before {
|
25
|
+
subject(:persistence) { ActiveFedora::Base.create! }
|
26
|
+
before { persistence.delete }
|
27
27
|
it { is_expected.to be_frozen }
|
28
28
|
end
|
29
29
|
end
|
@@ -46,68 +46,68 @@ describe ActiveFedora::Persistence do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
describe '.destroy' do
|
49
|
-
subject { ActiveFedora::Base.create! }
|
49
|
+
subject(:persistence) { ActiveFedora::Base.create! }
|
50
50
|
context 'with no options' do
|
51
|
-
before {
|
51
|
+
before { persistence.destroy }
|
52
52
|
it 'does not clear the id' do
|
53
|
-
expect(
|
53
|
+
expect(persistence.id).not_to be_nil
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
context 'with option eradicate: true' do
|
58
58
|
it 'deletes the tombstone' do
|
59
|
-
expect(
|
60
|
-
|
59
|
+
expect(persistence.class).to receive(:eradicate).with(persistence.id).and_return(true)
|
60
|
+
persistence.destroy(eradicate: true)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
describe "save" do
|
66
|
-
subject { ActiveFedora::Base.new }
|
66
|
+
subject(:persistence) { ActiveFedora::Base.new }
|
67
67
|
|
68
68
|
context "when called with option update_index: false" do
|
69
69
|
context "on a new record" do
|
70
70
|
it "does not update the index" do
|
71
|
-
expect(
|
72
|
-
|
71
|
+
expect(persistence).to_not receive(:update_index)
|
72
|
+
persistence.save(update_index: false)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
context "on a persisted record" do
|
77
77
|
before do
|
78
|
-
allow(
|
78
|
+
allow(persistence).to receive(:new_record?) { false }
|
79
79
|
allow_any_instance_of(Ldp::Orm).to receive(:save) { true }
|
80
|
-
allow(
|
80
|
+
allow(persistence).to receive(:update_modified_date)
|
81
81
|
end
|
82
82
|
|
83
83
|
it "does not update the index" do
|
84
|
-
expect(
|
85
|
-
|
84
|
+
expect(persistence).to_not receive(:update_index)
|
85
|
+
persistence.save(update_index: false)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
context "when called with option :update_index=>true" do
|
91
91
|
context "on create" do
|
92
|
-
before { allow(
|
92
|
+
before { allow(persistence).to receive(:create_needs_index?) { false } }
|
93
93
|
|
94
94
|
it "does not override `create_needs_index?'" do
|
95
|
-
expect(
|
96
|
-
|
95
|
+
expect(persistence).to_not receive(:update_index)
|
96
|
+
persistence.save(update_index: true)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
context "on update" do
|
101
101
|
before do
|
102
|
-
allow(
|
102
|
+
allow(persistence).to receive(:new_record?) { false }
|
103
103
|
allow_any_instance_of(Ldp::Orm).to receive(:save) { true }
|
104
|
-
allow(
|
105
|
-
allow(
|
104
|
+
allow(persistence).to receive(:update_needs_index?) { false }
|
105
|
+
allow(persistence).to receive(:update_modified_date)
|
106
106
|
end
|
107
107
|
|
108
108
|
it "does not override `update_needs_index?'" do
|
109
|
-
expect(
|
110
|
-
|
109
|
+
expect(persistence).to_not receive(:update_index)
|
110
|
+
persistence.save(update_index: true)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
@@ -99,21 +99,21 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
|
|
99
99
|
end
|
100
100
|
|
101
101
|
describe 'custom fields' do
|
102
|
-
subject { described_class.new }
|
102
|
+
subject(:datastream) { described_class.new }
|
103
103
|
it 'grabs the term' do
|
104
104
|
sample_xml = "<dc xmlns:dcterms='http://purl.org/dc/terms/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><dcterms:cust>custom</dcterms:cust></dc>"
|
105
|
-
|
106
|
-
|
107
|
-
expect(
|
105
|
+
datastream.content = sample_xml
|
106
|
+
datastream.field :cust
|
107
|
+
expect(datastream.cust).to eq ['custom']
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
111
|
describe "#field should accept :path option" do
|
112
|
-
subject { described_class.new }
|
112
|
+
subject(:datastream) { described_class.new }
|
113
113
|
it "is able to map :dc_type to the path 'type'" do
|
114
|
-
|
115
|
-
|
116
|
-
expect(
|
114
|
+
datastream.content = sample_xml
|
115
|
+
datastream.field :dc_type, :string, path: "type", multiple: true
|
116
|
+
expect(datastream.dc_type).to eq ['sound']
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
data/spec/unit/query_spec.rb
CHANGED
@@ -244,7 +244,7 @@ describe ActiveFedora::Base do
|
|
244
244
|
describe '#search_with_conditions' do
|
245
245
|
let(:mock_result) { double('Result') }
|
246
246
|
let(:klass) { SpecModel::Basic }
|
247
|
-
subject { klass.search_with_conditions(conditions) }
|
247
|
+
subject(:search_with_conditions) { klass.search_with_conditions(conditions) }
|
248
248
|
|
249
249
|
before do
|
250
250
|
expect(ActiveFedora::SolrService).to receive(:query)
|
@@ -259,7 +259,7 @@ describe ActiveFedora::Base do
|
|
259
259
|
let(:conditions) { { foo: 'bar', baz: ['quix', 'quack'] } }
|
260
260
|
|
261
261
|
it "makes a query to solr and returns the results" do
|
262
|
-
expect(
|
262
|
+
expect(search_with_conditions).to eq mock_result
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
@@ -271,7 +271,7 @@ describe ActiveFedora::Base do
|
|
271
271
|
let(:conditions) { { foo: '9" Nails', baz: ['7" version', 'quack'] } }
|
272
272
|
|
273
273
|
it "escapes quotes" do
|
274
|
-
expect(
|
274
|
+
expect(search_with_conditions).to eq mock_result
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
@@ -282,7 +282,7 @@ describe ActiveFedora::Base do
|
|
282
282
|
let(:conditions) { { baz: 'quack' } }
|
283
283
|
let(:expected_query) { "_query_:\"{!field f=baz}quack\"" }
|
284
284
|
it "doesn't use the class if it's called on AF:Base " do
|
285
|
-
expect(
|
285
|
+
expect(search_with_conditions).to eq mock_result
|
286
286
|
end
|
287
287
|
end
|
288
288
|
|
@@ -290,7 +290,7 @@ describe ActiveFedora::Base do
|
|
290
290
|
let(:conditions) { 'chunky:monkey' }
|
291
291
|
let(:expected_query) { '(chunky:monkey)' }
|
292
292
|
it "uses the query string if it's provided and wrap it in parentheses" do
|
293
|
-
expect(
|
293
|
+
expect(search_with_conditions).to eq mock_result
|
294
294
|
end
|
295
295
|
end
|
296
296
|
end
|
@@ -57,27 +57,27 @@ describe ActiveFedora::RDF::IndexingService do
|
|
57
57
|
let(:indexer) { described_class.new(f2) }
|
58
58
|
|
59
59
|
describe "#generate_solr_document" do
|
60
|
-
|
60
|
+
let(:solr_obj) { indexer.generate_solr_document(lambda { |key| "solr_rdf__#{key}" }) }
|
61
61
|
it "returns the right fields" do
|
62
|
-
expect(
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
62
|
+
expect(solr_obj.keys).to include(ActiveFedora.index_field_mapper.solr_name("solr_rdf__related_url", type: :string),
|
63
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", type: :string),
|
64
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :sortable),
|
65
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :facetable),
|
66
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__created", :sortable, type: :date),
|
67
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__created", :displayable),
|
68
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__title", type: :string),
|
69
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__title", :sortable),
|
70
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", type: :string),
|
71
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", :facetable))
|
72
72
|
end
|
73
73
|
|
74
74
|
it "returns the right values" do
|
75
|
-
expect(
|
76
|
-
expect(
|
77
|
-
expect(
|
78
|
-
expect(
|
79
|
-
expect(
|
80
|
-
expect(
|
75
|
+
expect(solr_obj[ActiveFedora.index_field_mapper.solr_name("solr_rdf__related_url", type: :string)]).to eq ["http://example.org/blogtastic/"]
|
76
|
+
expect(solr_obj[ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", type: :string)]).to contain_exactly "Tacoma, WA", "Renton, WA"
|
77
|
+
expect(solr_obj[ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", :facetable)]).to contain_exactly "Tacoma, WA", "Renton, WA"
|
78
|
+
expect(solr_obj[ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", type: :string)]).to eq ["Bob's Blogtastic Publishing"]
|
79
|
+
expect(solr_obj[ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :sortable)]).to eq "Bob's Blogtastic Publishing"
|
80
|
+
expect(solr_obj[ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :facetable)]).to eq ["Bob's Blogtastic Publishing"]
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -27,22 +27,22 @@ describe ActiveFedora::RDFDatastream do
|
|
27
27
|
Object.send(:remove_const, :MyObj)
|
28
28
|
end
|
29
29
|
|
30
|
-
subject { @obj.reload.descMetadata }
|
30
|
+
subject(:desc_metadata) { @obj.reload.descMetadata }
|
31
31
|
|
32
32
|
it "does not load the descMetadata datastream when calling content_changed?" do
|
33
|
-
expect(
|
34
|
-
expect(
|
33
|
+
expect(desc_metadata).to_not receive(:retrieve_content)
|
34
|
+
expect(desc_metadata).to_not be_content_changed
|
35
35
|
end
|
36
36
|
|
37
37
|
it "allows asserting an empty string" do
|
38
|
-
|
39
|
-
expect(
|
38
|
+
desc_metadata.title = ['']
|
39
|
+
expect(desc_metadata.title).to eq ['']
|
40
40
|
end
|
41
41
|
|
42
42
|
it "clears stuff" do
|
43
|
-
|
44
|
-
|
45
|
-
expect(
|
43
|
+
desc_metadata.title = ['one', 'two', 'three']
|
44
|
+
desc_metadata.title.clear
|
45
|
+
expect(desc_metadata.graph.query([desc_metadata.rdf_subject, ::RDF::Vocab::DC.title, nil]).first).to be_nil
|
46
46
|
end
|
47
47
|
|
48
48
|
it "has a list of fields" do
|
@@ -51,12 +51,12 @@ describe ActiveFedora::RDFDatastream do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "deserialize" do
|
54
|
-
subject { ActiveFedora::NtriplesRDFDatastream.new }
|
54
|
+
subject(:datastream) { ActiveFedora::NtriplesRDFDatastream.new }
|
55
55
|
it "is able to handle non-utf-8 characters" do
|
56
56
|
# see https://github.com/ruby-rdf/rdf/issues/142
|
57
57
|
data = "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT')
|
58
58
|
|
59
|
-
result =
|
59
|
+
result = datastream.deserialize(data)
|
60
60
|
expect(result.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
61
61
|
end
|
62
62
|
end
|
@@ -29,49 +29,49 @@ describe ActiveFedora::RDFDatastream do
|
|
29
29
|
Object.send(:remove_const, "DummySubnode")
|
30
30
|
end
|
31
31
|
|
32
|
-
subject { DummyResource.new("#{ActiveFedora.fedora.host}/test/test:1") }
|
32
|
+
subject(:resource) { DummyResource.new("#{ActiveFedora.fedora.host}/test/test:1") }
|
33
33
|
|
34
34
|
describe "attribute setting" do
|
35
35
|
context "on text attributes" do
|
36
36
|
before do
|
37
|
-
|
37
|
+
resource.title = "bla"
|
38
38
|
end
|
39
39
|
|
40
40
|
it "lets you access" do
|
41
|
-
expect(
|
41
|
+
expect(resource.title).to eq ["bla"]
|
42
42
|
end
|
43
43
|
|
44
44
|
it "marks it as changed" do
|
45
|
-
expect(
|
45
|
+
expect(resource).to be_changed
|
46
46
|
end
|
47
47
|
|
48
48
|
context "after it is persisted" do
|
49
49
|
before do
|
50
|
-
|
51
|
-
|
50
|
+
resource.save
|
51
|
+
resource.reload
|
52
52
|
end
|
53
53
|
|
54
54
|
it "is persisted" do
|
55
|
-
expect(
|
55
|
+
expect(resource.resource).to be_persisted
|
56
56
|
end
|
57
57
|
|
58
58
|
context "and it's reloaded" do
|
59
59
|
before do
|
60
|
-
|
60
|
+
resource.reload
|
61
61
|
end
|
62
62
|
|
63
63
|
it "is accessible after being saved" do
|
64
|
-
expect(
|
64
|
+
expect(resource.title).to eq ["bla"]
|
65
65
|
end
|
66
66
|
|
67
67
|
it "serializes to content" do
|
68
|
-
expect(
|
68
|
+
expect(resource.content).not_to be_blank
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
context "and it is found again" do
|
73
73
|
before do
|
74
|
-
@object = DummyResource.new(
|
74
|
+
@object = DummyResource.new(resource.uri)
|
75
75
|
end
|
76
76
|
|
77
77
|
it "serializes to content" do
|
@@ -94,15 +94,15 @@ describe ActiveFedora::RDFDatastream do
|
|
94
94
|
before do
|
95
95
|
dummy = DummySubnode.new
|
96
96
|
dummy.title = 'subbla'
|
97
|
-
|
97
|
+
resource.license = dummy
|
98
98
|
end
|
99
99
|
|
100
100
|
it "lets you access" do
|
101
|
-
expect(
|
101
|
+
expect(resource.license.first.title).to eq ['subbla']
|
102
102
|
end
|
103
103
|
|
104
104
|
it "marks it as changed" do
|
105
|
-
expect(
|
105
|
+
expect(resource).to be_changed
|
106
106
|
end
|
107
107
|
end
|
108
108
|
context "persisted to repository" do
|
@@ -113,15 +113,15 @@ describe ActiveFedora::RDFDatastream do
|
|
113
113
|
# We want to have to manually persist to the repository.
|
114
114
|
# Parent objects shouldn't be persisting children they share with other parents
|
115
115
|
dummy.persist!
|
116
|
-
|
116
|
+
resource.license = dummy
|
117
117
|
end
|
118
118
|
|
119
119
|
it "lets you access" do
|
120
|
-
expect(
|
120
|
+
expect(resource.license.first.title).to eq ['subbla']
|
121
121
|
end
|
122
122
|
|
123
123
|
it "marks it as changed" do
|
124
|
-
expect(
|
124
|
+
expect(resource).to be_changed
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
@@ -130,28 +130,28 @@ describe ActiveFedora::RDFDatastream do
|
|
130
130
|
describe "relationships" do
|
131
131
|
before do
|
132
132
|
@new_object = DummyAsset.create(something: ["subbla"])
|
133
|
-
|
134
|
-
|
133
|
+
resource.title = ["bla"]
|
134
|
+
resource.creator = @new_object
|
135
135
|
end
|
136
136
|
|
137
137
|
it "can set sub-properties to AF objects" do
|
138
|
-
expect(
|
138
|
+
expect(resource.creator).to eq [@new_object]
|
139
139
|
end
|
140
140
|
|
141
141
|
it "has accessible relationship attributes" do
|
142
|
-
expect(
|
142
|
+
expect(resource.creator.first.something).to eq ["subbla"]
|
143
143
|
end
|
144
144
|
|
145
145
|
it "lets me get to an AF:Base object" do
|
146
|
-
|
147
|
-
|
148
|
-
expect(
|
146
|
+
resource.save
|
147
|
+
new_resource = DummyResource.new(resource.uri)
|
148
|
+
expect(new_resource.creator.first).to be_kind_of(ActiveFedora::Base)
|
149
149
|
end
|
150
150
|
|
151
151
|
context "when the AF:Base object is deleted" do
|
152
152
|
before do
|
153
|
-
|
154
|
-
@resource = DummyResource.new(
|
153
|
+
resource.save
|
154
|
+
@resource = DummyResource.new(resource.uri)
|
155
155
|
@new_object.destroy
|
156
156
|
end
|
157
157
|
it "gives back an ActiveTriples::Resource" do
|
@@ -161,8 +161,8 @@ describe ActiveFedora::RDFDatastream do
|
|
161
161
|
end
|
162
162
|
|
163
163
|
it "allows for deep attributes to be set directly" do
|
164
|
-
|
165
|
-
expect(
|
164
|
+
resource.creator.first.something = ["Bla"]
|
165
|
+
expect(resource.creator.first.something).to eq ["Bla"]
|
166
166
|
end
|
167
167
|
|
168
168
|
context "when the subject is set with base_uri" do
|
@@ -171,37 +171,37 @@ describe ActiveFedora::RDFDatastream do
|
|
171
171
|
DummyResource.resource_class.configure base_uri: 'http://example.org/'
|
172
172
|
new_object = DummyAsset.new
|
173
173
|
new_object.save
|
174
|
-
|
174
|
+
resource.creator = new_object
|
175
175
|
end
|
176
176
|
after do
|
177
177
|
DummyResource.resource_class.configure base_uri: @old_uri
|
178
178
|
end
|
179
179
|
|
180
180
|
it "lets me get to an AF:Base object" do
|
181
|
-
|
182
|
-
|
183
|
-
expect(
|
181
|
+
resource.save
|
182
|
+
new_resource = DummyResource.new(resource.uri)
|
183
|
+
expect(new_resource.creator.first).to be_kind_of(ActiveFedora::Base)
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
187
|
context "when the object with a relationship is saved" do
|
188
188
|
before do
|
189
|
-
|
189
|
+
resource.save
|
190
190
|
end
|
191
191
|
|
192
192
|
it "is retrievable" do
|
193
|
-
expect(
|
193
|
+
expect(resource.creator.first.something).to eq ["subbla"]
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
197
|
context "when the object with a relationship is frozen" do
|
198
198
|
before do
|
199
|
-
|
200
|
-
|
199
|
+
resource.save
|
200
|
+
resource.freeze
|
201
201
|
end
|
202
202
|
|
203
203
|
it "is retrievable" do
|
204
|
-
expect(
|
204
|
+
expect(resource.creator.first.something).to eq ["subbla"]
|
205
205
|
end
|
206
206
|
end
|
207
207
|
end
|