active-fedora 8.2.1 → 8.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/active-fedora.gemspec +1 -2
- data/lib/active_fedora/datastream_collections.rb +4 -8
- data/lib/active_fedora/datastreams.rb +7 -9
- data/lib/active_fedora/version.rb +1 -1
- data/spec/config_helper.rb +3 -3
- data/spec/integration/associations_spec.rb +76 -76
- data/spec/integration/auditable_spec.rb +7 -7
- data/spec/integration/autosave_association_spec.rb +3 -3
- data/spec/integration/base_spec.rb +51 -51
- data/spec/integration/belongs_to_association_spec.rb +27 -27
- data/spec/integration/bug_spec.rb +1 -1
- data/spec/integration/collection_association_spec.rb +2 -2
- data/spec/integration/complex_rdf_datastream_spec.rb +32 -32
- data/spec/integration/datastream_collections_spec.rb +42 -42
- data/spec/integration/datastream_spec.rb +19 -19
- data/spec/integration/datastreams_spec.rb +25 -25
- data/spec/integration/delete_all_spec.rb +5 -5
- data/spec/integration/fedora_solr_sync_spec.rb +1 -1
- data/spec/integration/full_featured_model_spec.rb +9 -9
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +46 -47
- data/spec/integration/has_many_associations_spec.rb +17 -17
- data/spec/integration/json_serialization_spec.rb +2 -2
- data/spec/integration/load_from_solr_spec.rb +1 -1
- data/spec/integration/model_spec.rb +9 -9
- data/spec/integration/nested_attribute_spec.rb +17 -17
- data/spec/integration/ntriples_datastream_spec.rb +43 -43
- data/spec/integration/om_datastream_spec.rb +37 -37
- data/spec/integration/persistence_spec.rb +1 -1
- data/spec/integration/rdf_nested_attributes_spec.rb +9 -9
- data/spec/integration/relation_delegation_spec.rb +7 -7
- data/spec/integration/relation_spec.rb +2 -2
- data/spec/integration/rels_ext_datastream_spec.rb +3 -3
- data/spec/integration/scoped_query_spec.rb +14 -14
- data/spec/integration/solr_service_spec.rb +24 -24
- data/spec/support/mock_fedora.rb +9 -10
- data/spec/unit/active_fedora_spec.rb +20 -20
- data/spec/unit/attributes_spec.rb +24 -24
- data/spec/unit/base_active_model_spec.rb +6 -6
- data/spec/unit/base_cma_spec.rb +2 -2
- data/spec/unit/base_datastream_management_spec.rb +7 -7
- data/spec/unit/base_extra_spec.rb +20 -20
- data/spec/unit/base_spec.rb +141 -141
- data/spec/unit/builder/has_and_belongs_to_many_spec.rb +1 -1
- data/spec/unit/callback_spec.rb +12 -12
- data/spec/unit/code_configurator_spec.rb +7 -7
- data/spec/unit/config_spec.rb +2 -2
- data/spec/unit/content_model_spec.rb +19 -20
- data/spec/unit/core_spec.rb +1 -1
- data/spec/unit/datastream_collections_spec.rb +101 -101
- data/spec/unit/datastream_spec.rb +12 -12
- data/spec/unit/datastreams_spec.rb +39 -39
- data/spec/unit/file_configurator_spec.rb +117 -117
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +16 -16
- data/spec/unit/has_many_collection_spec.rb +5 -5
- data/spec/unit/inheritance_spec.rb +5 -5
- data/spec/unit/model_spec.rb +5 -5
- data/spec/unit/nom_datastream_spec.rb +5 -5
- data/spec/unit/ntriples_datastream_spec.rb +56 -56
- data/spec/unit/om_datastream_spec.rb +99 -99
- data/spec/unit/persistence_spec.rb +2 -2
- data/spec/unit/predicates_spec.rb +28 -28
- data/spec/unit/property_spec.rb +5 -5
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +10 -10
- data/spec/unit/query_spec.rb +66 -66
- data/spec/unit/rdf_datastream_spec.rb +10 -10
- data/spec/unit/rdf_resource_datastream_spec.rb +2 -2
- data/spec/unit/rdf_xml_writer_spec.rb +3 -3
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +9 -9
- data/spec/unit/relationship_graph_spec.rb +31 -31
- data/spec/unit/reload_on_save_spec.rb +3 -3
- data/spec/unit/rels_ext_datastream_spec.rb +28 -28
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +11 -11
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +11 -11
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +11 -11
- data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +7 -7
- data/spec/unit/rubydora_connection_spec.rb +3 -3
- data/spec/unit/semantic_node_spec.rb +17 -17
- data/spec/unit/serializers_spec.rb +1 -1
- data/spec/unit/service_definitions_spec.rb +11 -11
- data/spec/unit/simple_datastream_spec.rb +6 -6
- data/spec/unit/solr_config_options_spec.rb +10 -10
- data/spec/unit/solr_digital_object_spec.rb +4 -4
- data/spec/unit/solr_service_spec.rb +41 -41
- data/spec/unit/unsaved_digital_object_spec.rb +8 -8
- data/spec/unit/validations_spec.rb +6 -6
- metadata +4 -4
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe ActiveFedora::Associations::Builder::HasAndBelongsToMany do
|
4
4
|
describe "valid_options" do
|
5
5
|
subject { ActiveFedora::Associations::Builder::HasAndBelongsToMany.valid_options }
|
6
|
-
it {
|
6
|
+
it { is_expected.to eq [:class_name, :property, :before_add, :after_add, :before_remove, :after_remove,
|
7
7
|
:inverse_of, :solr_page_size, :autosave] }
|
8
8
|
end
|
9
9
|
end
|
data/spec/unit/callback_spec.rb
CHANGED
@@ -30,22 +30,22 @@ describe ActiveFedora::Base do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "Should have after_initialize, before_save,after_save, before_create, after_create, after_update, before_update, before_destroy" do
|
33
|
-
CallbackStub.
|
34
|
-
CallbackStub.
|
35
|
-
CallbackStub.
|
36
|
-
CallbackStub.
|
37
|
-
CallbackStub.
|
33
|
+
expect_any_instance_of(CallbackStub).to receive(:a_init)
|
34
|
+
expect_any_instance_of(CallbackStub).to receive :b_create
|
35
|
+
expect_any_instance_of(CallbackStub).to receive :a_create
|
36
|
+
expect_any_instance_of(CallbackStub).to receive(:b_save)
|
37
|
+
expect_any_instance_of(CallbackStub).to receive(:a_save)
|
38
38
|
cb = CallbackStub.new :pid => 'test:123'
|
39
39
|
cb.save
|
40
40
|
end
|
41
41
|
it "Should have after_initialize, before_save,after_save, before_create, after_create, after_update, before_update, before_destroy" do
|
42
|
-
CallbackStub.
|
43
|
-
CallbackStub.
|
44
|
-
CallbackStub.
|
45
|
-
CallbackStub.
|
46
|
-
CallbackStub.
|
47
|
-
CallbackStub.
|
48
|
-
CallbackStub.
|
42
|
+
expect_any_instance_of(CallbackStub).to receive(:a_init)
|
43
|
+
expect_any_instance_of(CallbackStub).to receive(:b_save)
|
44
|
+
expect_any_instance_of(CallbackStub).to receive(:a_save)
|
45
|
+
expect_any_instance_of(CallbackStub).to receive(:a_find)
|
46
|
+
expect_any_instance_of(CallbackStub).to receive(:b_update)
|
47
|
+
expect_any_instance_of(CallbackStub).to receive(:a_update)
|
48
|
+
expect_any_instance_of(CallbackStub).to receive(:do_stuff)
|
49
49
|
|
50
50
|
cb2 = CallbackStub.find('test:123')
|
51
51
|
cb2.save
|
@@ -38,14 +38,14 @@ describe ActiveFedora::FileConfigurator do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should initialize from code" do
|
41
|
-
Psych.
|
42
|
-
File.
|
43
|
-
File.
|
44
|
-
File.
|
41
|
+
expect(Psych).to receive(:load).never
|
42
|
+
expect(File).to receive(:exists?).never
|
43
|
+
expect(File).to receive(:read).never
|
44
|
+
expect(File).to receive(:open).never
|
45
45
|
ActiveFedora.init(@config_params)
|
46
|
-
ActiveFedora.fedora_config.credentials.
|
47
|
-
ActiveFedora.solr_config.
|
48
|
-
ActiveFedora::Predicates.predicate_mappings['info:fedora/fedora-system:def/relations-external#'].length.
|
46
|
+
expect(ActiveFedora.fedora_config.credentials).to eq(@config_params[:fedora_config])
|
47
|
+
expect(ActiveFedora.solr_config).to eq(@config_params[:solr_config])
|
48
|
+
expect(ActiveFedora::Predicates.predicate_mappings['info:fedora/fedora-system:def/relations-external#'].length).to eq(1)
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
data/spec/unit/config_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe ActiveFedora::Config do
|
|
5
5
|
conf = Psych.load(File.read('spec/fixtures/rails_root/config/fedora.yml'))['test']
|
6
6
|
subject { ActiveFedora::Config.new(conf) }
|
7
7
|
its(:credentials) { should == {:url => 'http://testhost.com:8983/fedora', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'}}
|
8
|
-
it {
|
8
|
+
it { is_expected.not_to be_sharded }
|
9
9
|
end
|
10
10
|
describe "with several fedora shards" do
|
11
11
|
conf = Psych.load(File.read('spec/fixtures/sharded_fedora.yml'))['test']
|
@@ -13,7 +13,7 @@ describe ActiveFedora::Config do
|
|
13
13
|
its(:credentials) { should == [{:url => 'http://127.0.0.1:8983/fedora1', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'},
|
14
14
|
{:url => 'http://127.0.0.1:8983/fedora2', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'},
|
15
15
|
{:url => 'http://127.0.0.1:8983/fedora3', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'}]}
|
16
|
-
it {
|
16
|
+
it { is_expected.to be_sharded }
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -21,19 +21,19 @@ describe ActiveFedora::ContentModel do
|
|
21
21
|
describe '.best_model_for' do
|
22
22
|
it 'should be nil if no relationships' do
|
23
23
|
mock_object = BaseModel.new
|
24
|
-
mock_object.
|
24
|
+
expect(mock_object).to receive(:relationships).with(:has_model).and_return([])
|
25
25
|
expect(ActiveFedora::ContentModel.best_model_for(mock_object)).to be_nil
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'should be based on inheritance hierarchy' do
|
29
29
|
mock_object = ActiveFedora::Base.new
|
30
|
-
mock_object.
|
30
|
+
expect(mock_object).to receive(:relationships).with(:has_model).and_return(["info:fedora/fedora-system:ServiceDefinition-3.0", 'info:fedora/afmodel:SampleModel', 'info:fedora/afmodel:BaseModel'])
|
31
31
|
expect(ActiveFedora::ContentModel.best_model_for(mock_object)).to eq SampleModel
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should find the deepest descendant of the on inheritance hierarchy' do
|
35
35
|
mock_object = BaseModel.new
|
36
|
-
mock_object.
|
36
|
+
expect(mock_object).to receive(:relationships).with(:has_model).and_return(["info:fedora/fedora-system:ServiceDefinition-3.0", 'info:fedora/afmodel:SampleModel', 'info:fedora/afmodel:BaseModel'])
|
37
37
|
expect(ActiveFedora::ContentModel.best_model_for(mock_object)).to eq SampleModel
|
38
38
|
end
|
39
39
|
end
|
@@ -41,46 +41,45 @@ describe ActiveFedora::ContentModel do
|
|
41
41
|
describe "models_asserted_by" do
|
42
42
|
it "should return an array of all of the content models asserted by the given object" do
|
43
43
|
mock_object = double("ActiveFedora Object")
|
44
|
-
mock_object.
|
45
|
-
ActiveFedora::ContentModel.models_asserted_by(mock_object).
|
44
|
+
expect(mock_object).to receive(:relationships).with(:has_model).and_return(["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"])
|
45
|
+
expect(ActiveFedora::ContentModel.models_asserted_by(mock_object)).to eq(["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"])
|
46
46
|
end
|
47
47
|
it "should return an empty array if the object doesn't have a RELS-EXT datastream" do
|
48
48
|
mock_object = double("ActiveFedora Object")
|
49
|
-
mock_object.
|
50
|
-
ActiveFedora::ContentModel.models_asserted_by(mock_object).
|
49
|
+
expect(mock_object).to receive(:relationships).with(:has_model).and_return([])
|
50
|
+
expect(ActiveFedora::ContentModel.models_asserted_by(mock_object)).to eq([])
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
describe "known_models_asserted_by" do
|
55
55
|
it "should figure out the applicable models to load" do
|
56
56
|
mock_object = double("ActiveFedora Object")
|
57
|
-
mock_object.
|
58
|
-
ActiveFedora::ContentModel.known_models_for(mock_object).
|
57
|
+
expect(mock_object).to receive(:relationships).with(:has_model).and_return(["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"])
|
58
|
+
expect(ActiveFedora::ContentModel.known_models_for(mock_object)).to eq([SampleModel])
|
59
59
|
end
|
60
60
|
it "should support namespaced models" do
|
61
|
-
pending "This is harder than it looks."
|
62
61
|
mock_object = double("ActiveFedora Object")
|
63
|
-
mock_object.
|
64
|
-
ActiveFedora::ContentModel.known_models_for(mock_object).
|
62
|
+
expect(mock_object).to receive(:relationships).with(:has_model).and_return(["info:fedora/afmodel:Sample_NamespacedModel"])
|
63
|
+
expect(ActiveFedora::ContentModel.known_models_for(mock_object)).to eq([Sample::NamespacedModel])
|
65
64
|
end
|
66
65
|
it "should default to using ActiveFedora::Base as the model" do
|
67
66
|
mock_object = double("ActiveFedora Object")
|
68
|
-
mock_object.
|
69
|
-
ActiveFedora::ContentModel.known_models_for(mock_object).
|
67
|
+
expect(mock_object).to receive(:relationships).with(:has_model).and_return(["info:fedora/afmodel:NonDefinedModel"])
|
68
|
+
expect(ActiveFedora::ContentModel.known_models_for(mock_object)).to eq([ActiveFedora::Base])
|
70
69
|
end
|
71
70
|
it "should still work even if the object doesn't have a RELS-EXT datastream" do
|
72
71
|
mock_object = double("ActiveFedora Object")
|
73
|
-
mock_object.
|
74
|
-
ActiveFedora::ContentModel.known_models_for(mock_object).
|
72
|
+
expect(mock_object).to receive(:relationships).with(:has_model).and_return([])
|
73
|
+
expect(ActiveFedora::ContentModel.known_models_for(mock_object)).to eq([ActiveFedora::Base])
|
75
74
|
end
|
76
75
|
end
|
77
76
|
|
78
77
|
describe "uri_to_model_class" do
|
79
78
|
it "should return an ActiveFedora Model class corresponding to the given uri if a valid model can be found" do
|
80
|
-
ActiveFedora::ContentModel.uri_to_model_class("info:fedora/afmodel:SampleModel").
|
81
|
-
ActiveFedora::ContentModel.uri_to_model_class("info:fedora/afmodel:NonDefinedModel").
|
82
|
-
ActiveFedora::ContentModel.uri_to_model_class("info:fedora/afmodel:String").
|
83
|
-
ActiveFedora::ContentModel.uri_to_model_class("info:fedora/hydra-cModel:genericContent").
|
79
|
+
expect(ActiveFedora::ContentModel.uri_to_model_class("info:fedora/afmodel:SampleModel")).to eq(SampleModel)
|
80
|
+
expect(ActiveFedora::ContentModel.uri_to_model_class("info:fedora/afmodel:NonDefinedModel")).to eq(false)
|
81
|
+
expect(ActiveFedora::ContentModel.uri_to_model_class("info:fedora/afmodel:String")).to eq(false)
|
82
|
+
expect(ActiveFedora::ContentModel.uri_to_model_class("info:fedora/hydra-cModel:genericContent")).to eq(GenericContent)
|
84
83
|
end
|
85
84
|
end
|
86
85
|
|
data/spec/unit/core_spec.rb
CHANGED
@@ -15,24 +15,24 @@ describe ActiveFedora::DatastreamCollections do
|
|
15
15
|
it 'should cache a definition of named datastream and create helper methods to add/remove/access them' do
|
16
16
|
@test_object2 = MockHasDatastream.new
|
17
17
|
#prefix should default to name in caps if not specified in has_datastream call
|
18
|
-
@test_object2.named_datastreams_desc.
|
18
|
+
expect(@test_object2.named_datastreams_desc).to eq({"thumbnail"=>{:name=>"thumbnail",:prefix => "THUMB",
|
19
19
|
:type=>"ActiveFedora::Datastream", :mimeType=>"image/jpeg",
|
20
20
|
:controlGroup=>'M'},
|
21
21
|
"EAD"=> {:name=>"EAD", :prefix=>"EAD",
|
22
22
|
:type=>"ActiveFedora::Datastream", :mimeType=>"application/xml",
|
23
23
|
:controlGroup=>'M' },
|
24
24
|
"external"=> {:name=>"external", :prefix=>"EXTERNAL",
|
25
|
-
:type=>"ActiveFedora::Datastream", :controlGroup=>'E' }}
|
26
|
-
@test_object2.
|
27
|
-
@test_object2.
|
28
|
-
@test_object2.
|
29
|
-
@test_object2.
|
30
|
-
@test_object2.
|
31
|
-
@test_object2.
|
32
|
-
@test_object2.
|
33
|
-
@test_object2.
|
34
|
-
@test_object2.
|
35
|
-
@test_object2.
|
25
|
+
:type=>"ActiveFedora::Datastream", :controlGroup=>'E' }})
|
26
|
+
expect(@test_object2).to respond_to(:thumbnail_append)
|
27
|
+
expect(@test_object2).to respond_to(:thumbnail_file_append)
|
28
|
+
expect(@test_object2).to respond_to(:thumbnail)
|
29
|
+
expect(@test_object2).to respond_to(:thumbnail_ids)
|
30
|
+
expect(@test_object2).to respond_to(:ead_append)
|
31
|
+
expect(@test_object2).to respond_to(:ead_file_append)
|
32
|
+
expect(@test_object2).to respond_to(:EAD)
|
33
|
+
expect(@test_object2).to respond_to(:EAD_ids)
|
34
|
+
expect(@test_object2).to respond_to(:external)
|
35
|
+
expect(@test_object2).to respond_to(:external_ids)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
describe '#datastream_names' do
|
@@ -46,7 +46,7 @@ describe ActiveFedora::DatastreamCollections do
|
|
46
46
|
|
47
47
|
it 'should return a set of datastream names defined by has_datastream' do
|
48
48
|
@test_object2 = MockDatastreamNames.new
|
49
|
-
@test_object2.datastream_names.
|
49
|
+
expect(@test_object2.datastream_names).to include("thumbnail","EAD")
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -65,8 +65,8 @@ describe ActiveFedora::DatastreamCollections do
|
|
65
65
|
@test_object2 = MockAddNamedDatastream.new
|
66
66
|
@f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"))
|
67
67
|
@f2 = File.new(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ))
|
68
|
-
@f.
|
69
|
-
@f2.
|
68
|
+
allow(@f).to receive(:content_type).and_return("image/jpeg")
|
69
|
+
allow(@f2).to receive(:original_filename).and_return("dino.jpg")
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'cannot add a datastream with name that does not exist' do
|
@@ -93,16 +93,16 @@ describe ActiveFedora::DatastreamCollections do
|
|
93
93
|
|
94
94
|
it "should use the given label for the dsLabel" do
|
95
95
|
@test_object2.add_named_datastream("high",{:content_type=>"image/jpeg",:blob=>@f2, :label=>"my_image"})
|
96
|
-
@test_object2.high.first.dsLabel.
|
96
|
+
expect(@test_object2.high.first.dsLabel).to eq("my_image")
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should fallback on using the file name" do
|
100
100
|
@test_object2.add_named_datastream("high",{:content_type=>"image/jpeg",:blob=>@f2})
|
101
|
-
@test_object2.high.first.dsLabel.
|
101
|
+
expect(@test_object2.high.first.dsLabel).to eq("dino.jpg")
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should check the file for a content type" do
|
105
|
-
@f.
|
105
|
+
expect(@f).to receive(:content_type).and_return("image/jpeg")
|
106
106
|
@test_object2.add_named_datastream("thumbnail",{:file=>@f})
|
107
107
|
end
|
108
108
|
|
@@ -111,7 +111,7 @@ describe ActiveFedora::DatastreamCollections do
|
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should encsure mimetype and content type match" do
|
114
|
-
@f.
|
114
|
+
allow(@f).to receive(:content_type).and_return("image/tiff")
|
115
115
|
expect { @test_object2.add_named_datastream("thumbnail",{:file=>f}) }.to raise_error
|
116
116
|
end
|
117
117
|
|
@@ -119,12 +119,12 @@ describe ActiveFedora::DatastreamCollections do
|
|
119
119
|
#check for if any mime type allowed
|
120
120
|
@test_object2.add_named_datastream("anymime",{:file=>@f})
|
121
121
|
#check datastream created is of type ActiveFedora::Datastream
|
122
|
-
@test_object2.anymime.first.class.
|
122
|
+
expect(@test_object2.anymime.first.class).to eq(ActiveFedora::Datastream)
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should cgecj that a dsid forms to the prefix" do
|
126
126
|
#if dsid supplied check that conforms to prefix
|
127
|
-
@f.
|
127
|
+
allow(@f).to receive(:content_type).and_return("image/jpeg")
|
128
128
|
expect { @test_object2.add_named_datastream("thumbnail",{:file=>@f,:dsid=>"DS1"}) }.to raise_error
|
129
129
|
end
|
130
130
|
|
@@ -134,7 +134,7 @@ describe ActiveFedora::DatastreamCollections do
|
|
134
134
|
#@test_object2.high.first.attributes[:prefix].should == "HIGH"
|
135
135
|
@test_object2.high.first.dsid.match(/HIGH[0-9]/)
|
136
136
|
#check datastreams added with other right properties
|
137
|
-
@test_object2.high.first.controlGroup.
|
137
|
+
expect(@test_object2.high.first.controlGroup).to eq("M")
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should work with external datastreams" do
|
@@ -142,7 +142,7 @@ describe ActiveFedora::DatastreamCollections do
|
|
142
142
|
#check external datastream
|
143
143
|
@test_object2.add_named_datastream("external",{:dsLocation=>"http://myreasource.com"})
|
144
144
|
#check dslocation goes to dslabel
|
145
|
-
@test_object2.external.first.dsLabel.
|
145
|
+
expect(@test_object2.external.first.dsLabel).to eq("http://myreasource.com")
|
146
146
|
#check datastreams added to fedora (may want to stub this at first)
|
147
147
|
end
|
148
148
|
end
|
@@ -162,15 +162,15 @@ describe ActiveFedora::DatastreamCollections do
|
|
162
162
|
@test_object2 = MockAddNamedFileDatastream.new
|
163
163
|
f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"))
|
164
164
|
#these normally supplied in multi-part post request
|
165
|
-
f.
|
166
|
-
f.
|
165
|
+
allow(f).to receive(:original_filename).and_return("minivan.jpg")
|
166
|
+
allow(f).to receive(:content_type).and_return("image/jpeg")
|
167
167
|
@test_object2.add_named_file_datastream("thumbnail",f)
|
168
168
|
thumb = @test_object2.thumbnail.first
|
169
|
-
thumb.class.
|
170
|
-
thumb.mimeType.
|
171
|
-
thumb.dsid.
|
172
|
-
thumb.controlGroup.
|
173
|
-
thumb.dsLabel.
|
169
|
+
expect(thumb.class).to eq(MockDS)
|
170
|
+
expect(thumb.mimeType).to eq("image/jpeg")
|
171
|
+
expect(thumb.dsid).to eq("THUMB1")
|
172
|
+
expect(thumb.controlGroup).to eq("M")
|
173
|
+
expect(thumb.dsLabel).to eq("minivan.jpg")
|
174
174
|
#thumb.name.should == "thumbnail"
|
175
175
|
# :prefix=>"THUMB", :content_type=>"image/jpeg", :dsid=>"THUMB1", :dsID=>"THUMB1",
|
176
176
|
# :pid=>@test_object2.pid, :mimeType=>"image/jpeg", :controlGroup=>"M", :dsLabel=>"minivan.jpg", :name=>"thumbnail"}
|
@@ -190,10 +190,10 @@ describe ActiveFedora::DatastreamCollections do
|
|
190
190
|
@test_object2 = MockUpdateNamedDatastream.new
|
191
191
|
f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"))
|
192
192
|
f2 = File.new(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ))
|
193
|
-
f.
|
194
|
-
f.
|
195
|
-
f2.
|
196
|
-
f2.
|
193
|
+
allow(f).to receive(:content_type).and_return("image/jpeg")
|
194
|
+
allow(f).to receive(:original_filename).and_return("minivan.jpg")
|
195
|
+
allow(f2).to receive(:content_type).and_return("image/jpeg")
|
196
|
+
allow(f2).to receive(:original_filename).and_return("dino.jpg")
|
197
197
|
#check raise exception if dsid not supplied
|
198
198
|
@test_object2.add_named_datastream("thumbnail",{:file=>f})
|
199
199
|
had_exception = false
|
@@ -212,15 +212,15 @@ describe ActiveFedora::DatastreamCollections do
|
|
212
212
|
end
|
213
213
|
raise "Failed to raise exception if dsid does not exist" unless had_exception
|
214
214
|
#check datastream is updated in place without new dsid
|
215
|
-
@test_object2.thumbnail.size.
|
215
|
+
expect(@test_object2.thumbnail.size).to eq(1)
|
216
216
|
@test_object2.thumbnail_ids == ["THUMB1"]
|
217
217
|
thumb1 = @test_object2.thumbnail.first
|
218
|
-
thumb1.dsid.
|
219
|
-
thumb1.pid.
|
220
|
-
thumb1.dsLabel.
|
218
|
+
expect(thumb1.dsid).to eq('THUMB1')
|
219
|
+
expect(thumb1.pid).to eq(@test_object2.pid)
|
220
|
+
expect(thumb1.dsLabel).to eq('minivan.jpg')
|
221
221
|
f.rewind
|
222
222
|
@test_object2.update_named_datastream("thumbnail",{:file=>f2,:dsid=>"THUMB1"})
|
223
|
-
@test_object2.thumbnail.size.
|
223
|
+
expect(@test_object2.thumbnail.size).to eq(1)
|
224
224
|
@test_object2.thumbnail_ids == ["THUMB1"]
|
225
225
|
# @test_object2.thumbnail.first.attributes.should == {:type=>"ActiveFedora::Datastream",
|
226
226
|
# :content_type=>"image/jpeg",
|
@@ -229,9 +229,9 @@ describe ActiveFedora::DatastreamCollections do
|
|
229
229
|
# :pid=>@test_object2.pid, :dsID=>"THUMB1",
|
230
230
|
# :name=>"thumbnail", :dsLabel=>"dino.jpg"}
|
231
231
|
thumb1 = @test_object2.thumbnail.first
|
232
|
-
thumb1.dsid.
|
233
|
-
thumb1.pid.
|
234
|
-
thumb1.dsLabel.
|
232
|
+
expect(thumb1.dsid).to eq('THUMB1')
|
233
|
+
expect(thumb1.pid).to eq(@test_object2.pid)
|
234
|
+
expect(thumb1.dsLabel).to eq('dino.jpg')
|
235
235
|
end
|
236
236
|
end
|
237
237
|
describe '#named_datastreams_desc' do
|
@@ -245,9 +245,9 @@ describe ActiveFedora::DatastreamCollections do
|
|
245
245
|
|
246
246
|
it 'should intialize a value to an empty hash and then not modify afterward' do
|
247
247
|
@test_object2 = MockNamedDatastreamsDesc.new
|
248
|
-
@test_object2.named_datastreams_desc.
|
248
|
+
expect(@test_object2.named_datastreams_desc).to eq({"thumbnail"=>{:name=>"thumbnail",:prefix => "THUMB",
|
249
249
|
:type=>"ActiveFedora::Datastream", :mimeType=>"image/jpeg",
|
250
|
-
:controlGroup=>'M'}}
|
250
|
+
:controlGroup=>'M'}})
|
251
251
|
end
|
252
252
|
end
|
253
253
|
|
@@ -261,8 +261,8 @@ describe ActiveFedora::DatastreamCollections do
|
|
261
261
|
|
262
262
|
it 'should return true if a named datastream exists in model' do
|
263
263
|
@test_object2 = MockIsNamedDatastream.new
|
264
|
-
@test_object2.is_named_datastream?("thumbnail").
|
265
|
-
@test_object2.is_named_datastream?("thumb").
|
264
|
+
expect(@test_object2.is_named_datastream?("thumbnail")).to eq(true)
|
265
|
+
expect(@test_object2.is_named_datastream?("thumb")).to eq(false)
|
266
266
|
end
|
267
267
|
end
|
268
268
|
|
@@ -280,33 +280,33 @@ describe ActiveFedora::DatastreamCollections do
|
|
280
280
|
it 'should return a hash of datastream names to arrays of datastreams' do
|
281
281
|
@test_object2 = MockNamedDatastreams.new
|
282
282
|
f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg" ))
|
283
|
-
f.
|
284
|
-
f.
|
283
|
+
allow(f).to receive(:content_type).and_return("image/jpeg")
|
284
|
+
allow(f).to receive(:original_filename).and_return("minivan.jpg")
|
285
285
|
f2 = File.new(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ))
|
286
|
-
f2.
|
287
|
-
f2.
|
286
|
+
allow(f2).to receive(:content_type).and_return("image/jpeg")
|
287
|
+
allow(f2).to receive(:original_filename).and_return("dino.jpg")
|
288
288
|
@test_object2.thumbnail_file_append(f)
|
289
289
|
@test_object2.high_file_append(f2)
|
290
290
|
@test_object2.external_append({:dsLocation=>"http://myresource.com"})
|
291
291
|
datastreams = @test_object2.named_datastreams
|
292
|
-
datastreams.keys.include?("thumbnail").
|
293
|
-
datastreams.keys.include?("external").
|
294
|
-
datastreams.keys.include?("high").
|
295
|
-
datastreams.keys.size.
|
296
|
-
datastreams["thumbnail"].size.
|
297
|
-
datastreams["thumbnail"].first.dsid.
|
298
|
-
datastreams["thumbnail"].first.dsLabel.
|
299
|
-
datastreams["thumbnail"].first.controlGroup.
|
292
|
+
expect(datastreams.keys.include?("thumbnail")).to eq(true)
|
293
|
+
expect(datastreams.keys.include?("external")).to eq(true)
|
294
|
+
expect(datastreams.keys.include?("high")).to eq(true)
|
295
|
+
expect(datastreams.keys.size).to eq(3)
|
296
|
+
expect(datastreams["thumbnail"].size).to eq(1)
|
297
|
+
expect(datastreams["thumbnail"].first.dsid).to eq('THUMB1')
|
298
|
+
expect(datastreams["thumbnail"].first.dsLabel).to eq('minivan.jpg')
|
299
|
+
expect(datastreams["thumbnail"].first.controlGroup).to eq("M")
|
300
300
|
|
301
|
-
datastreams["external"].size.
|
302
|
-
datastreams["external"].first.dsid.
|
303
|
-
datastreams["external"].first.dsLocation.
|
304
|
-
datastreams["external"].first.controlGroup.
|
301
|
+
expect(datastreams["external"].size).to eq(1)
|
302
|
+
expect(datastreams["external"].first.dsid).to eq("EXTERNAL1")
|
303
|
+
expect(datastreams["external"].first.dsLocation).to eq("http://myresource.com")
|
304
|
+
expect(datastreams["external"].first.controlGroup).to eq("E")
|
305
305
|
|
306
|
-
datastreams["high"].size.
|
307
|
-
datastreams["high"].first.dsLabel.
|
308
|
-
datastreams["high"].first.controlGroup.
|
309
|
-
datastreams["high"].first.dsid.
|
306
|
+
expect(datastreams["high"].size).to eq(1)
|
307
|
+
expect(datastreams["high"].first.dsLabel).to eq('dino.jpg')
|
308
|
+
expect(datastreams["high"].first.controlGroup).to eq("M")
|
309
|
+
expect(datastreams["high"].first.dsid).to eq("HIGH1")
|
310
310
|
end
|
311
311
|
end
|
312
312
|
|
@@ -325,15 +325,15 @@ describe ActiveFedora::DatastreamCollections do
|
|
325
325
|
it 'should provide a hash of datastreams names to array of datastream ids' do
|
326
326
|
@test_object2 = MockNamedDatastreamsIds.new
|
327
327
|
f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg" ))
|
328
|
-
f.
|
329
|
-
f.
|
328
|
+
allow(f).to receive(:content_type).and_return("image/jpeg")
|
329
|
+
allow(f).to receive(:original_filename).and_return("minivan.jpg")
|
330
330
|
f2 = File.new(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ))
|
331
|
-
f2.
|
332
|
-
f2.
|
331
|
+
allow(f2).to receive(:content_type).and_return("image/jpeg")
|
332
|
+
allow(f2).to receive(:original_filename).and_return("dino.jpg")
|
333
333
|
@test_object2.thumbnail_file_append(f)
|
334
334
|
@test_object2.high_file_append(f2)
|
335
335
|
@test_object2.external_append({:dsLocation=>"http://myresource.com"})
|
336
|
-
@test_object2.named_datastreams_ids.
|
336
|
+
expect(@test_object2.named_datastreams_ids).to eq({"thumbnail"=>["THUMB1"],"high"=>["HIGH1"],"external"=>["EXTERNAL1"]})
|
337
337
|
end
|
338
338
|
end
|
339
339
|
|
@@ -349,32 +349,32 @@ describe ActiveFedora::DatastreamCollections do
|
|
349
349
|
|
350
350
|
it 'should create helper methods to get named datastreams or dsids' do
|
351
351
|
@test_object2 = MockCreateNamedDatastreamFinder.new
|
352
|
-
@test_object2.
|
353
|
-
@test_object2.
|
354
|
-
@test_object2.
|
355
|
-
@test_object2.
|
352
|
+
expect(@test_object2).to respond_to(:thumbnail)
|
353
|
+
expect(@test_object2).to respond_to(:thumbnail_ids)
|
354
|
+
expect(@test_object2).to respond_to(:high)
|
355
|
+
expect(@test_object2).to respond_to(:high_ids)
|
356
356
|
f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"))
|
357
357
|
f2 = File.new(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ))
|
358
|
-
f2.
|
359
|
-
f.
|
358
|
+
allow(f2).to receive(:original_filename).and_return("dino.jpg")
|
359
|
+
allow(f).to receive(:content_type).and_return("image/jpeg")
|
360
360
|
@test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f, :label=>"testDS"})
|
361
361
|
@test_object2.add_named_datastream("high",{:content_type=>"image/jpeg",:blob=>f2})
|
362
362
|
@test_object2.add_named_datastream("high",{:content_type=>"image/jpeg",:blob=>f2})
|
363
363
|
t2_thumb1 = @test_object2.thumbnail.first
|
364
|
-
t2_thumb1.mimeType.
|
365
|
-
t2_thumb1.controlGroup.
|
366
|
-
t2_thumb1.dsLabel.
|
367
|
-
t2_thumb1.pid.
|
368
|
-
t2_thumb1.dsid.
|
364
|
+
expect(t2_thumb1.mimeType).to eq("image/jpeg")
|
365
|
+
expect(t2_thumb1.controlGroup).to eq("M")
|
366
|
+
expect(t2_thumb1.dsLabel).to eq("testDS")
|
367
|
+
expect(t2_thumb1.pid).to eq(@test_object2.pid)
|
368
|
+
expect(t2_thumb1.dsid).to eq("THUMB1")
|
369
369
|
# :type=>"ActiveFedora::Datastream",
|
370
370
|
# :prefix=>"THUMB", :content_type=>"image/jpeg", :dsid=>"THUMB1", :dsID=>"THUMB1",
|
371
371
|
# :pid=>@test_object2.pid, :mimeType=>"image/jpeg", :controlGroup=>"M", :dsLabel=>"testDS", :name=>"thumbnail", :label=>"testDS"}
|
372
|
-
@test_object2.thumbnail_ids.
|
372
|
+
expect(@test_object2.thumbnail_ids).to eq(["THUMB1"])
|
373
373
|
@test_object2.high_ids.include?("HIGH1") == true
|
374
374
|
@test_object2.high_ids.include?("HIGH2") == true
|
375
|
-
@test_object2.high_ids.size.
|
375
|
+
expect(@test_object2.high_ids.size).to eq(2)
|
376
376
|
#just check returning datastream object at this point
|
377
|
-
@test_object2.high.first.class.
|
377
|
+
expect(@test_object2.high.first.class).to eq(ActiveFedora::Datastream)
|
378
378
|
end
|
379
379
|
end
|
380
380
|
|
@@ -391,29 +391,29 @@ describe ActiveFedora::DatastreamCollections do
|
|
391
391
|
it 'should create append method for each has_datastream entry' do
|
392
392
|
@test_object2 = MockCreateNamedDatastreamUpdateMethods.new
|
393
393
|
@test_object3 = MockCreateNamedDatastreamUpdateMethods.new
|
394
|
-
@test_object2.
|
395
|
-
@test_object2.
|
394
|
+
expect(@test_object2).to respond_to(:thumbnail_append)
|
395
|
+
expect(@test_object2).to respond_to(:ead_append)
|
396
396
|
f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"))
|
397
|
-
f.
|
398
|
-
f.
|
397
|
+
allow(f).to receive(:content_type).and_return("image/jpeg")
|
398
|
+
allow(f).to receive(:original_filename).and_return("minivan.jpg")
|
399
399
|
@test_object2.thumbnail_file_append(f)
|
400
400
|
t2_thumb1 = @test_object2.thumbnail.first
|
401
|
-
t2_thumb1.mimeType.
|
402
|
-
t2_thumb1.dsLabel.
|
403
|
-
t2_thumb1.pid.
|
404
|
-
t2_thumb1.dsid.
|
401
|
+
expect(t2_thumb1.mimeType).to eq("image/jpeg")
|
402
|
+
expect(t2_thumb1.dsLabel).to eq("minivan.jpg")
|
403
|
+
expect(t2_thumb1.pid).to eq(@test_object2.pid)
|
404
|
+
expect(t2_thumb1.dsid).to eq("THUMB1")
|
405
405
|
@test_object3.thumbnail_append({:file=>f})
|
406
406
|
t3_thumb1 = @test_object3.thumbnail.first
|
407
|
-
t3_thumb1.mimeType.
|
408
|
-
t3_thumb1.dsLabel.
|
409
|
-
t3_thumb1.pid.
|
410
|
-
t3_thumb1.dsid.
|
407
|
+
expect(t3_thumb1.mimeType).to eq("image/jpeg")
|
408
|
+
expect(t3_thumb1.dsLabel).to eq("minivan.jpg")
|
409
|
+
expect(t3_thumb1.pid).to eq(@test_object3.pid)
|
410
|
+
expect(t3_thumb1.dsid).to eq("THUMB1")
|
411
411
|
@test_object3.external_append({:dsLocation=>"http://myresource.com"})
|
412
412
|
t3_external1 = @test_object3.external.first
|
413
|
-
t3_external1.dsLabel.
|
414
|
-
t3_external1.dsLocation.
|
415
|
-
t3_external1.pid.
|
416
|
-
t3_external1.dsid.
|
413
|
+
expect(t3_external1.dsLabel).to eq("http://myresource.com")
|
414
|
+
expect(t3_external1.dsLocation).to eq("http://myresource.com")
|
415
|
+
expect(t3_external1.pid).to eq(@test_object3.pid)
|
416
|
+
expect(t3_external1.dsid).to eq("EXTERNAL1")
|
417
417
|
t3_external1.controlGroup == 'E'
|
418
418
|
end
|
419
419
|
end
|