active-fedora 6.7.8 → 6.8.0
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/.rspec +1 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +938 -0
- data/.travis.yml +5 -6
- data/Gemfile +3 -1
- data/Rakefile +7 -5
- data/active-fedora.gemspec +7 -8
- data/lib/active_fedora/om_datastream.rb +1 -0
- data/lib/active_fedora/rdf_xml_writer.rb +31 -62
- data/lib/active_fedora/version.rb +1 -1
- data/spec/config_helper.rb +14 -14
- data/spec/integration/associations_spec.rb +232 -232
- data/spec/integration/attributes_spec.rb +11 -12
- data/spec/integration/auditable_spec.rb +10 -10
- data/spec/integration/base_spec.rb +163 -163
- data/spec/integration/bug_spec.rb +7 -7
- data/spec/integration/complex_rdf_datastream_spec.rb +88 -88
- data/spec/integration/datastream_collections_spec.rb +69 -69
- data/spec/integration/datastream_spec.rb +43 -43
- data/spec/integration/datastreams_spec.rb +63 -63
- data/spec/integration/delegating_spec.rb +14 -14
- data/spec/integration/delete_all_spec.rb +38 -42
- data/spec/integration/fedora_solr_sync_spec.rb +5 -5
- data/spec/integration/full_featured_model_spec.rb +101 -101
- data/spec/integration/has_many_associations_spec.rb +24 -24
- data/spec/integration/model_spec.rb +30 -30
- data/spec/integration/nested_attribute_spec.rb +41 -41
- data/spec/integration/ntriples_datastream_spec.rb +107 -107
- data/spec/integration/om_datastream_spec.rb +67 -67
- data/spec/integration/persistence_spec.rb +6 -6
- data/spec/integration/rdf_nested_attributes_spec.rb +56 -56
- data/spec/integration/relation_delegation_spec.rb +24 -26
- data/spec/integration/rels_ext_datastream_spec.rb +20 -20
- data/spec/integration/scoped_query_spec.rb +40 -41
- data/spec/integration/solr_instance_loader_spec.rb +4 -4
- data/spec/integration/solr_service_spec.rb +46 -46
- data/spec/rails3_test_app/config/application.rb +1 -1
- data/spec/rails3_test_app/config/environments/development.rb +0 -1
- data/spec/rails3_test_app/config/environments/production.rb +1 -1
- data/spec/rails3_test_app/spec/spec_helper.rb +3 -3
- data/spec/rails3_test_app/spec/unit/rails_3_init.rb +4 -4
- data/spec/samples/hydra-mods_article_datastream.rb +334 -334
- data/spec/samples/hydra-rights_metadata_datastream.rb +57 -57
- data/spec/samples/marpa-dc_datastream.rb +17 -17
- data/spec/samples/models/audio_record.rb +16 -16
- data/spec/samples/models/image.rb +2 -2
- data/spec/samples/models/mods_article.rb +5 -5
- data/spec/samples/models/oral_history.rb +18 -18
- data/spec/samples/models/seminar.rb +24 -24
- data/spec/samples/models/seminar_audio_file.rb +17 -17
- data/spec/samples/oral_history_sample_model.rb +21 -21
- data/spec/samples/special_thing.rb +14 -14
- data/spec/spec_helper.rb +7 -11
- data/spec/support/an_active_model.rb +2 -2
- data/spec/support/mock_fedora.rb +16 -17
- data/spec/unit/active_fedora_spec.rb +58 -58
- data/spec/unit/association_proxy_spec.rb +5 -7
- data/spec/unit/base_active_model_spec.rb +25 -26
- data/spec/unit/base_cma_spec.rb +5 -5
- data/spec/unit/base_datastream_management_spec.rb +27 -27
- data/spec/unit/base_delegate_spec.rb +80 -82
- data/spec/unit/base_delegate_to_spec.rb +37 -39
- data/spec/unit/base_extra_spec.rb +48 -48
- data/spec/unit/base_spec.rb +300 -300
- data/spec/unit/callback_spec.rb +19 -19
- data/spec/unit/code_configurator_spec.rb +17 -17
- data/spec/unit/config_spec.rb +16 -8
- data/spec/unit/content_model_spec.rb +60 -60
- data/spec/unit/datastream_collections_spec.rb +229 -229
- data/spec/unit/datastream_spec.rb +57 -54
- data/spec/unit/datastreams_spec.rb +77 -77
- data/spec/unit/file_configurator_spec.rb +217 -217
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +26 -26
- data/spec/unit/has_many_collection_spec.rb +9 -9
- data/spec/unit/inheritance_spec.rb +12 -13
- data/spec/unit/model_spec.rb +41 -51
- data/spec/unit/nom_datastream_spec.rb +15 -15
- data/spec/unit/ntriples_datastream_spec.rb +112 -112
- data/spec/unit/om_datastream_spec.rb +233 -227
- data/spec/unit/persistence_spec.rb +6 -6
- data/spec/unit/predicates_spec.rb +73 -73
- data/spec/unit/property_spec.rb +9 -17
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +33 -33
- data/spec/unit/query_spec.rb +188 -217
- data/spec/unit/rdf_datastream_spec.rb +28 -21
- data/spec/unit/rdf_list_nested_attributes_spec.rb +34 -34
- data/spec/unit/rdf_list_spec.rb +80 -104
- data/spec/unit/rdf_node_spec.rb +7 -7
- data/spec/unit/rdf_xml_writer_spec.rb +10 -10
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +27 -27
- data/spec/unit/relationship_graph_spec.rb +51 -51
- data/spec/unit/rels_ext_datastream_spec.rb +75 -69
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +12 -12
- data/spec/unit/rubydora_connection_spec.rb +5 -5
- data/spec/unit/semantic_node_spec.rb +59 -59
- data/spec/unit/serializers_spec.rb +4 -4
- data/spec/unit/service_definitions_spec.rb +26 -26
- data/spec/unit/simple_datastream_spec.rb +17 -17
- data/spec/unit/solr_config_options_spec.rb +27 -28
- data/spec/unit/solr_digital_object_spec.rb +21 -21
- data/spec/unit/solr_service_spec.rb +81 -81
- data/spec/unit/unsaved_digital_object_spec.rb +20 -20
- data/spec/unit/validations_spec.rb +21 -21
- metadata +70 -58
- data/gemfiles/gemfile.rails3 +0 -11
- data/gemfiles/gemfile.rails4 +0 -10
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
require 'active_fedora'
|
|
4
|
-
require
|
|
4
|
+
require 'nokogiri'
|
|
5
5
|
|
|
6
6
|
describe ActiveFedora::Datastream do
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
before(:each) do
|
|
9
9
|
@test_object = ActiveFedora::Base.new
|
|
10
10
|
@test_datastream = ActiveFedora::Datastream.new(@test_object.inner_object, 'abcd')
|
|
11
|
-
@test_datastream.content =
|
|
11
|
+
@test_datastream.content = 'hi there'
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
describe '#metadata?' do
|
|
15
|
+
subject { super().metadata? }
|
|
16
|
+
it { is_expected.to be_falsey}
|
|
17
|
+
end
|
|
15
18
|
|
|
16
|
-
it
|
|
17
|
-
@test_datastream.
|
|
18
|
-
@test_datastream.to_param.
|
|
19
|
+
it 'should escape dots in to_param' do
|
|
20
|
+
allow(@test_datastream).to receive(:dsid).and_return('foo.bar')
|
|
21
|
+
expect(@test_datastream.to_param).to eq('foo%2ebar')
|
|
19
22
|
end
|
|
20
|
-
|
|
21
|
-
it
|
|
22
|
-
@test_datastream.inspect.
|
|
23
|
+
|
|
24
|
+
it 'should be inspectable' do
|
|
25
|
+
expect(@test_datastream.inspect).to match /#<ActiveFedora::Datastream @pid=\"\" @dsid=\"abcd\" @controlGroup=\"M\" changed=\"true\" @mimeType=\"\" >/
|
|
23
26
|
end
|
|
24
27
|
|
|
25
28
|
describe '#validate_content_present' do
|
|
@@ -28,65 +31,65 @@ describe ActiveFedora::Datastream do
|
|
|
28
31
|
@test_datastream.dsLocation = nil
|
|
29
32
|
end
|
|
30
33
|
|
|
31
|
-
it
|
|
34
|
+
it 'should expect content on an Inline (X) datastream' do
|
|
32
35
|
@test_datastream.controlGroup = 'X'
|
|
33
|
-
@test_datastream.dsLocation =
|
|
34
|
-
@test_datastream.validate_content_present.
|
|
35
|
-
@test_datastream.content =
|
|
36
|
-
@test_datastream.validate_content_present.
|
|
36
|
+
@test_datastream.dsLocation = 'http://example.com/test/content/abcd'
|
|
37
|
+
expect(@test_datastream.validate_content_present).to be_falsey
|
|
38
|
+
@test_datastream.content = '<foo><xmlelement/></foo>'
|
|
39
|
+
expect(@test_datastream.validate_content_present).to be_truthy
|
|
37
40
|
end
|
|
38
41
|
|
|
39
|
-
context
|
|
42
|
+
context 'on a Managed (M) datastream' do
|
|
40
43
|
before { @test_datastream.controlGroup = 'M' }
|
|
41
|
-
it
|
|
42
|
-
@test_datastream.validate_content_present.
|
|
44
|
+
it 'should be false when neither dsLocation nor content is present' do
|
|
45
|
+
expect(@test_datastream.validate_content_present).to be_falsey
|
|
43
46
|
end
|
|
44
|
-
it
|
|
45
|
-
@test_datastream.dsLocation =
|
|
46
|
-
@test_datastream.validate_content_present.
|
|
47
|
+
it 'should be true when dsLocation is present' do
|
|
48
|
+
@test_datastream.dsLocation = 'http://example.com/test/content/abcd'
|
|
49
|
+
expect(@test_datastream.validate_content_present).to be_truthy
|
|
47
50
|
end
|
|
48
|
-
it
|
|
49
|
-
@test_datastream.content =
|
|
50
|
-
@test_datastream.validate_content_present.
|
|
51
|
+
it 'should be true when content is present' do
|
|
52
|
+
@test_datastream.content = '<foo><xmlelement/></foo>'
|
|
53
|
+
expect(@test_datastream.validate_content_present).to be_truthy
|
|
51
54
|
end
|
|
52
55
|
end
|
|
53
56
|
|
|
54
|
-
it
|
|
57
|
+
it 'should expect a dsLocation on an External (E) datastream' do
|
|
55
58
|
@test_datastream.controlGroup = 'E'
|
|
56
|
-
@test_datastream.content =
|
|
57
|
-
@test_datastream.validate_content_present.
|
|
58
|
-
@test_datastream.dsLocation =
|
|
59
|
-
@test_datastream.validate_content_present.
|
|
60
|
-
@test_datastream.
|
|
59
|
+
@test_datastream.content = '<foo><xmlelement/></foo>'
|
|
60
|
+
expect(@test_datastream.validate_content_present).to be_falsey
|
|
61
|
+
@test_datastream.dsLocation = 'http://example.com/test/content/abcd'
|
|
62
|
+
expect(@test_datastream.validate_content_present).to be_truthy
|
|
63
|
+
expect(@test_datastream).to be_external
|
|
61
64
|
end
|
|
62
65
|
|
|
63
|
-
it
|
|
66
|
+
it 'should expect a dsLocation on a Redirect (R) datastream' do
|
|
64
67
|
@test_datastream.controlGroup = 'R'
|
|
65
|
-
@test_datastream.content =
|
|
66
|
-
@test_datastream.validate_content_present.
|
|
67
|
-
@test_datastream.dsLocation =
|
|
68
|
-
@test_datastream.validate_content_present.
|
|
68
|
+
@test_datastream.content = '<foo><xmlelement/></foo>'
|
|
69
|
+
expect(@test_datastream.validate_content_present).to be_falsey
|
|
70
|
+
@test_datastream.dsLocation = 'http://example.com/test/content/abcd'
|
|
71
|
+
expect(@test_datastream.validate_content_present).to be_truthy
|
|
69
72
|
end
|
|
70
73
|
end
|
|
71
|
-
|
|
72
|
-
it
|
|
74
|
+
|
|
75
|
+
it 'should have mimeType accessors' do
|
|
73
76
|
ds1 = ActiveFedora::Datastream.new
|
|
74
|
-
ds1.mimeType =
|
|
75
|
-
ds1.mimeType.
|
|
77
|
+
ds1.mimeType = 'text/foo'
|
|
78
|
+
expect(ds1.mimeType).to eq('text/foo')
|
|
76
79
|
ds2 = ActiveFedora::Datastream.new
|
|
77
|
-
ds2.mimeType =
|
|
78
|
-
ds2.mimeType.
|
|
80
|
+
ds2.mimeType = 'text/bar'
|
|
81
|
+
expect(ds2.mimeType).to eq('text/bar')
|
|
79
82
|
end
|
|
80
83
|
|
|
81
|
-
describe
|
|
82
|
-
it
|
|
84
|
+
describe '.size' do
|
|
85
|
+
it 'should lazily load the datastream size attribute from the fedora repository' do
|
|
83
86
|
ds_profile = <<-EOS
|
|
84
|
-
<datastreamProfile
|
|
85
|
-
xmlns=\"http://www.fedora.info/definitions/1/0/management/\"
|
|
86
|
-
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
|
|
87
|
-
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
|
|
88
|
-
xsi:schemaLocation=\"http://www.fedora.info/definitions/1/0/management/ http://www.fedora.info/definitions/1/0/datastreamProfile.xsd\"
|
|
89
|
-
pid=\"#{@test_object.pid}\"
|
|
87
|
+
<datastreamProfile
|
|
88
|
+
xmlns=\"http://www.fedora.info/definitions/1/0/management/\"
|
|
89
|
+
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
|
|
90
|
+
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
|
|
91
|
+
xsi:schemaLocation=\"http://www.fedora.info/definitions/1/0/management/ http://www.fedora.info/definitions/1/0/datastreamProfile.xsd\"
|
|
92
|
+
pid=\"#{@test_object.pid}\"
|
|
90
93
|
dsID=\"#{@test_datastream.dsid}\" >
|
|
91
94
|
<dsLabel></dsLabel>
|
|
92
95
|
<dsVersionID>#{@test_datastream.dsid}.1</dsVersionID>
|
|
@@ -106,13 +109,13 @@ describe ActiveFedora::Datastream do
|
|
|
106
109
|
EOS
|
|
107
110
|
|
|
108
111
|
mock_repo = Rubydora::Repository.new
|
|
109
|
-
@test_object.inner_object.
|
|
110
|
-
mock_repo.api.
|
|
111
|
-
@test_datastream.size.
|
|
112
|
+
allow(@test_object.inner_object).to receive(:repository).and_return(mock_repo)
|
|
113
|
+
expect(mock_repo.api).to receive(:datastream).with(:dsid => 'abcd', :pid => @test_object.pid).and_return(ds_profile)
|
|
114
|
+
expect(@test_datastream.size).to eq(9999)
|
|
112
115
|
end
|
|
113
116
|
|
|
114
|
-
it
|
|
115
|
-
@test_datastream.size.
|
|
117
|
+
it 'should default to an empty string if ds has not been saved' do
|
|
118
|
+
expect(@test_datastream.size).to be_nil
|
|
116
119
|
end
|
|
117
120
|
end
|
|
118
121
|
end
|
|
@@ -11,16 +11,16 @@ describe ActiveFedora::Datastreams do
|
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
it
|
|
15
|
-
FooHistory.ds_specs.
|
|
14
|
+
it 'should have a ds_specs entry' do
|
|
15
|
+
expect(FooHistory.ds_specs).to have_key('dsid')
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
it
|
|
19
|
-
FooHistory.ds_specs['dsid'].
|
|
18
|
+
it 'should have reasonable defaults' do
|
|
19
|
+
expect(FooHistory.ds_specs['dsid']).to include(:autocreate => false)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
it
|
|
23
|
-
FooHistory.ds_specs['complex_ds'].
|
|
22
|
+
it 'should let you override defaults' do
|
|
23
|
+
expect(FooHistory.ds_specs['complex_ds']).to include(:versionable => true, :autocreate => true, :type => 'Z', :label => 'My Label', :control_group => 'Z')
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -32,90 +32,90 @@ describe ActiveFedora::Datastreams do
|
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
it
|
|
36
|
-
FooHistory.ds_specs['dsid'].
|
|
37
|
-
FooHistory.ds_specs['another'].
|
|
35
|
+
it 'should have reasonable defaults' do
|
|
36
|
+
expect(FooHistory.ds_specs['dsid']).to include(:type => ActiveFedora::Datastream, :label => 'File Datastream', :control_group => 'M')
|
|
37
|
+
expect(FooHistory.ds_specs['another']).to include(:type => ActiveFedora::Datastream, :label => 'File Datastream', :control_group => 'M')
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
describe
|
|
42
|
-
it
|
|
41
|
+
describe '#serialize_datastreams' do
|
|
42
|
+
it 'should touch each datastream' do
|
|
43
43
|
m1 = double()
|
|
44
44
|
m2 = double()
|
|
45
45
|
|
|
46
|
-
m1.
|
|
47
|
-
m2.
|
|
46
|
+
expect(m1).to receive(:serialize!)
|
|
47
|
+
expect(m2).to receive(:serialize!)
|
|
48
48
|
subject.stub(:datastreams => { :m1 => m1, :m2 => m2})
|
|
49
49
|
subject.serialize_datastreams
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
describe
|
|
54
|
-
it
|
|
55
|
-
|
|
53
|
+
describe '#add_disseminator_location_to_datastreams' do
|
|
54
|
+
it 'should infer dsLocations for E datastreams without hitting Fedora' do
|
|
55
|
+
|
|
56
56
|
mock_specs = {:e => { :disseminator => 'xyz' }}
|
|
57
57
|
mock_ds = double(:controlGroup => 'E')
|
|
58
58
|
ActiveFedora::Base.stub(:ds_specs => mock_specs)
|
|
59
59
|
ActiveFedora.stub(:config_for_environment => { :url => 'http://localhost'})
|
|
60
60
|
subject.stub(:pid => 'test:1', :datastreams => {:e => mock_ds})
|
|
61
|
-
mock_ds.
|
|
61
|
+
expect(mock_ds).to receive(:dsLocation=).with('http://localhost/objects/test:1/methods/xyz')
|
|
62
62
|
subject.add_disseminator_location_to_datastreams
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
describe
|
|
66
|
+
describe '#corresponding_datastream_name' do
|
|
67
67
|
before(:each) do
|
|
68
68
|
subject.stub(:datastreams => { 'abc' => double(), 'a_b_c' => double(), 'a-b' => double()})
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
it
|
|
72
|
-
subject.corresponding_datastream_name('abc').
|
|
71
|
+
it 'should use the name, if it exists' do
|
|
72
|
+
expect(subject.corresponding_datastream_name('abc')).to eq('abc')
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
it
|
|
76
|
-
subject.corresponding_datastream_name('a_b').
|
|
75
|
+
it 'should hash-erize underscores' do
|
|
76
|
+
expect(subject.corresponding_datastream_name('a_b')).to eq('a-b')
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
it
|
|
80
|
-
subject.corresponding_datastream_name('xyz').
|
|
79
|
+
it 'should return nil if nothing matches' do
|
|
80
|
+
expect(subject.corresponding_datastream_name('xyz')).to be_nil
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
|
-
|
|
84
|
-
describe
|
|
85
|
-
it
|
|
86
|
-
subject.
|
|
87
|
-
subject.datastreams.
|
|
83
|
+
|
|
84
|
+
describe '#datastreams' do
|
|
85
|
+
it 'should return the datastream hash proxy' do
|
|
86
|
+
allow(subject).to receive(:load_datastreams)
|
|
87
|
+
expect(subject.datastreams).to be_a_kind_of(ActiveFedora::DatastreamHash)
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
it
|
|
91
|
-
YAML.load(subject.datastreams.to_yaml).inspect.
|
|
90
|
+
it 'should round-trip to/from YAML' do
|
|
91
|
+
expect(YAML.load(subject.datastreams.to_yaml).inspect).to eq(subject.datastreams.inspect)
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
describe
|
|
96
|
-
it
|
|
95
|
+
describe '#configure_datastream' do
|
|
96
|
+
it 'should look up the ds_spec' do
|
|
97
97
|
mock_dsspec = { :type => nil }
|
|
98
98
|
subject.stub(:ds_specs => {'abc' => mock_dsspec})
|
|
99
99
|
subject.configure_datastream(double(:dsid => 'abc'))
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
-
it
|
|
102
|
+
it 'should be ok if there is no ds spec' do
|
|
103
103
|
mock_dsspec = double()
|
|
104
104
|
subject.stub(:ds_specs => {})
|
|
105
105
|
subject.configure_datastream(double(:dsid => 'abc'))
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
-
it
|
|
108
|
+
it 'should configure RelsExtDatastream' do
|
|
109
109
|
mock_dsspec = { :type => ActiveFedora::RelsExtDatastream }
|
|
110
110
|
subject.stub(:ds_specs => {'abc' => mock_dsspec})
|
|
111
111
|
|
|
112
112
|
ds = double(:dsid => 'abc')
|
|
113
|
-
ds.
|
|
113
|
+
expect(ds).to receive(:model=).with(subject)
|
|
114
114
|
|
|
115
115
|
subject.configure_datastream(ds)
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
-
it
|
|
118
|
+
it 'should run a Proc' do
|
|
119
119
|
ds = double(:dsid => 'abc')
|
|
120
120
|
@count = 0
|
|
121
121
|
mock_dsspec = { :block => lambda { |x| @count += 1 } }
|
|
@@ -128,110 +128,110 @@ describe ActiveFedora::Datastreams do
|
|
|
128
128
|
end
|
|
129
129
|
end
|
|
130
130
|
|
|
131
|
-
describe
|
|
132
|
-
it
|
|
133
|
-
subject.inner_object.
|
|
131
|
+
describe '#datastream_from_spec' do
|
|
132
|
+
it 'should fetch the rubydora datastream' do
|
|
133
|
+
expect(subject.inner_object).to receive(:datastream_object_for).with('dsid', {}, {})
|
|
134
134
|
subject.datastream_from_spec({}, 'dsid')
|
|
135
135
|
end
|
|
136
136
|
end
|
|
137
137
|
|
|
138
|
-
describe
|
|
139
|
-
it
|
|
140
|
-
|
|
138
|
+
describe '#load_datastreams' do
|
|
139
|
+
it 'should load and configure persisted datastreams and should add any datastreams left over in the ds specs' do
|
|
140
|
+
skip
|
|
141
141
|
end
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
-
describe
|
|
145
|
-
it
|
|
144
|
+
describe '#add_datastream' do
|
|
145
|
+
it 'should add the datastream to the object' do
|
|
146
146
|
ds = double(:dsid => 'Abc')
|
|
147
147
|
subject.add_datastream(ds)
|
|
148
|
-
subject.datastreams['Abc'].
|
|
148
|
+
expect(subject.datastreams['Abc']).to eq(ds)
|
|
149
149
|
end
|
|
150
150
|
|
|
151
|
-
it
|
|
151
|
+
it 'should mint a dsid' do
|
|
152
152
|
ds = ActiveFedora::Datastream.new
|
|
153
|
-
subject.add_datastream(ds).
|
|
153
|
+
expect(subject.add_datastream(ds)).to eq('DS1')
|
|
154
154
|
end
|
|
155
155
|
end
|
|
156
156
|
|
|
157
|
-
describe
|
|
158
|
-
it
|
|
157
|
+
describe '#metadata_streams' do
|
|
158
|
+
it 'should only be metadata datastreams' do
|
|
159
159
|
ds1 = double(:metadata? => true)
|
|
160
160
|
ds2 = double(:metadata? => true)
|
|
161
161
|
ds3 = double(:metadata? => true)
|
|
162
162
|
relsextds = ActiveFedora::RelsExtDatastream.new
|
|
163
163
|
file_ds = double(:metadata? => false)
|
|
164
164
|
subject.stub(:datastreams => {:a => ds1, :b => ds2, :c => ds3, :d => relsextds, :e => file_ds})
|
|
165
|
-
subject.metadata_streams.
|
|
166
|
-
subject.metadata_streams.
|
|
167
|
-
subject.metadata_streams.
|
|
165
|
+
expect(subject.metadata_streams).to include(ds1, ds2, ds3)
|
|
166
|
+
expect(subject.metadata_streams).not_to include(relsextds)
|
|
167
|
+
expect(subject.metadata_streams).not_to include(file_ds)
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
170
|
|
|
171
|
-
describe
|
|
172
|
-
it
|
|
173
|
-
subject.generate_dsid('FOO').
|
|
171
|
+
describe '#generate_dsid' do
|
|
172
|
+
it 'should create an autoincrementing dsid' do
|
|
173
|
+
expect(subject.generate_dsid('FOO')).to eq('FOO1')
|
|
174
174
|
end
|
|
175
175
|
|
|
176
|
-
it
|
|
176
|
+
it 'should start from the highest existin dsid' do
|
|
177
177
|
subject.stub(:datastreams => {'FOO56' => double()})
|
|
178
|
-
subject.generate_dsid('FOO').
|
|
178
|
+
expect(subject.generate_dsid('FOO')).to eq('FOO57')
|
|
179
179
|
end
|
|
180
180
|
end
|
|
181
181
|
|
|
182
|
-
describe
|
|
183
|
-
it
|
|
182
|
+
describe '#relsext' do
|
|
183
|
+
it 'should be the RELS-EXT datastream' do
|
|
184
184
|
m = double
|
|
185
185
|
subject.stub(:datastreams => { 'RELS-EXT' => m})
|
|
186
|
-
subject.rels_ext.
|
|
186
|
+
expect(subject.rels_ext).to eq(m)
|
|
187
187
|
end
|
|
188
188
|
|
|
189
|
-
it
|
|
189
|
+
it 'should make one up otherwise' do
|
|
190
190
|
subject.stub(:datastreams => {})
|
|
191
191
|
|
|
192
|
-
subject.rels_ext.
|
|
192
|
+
expect(subject.rels_ext).to be_a_kind_of(ActiveFedora::RelsExtDatastream)
|
|
193
193
|
end
|
|
194
194
|
end
|
|
195
195
|
|
|
196
|
-
describe
|
|
196
|
+
describe '#add_file_datastream' do
|
|
197
197
|
# tested elsewhere :/
|
|
198
|
-
end
|
|
198
|
+
end
|
|
199
199
|
|
|
200
|
-
describe
|
|
201
|
-
it
|
|
200
|
+
describe '#create_datastream' do
|
|
201
|
+
it 'should mint a DSID' do
|
|
202
202
|
ds = subject.create_datastream(ActiveFedora::Datastream, nil, {})
|
|
203
|
-
ds.dsid.
|
|
203
|
+
expect(ds.dsid).to eq('DS1')
|
|
204
204
|
end
|
|
205
205
|
|
|
206
|
-
it
|
|
206
|
+
it 'should raise an argument error if the supplied dsid is nonsense' do
|
|
207
207
|
expect { subject.create_datastream(ActiveFedora::Datastream, 0) }.to raise_error(ArgumentError)
|
|
208
208
|
end
|
|
209
209
|
|
|
210
|
-
it
|
|
210
|
+
it 'should try to get a mime type from the blob' do
|
|
211
211
|
mock_file = double(:content_type => 'x-application/asdf')
|
|
212
212
|
ds = subject.create_datastream(ActiveFedora::Datastream, nil, {:blob => mock_file})
|
|
213
|
-
ds.mimeType.
|
|
213
|
+
expect(ds.mimeType).to eq('x-application/asdf')
|
|
214
214
|
end
|
|
215
215
|
|
|
216
|
-
it
|
|
216
|
+
it 'should provide a default mime type' do
|
|
217
217
|
mock_file = double()
|
|
218
218
|
ds = subject.create_datastream(ActiveFedora::Datastream, nil, {:blob => mock_file})
|
|
219
|
-
ds.mimeType.
|
|
219
|
+
expect(ds.mimeType).to eq('application/octet-stream')
|
|
220
220
|
end
|
|
221
221
|
|
|
222
|
-
it
|
|
222
|
+
it 'should use the filename as a default label' do
|
|
223
223
|
mock_file = double(:path => '/asdf/fdsa')
|
|
224
224
|
ds = subject.create_datastream(ActiveFedora::Datastream, nil, {:blob => mock_file})
|
|
225
|
-
ds.dsLabel.
|
|
225
|
+
expect(ds.dsLabel).to eq('fdsa')
|
|
226
226
|
end
|
|
227
227
|
end
|
|
228
228
|
|
|
229
|
-
describe
|
|
229
|
+
describe '#additional_attributes_for_external_and_redirect_control_groups' do
|
|
230
230
|
before(:all) do
|
|
231
231
|
@behavior = ActiveFedora::Datastreams.deprecation_behavior
|
|
232
232
|
ActiveFedora::Datastreams.deprecation_behavior = :silence
|
|
233
233
|
end
|
|
234
|
-
|
|
234
|
+
|
|
235
235
|
after :all do
|
|
236
236
|
ActiveFedora::Datastreams.deprecation_behavior = @behavior
|
|
237
237
|
end
|