active-fedora 6.8.0 → 7.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +15 -5
  4. data/CONTRIBUTING.md +2 -0
  5. data/Gemfile +0 -2
  6. data/History.txt +2 -32
  7. data/README.md +143 -0
  8. data/Rakefile +5 -7
  9. data/active-fedora.gemspec +9 -9
  10. data/gemfiles/rails3.gemfile +11 -0
  11. data/gemfiles/rails4.gemfile +10 -0
  12. data/lib/active_fedora.rb +31 -4
  13. data/lib/active_fedora/association_relation.rb +18 -0
  14. data/lib/active_fedora/associations.rb +38 -171
  15. data/lib/active_fedora/associations/association.rb +163 -0
  16. data/lib/active_fedora/associations/association_scope.rb +39 -0
  17. data/lib/active_fedora/associations/belongs_to_association.rb +47 -25
  18. data/lib/active_fedora/associations/builder/association.rb +55 -0
  19. data/lib/active_fedora/associations/builder/belongs_to.rb +100 -0
  20. data/lib/active_fedora/associations/builder/collection_association.rb +56 -0
  21. data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +30 -0
  22. data/lib/active_fedora/associations/builder/has_many.rb +63 -0
  23. data/lib/active_fedora/associations/builder/singular_association.rb +32 -0
  24. data/lib/active_fedora/associations/{association_collection.rb → collection_association.rb} +203 -53
  25. data/lib/active_fedora/associations/collection_proxy.rb +862 -0
  26. data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +35 -25
  27. data/lib/active_fedora/associations/has_many_association.rb +36 -11
  28. data/lib/active_fedora/associations/singular_association.rb +62 -0
  29. data/lib/active_fedora/attributes.rb +43 -139
  30. data/lib/active_fedora/autosave_association.rb +317 -0
  31. data/lib/active_fedora/base.rb +10 -327
  32. data/lib/active_fedora/callbacks.rb +1 -3
  33. data/lib/active_fedora/content_model.rb +16 -0
  34. data/lib/active_fedora/core.rb +151 -0
  35. data/lib/active_fedora/datastream_attribute.rb +76 -0
  36. data/lib/active_fedora/datastream_hash.rb +8 -13
  37. data/lib/active_fedora/datastreams.rb +39 -26
  38. data/lib/active_fedora/digital_object.rb +2 -2
  39. data/lib/active_fedora/fedora_attributes.rb +45 -0
  40. data/lib/active_fedora/fixture_loader.rb +1 -1
  41. data/lib/active_fedora/indexing.rb +6 -1
  42. data/lib/active_fedora/model.rb +0 -17
  43. data/lib/active_fedora/nested_attributes.rb +2 -2
  44. data/lib/active_fedora/null_relation.rb +7 -0
  45. data/lib/active_fedora/om_datastream.rb +3 -4
  46. data/lib/active_fedora/persistence.rb +41 -29
  47. data/lib/active_fedora/querying.rb +2 -163
  48. data/lib/active_fedora/rdf.rb +1 -0
  49. data/lib/active_fedora/rdf/indexing.rb +67 -0
  50. data/lib/active_fedora/rdf_datastream.rb +2 -50
  51. data/lib/active_fedora/rdf_node.rb +12 -7
  52. data/lib/active_fedora/rdf_node/term_proxy.rb +30 -21
  53. data/lib/active_fedora/rdfxml_rdf_datastream.rb +1 -1
  54. data/lib/active_fedora/reflection.rb +163 -20
  55. data/lib/active_fedora/relation.rb +33 -130
  56. data/lib/active_fedora/relation/calculations.rb +19 -0
  57. data/lib/active_fedora/relation/delegation.rb +22 -0
  58. data/lib/active_fedora/relation/finder_methods.rb +247 -0
  59. data/lib/active_fedora/relation/merger.rb +22 -0
  60. data/lib/active_fedora/relation/query_methods.rb +58 -0
  61. data/lib/active_fedora/relation/spawn_methods.rb +46 -0
  62. data/lib/active_fedora/relationship_graph.rb +0 -2
  63. data/lib/active_fedora/rels_ext_datastream.rb +1 -4
  64. data/lib/active_fedora/rubydora_connection.rb +1 -1
  65. data/lib/active_fedora/scoping.rb +20 -0
  66. data/lib/active_fedora/scoping/default.rb +38 -0
  67. data/lib/active_fedora/scoping/named.rb +32 -0
  68. data/lib/active_fedora/semantic_node.rb +54 -106
  69. data/lib/active_fedora/serialization.rb +19 -0
  70. data/lib/active_fedora/sharding.rb +58 -0
  71. data/lib/active_fedora/solr_digital_object.rb +15 -5
  72. data/lib/active_fedora/solr_instance_loader.rb +1 -1
  73. data/lib/active_fedora/solr_service.rb +1 -1
  74. data/lib/active_fedora/unsaved_digital_object.rb +6 -4
  75. data/lib/active_fedora/version.rb +1 -1
  76. data/lib/tasks/active_fedora.rake +3 -0
  77. data/lib/tasks/active_fedora_dev.rake +6 -5
  78. data/spec/config_helper.rb +14 -14
  79. data/spec/integration/associations_spec.rb +168 -455
  80. data/spec/integration/attributes_spec.rb +12 -11
  81. data/spec/integration/auditable_spec.rb +11 -11
  82. data/spec/integration/autosave_association_spec.rb +25 -0
  83. data/spec/integration/base_spec.rb +163 -163
  84. data/spec/integration/belongs_to_association_spec.rb +166 -0
  85. data/spec/integration/bug_spec.rb +7 -7
  86. data/spec/integration/collection_association_spec.rb +58 -0
  87. data/spec/integration/complex_rdf_datastream_spec.rb +88 -88
  88. data/spec/integration/datastream_collections_spec.rb +69 -69
  89. data/spec/integration/datastream_spec.rb +43 -43
  90. data/spec/integration/datastreams_spec.rb +63 -63
  91. data/spec/integration/delete_all_spec.rb +46 -39
  92. data/spec/integration/fedora_solr_sync_spec.rb +5 -5
  93. data/spec/integration/field_to_solr_name_spec.rb +34 -0
  94. data/spec/integration/full_featured_model_spec.rb +100 -101
  95. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +341 -0
  96. data/spec/integration/has_many_associations_spec.rb +172 -24
  97. data/spec/integration/json_serialization_spec.rb +31 -0
  98. data/spec/integration/load_from_solr_spec.rb +48 -0
  99. data/spec/integration/model_spec.rb +35 -40
  100. data/spec/integration/nested_attribute_spec.rb +42 -43
  101. data/spec/integration/ntriples_datastream_spec.rb +131 -113
  102. data/spec/integration/om_datastream_spec.rb +67 -67
  103. data/spec/integration/persistence_spec.rb +7 -7
  104. data/spec/integration/rdf_nested_attributes_spec.rb +56 -56
  105. data/spec/integration/relation_delegation_spec.rb +26 -25
  106. data/spec/integration/relation_spec.rb +42 -0
  107. data/spec/integration/rels_ext_datastream_spec.rb +20 -20
  108. data/spec/integration/scoped_query_spec.rb +61 -51
  109. data/spec/integration/solr_instance_loader_spec.rb +5 -5
  110. data/spec/integration/solr_service_spec.rb +46 -46
  111. data/spec/samples/hydra-mods_article_datastream.rb +334 -334
  112. data/spec/samples/hydra-rights_metadata_datastream.rb +57 -57
  113. data/spec/samples/marpa-dc_datastream.rb +17 -17
  114. data/spec/samples/models/audio_record.rb +16 -16
  115. data/spec/samples/models/image.rb +2 -2
  116. data/spec/samples/models/mods_article.rb +5 -5
  117. data/spec/samples/models/oral_history.rb +18 -18
  118. data/spec/samples/models/seminar.rb +24 -24
  119. data/spec/samples/models/seminar_audio_file.rb +17 -17
  120. data/spec/samples/oral_history_sample_model.rb +21 -21
  121. data/spec/samples/special_thing.rb +14 -14
  122. data/spec/spec_helper.rb +11 -7
  123. data/spec/support/an_active_model.rb +2 -8
  124. data/spec/support/freeze_mocks.rb +12 -0
  125. data/spec/support/mock_fedora.rb +17 -16
  126. data/spec/unit/active_fedora_spec.rb +58 -60
  127. data/spec/unit/attributes_spec.rb +314 -0
  128. data/spec/unit/base_active_model_spec.rb +28 -27
  129. data/spec/unit/base_cma_spec.rb +5 -5
  130. data/spec/unit/base_datastream_management_spec.rb +27 -27
  131. data/spec/unit/base_extra_spec.rb +76 -48
  132. data/spec/unit/base_spec.rb +277 -348
  133. data/spec/unit/callback_spec.rb +18 -19
  134. data/spec/unit/code_configurator_spec.rb +17 -17
  135. data/spec/unit/config_spec.rb +8 -16
  136. data/spec/unit/content_model_spec.rb +79 -60
  137. data/spec/unit/datastream_collections_spec.rb +229 -229
  138. data/spec/unit/datastream_spec.rb +51 -63
  139. data/spec/unit/datastreams_spec.rb +87 -87
  140. data/spec/unit/file_configurator_spec.rb +217 -217
  141. data/spec/unit/has_and_belongs_to_many_collection_spec.rb +44 -25
  142. data/spec/unit/has_many_collection_spec.rb +26 -8
  143. data/spec/unit/inheritance_spec.rb +13 -12
  144. data/spec/unit/model_spec.rb +39 -45
  145. data/spec/unit/nom_datastream_spec.rb +15 -15
  146. data/spec/unit/ntriples_datastream_spec.rb +123 -118
  147. data/spec/unit/om_datastream_spec.rb +227 -233
  148. data/spec/unit/persistence_spec.rb +34 -15
  149. data/spec/unit/predicates_spec.rb +73 -73
  150. data/spec/unit/property_spec.rb +17 -9
  151. data/spec/unit/qualified_dublin_core_datastream_spec.rb +33 -33
  152. data/spec/unit/query_spec.rb +222 -198
  153. data/spec/unit/rdf_datastream_spec.rb +21 -28
  154. data/spec/unit/rdf_list_nested_attributes_spec.rb +34 -34
  155. data/spec/unit/rdf_list_spec.rb +65 -64
  156. data/spec/unit/rdf_node_spec.rb +7 -7
  157. data/spec/unit/rdf_xml_writer_spec.rb +10 -10
  158. data/spec/unit/rdfxml_rdf_datastream_spec.rb +27 -27
  159. data/spec/unit/relationship_graph_spec.rb +51 -51
  160. data/spec/unit/rels_ext_datastream_spec.rb +68 -74
  161. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +15 -15
  162. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +15 -15
  163. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +15 -15
  164. data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +12 -12
  165. data/spec/unit/rubydora_connection_spec.rb +5 -5
  166. data/spec/unit/semantic_node_spec.rb +48 -107
  167. data/spec/unit/serializers_spec.rb +4 -4
  168. data/spec/unit/service_definitions_spec.rb +26 -26
  169. data/spec/unit/simple_datastream_spec.rb +17 -17
  170. data/spec/unit/solr_config_options_spec.rb +29 -28
  171. data/spec/unit/solr_digital_object_spec.rb +17 -25
  172. data/spec/unit/solr_service_spec.rb +95 -82
  173. data/spec/unit/unsaved_digital_object_spec.rb +24 -23
  174. data/spec/unit/validations_spec.rb +21 -21
  175. metadata +110 -159
  176. data/.rspec +0 -1
  177. data/.rubocop.yml +0 -1
  178. data/.rubocop_todo.yml +0 -938
  179. data/CONSOLE_GETTING_STARTED.textile +0 -1
  180. data/NOKOGIRI_DATASTREAMS.textile +0 -1
  181. data/README.textile +0 -116
  182. data/lib/active_fedora/associations/association_proxy.rb +0 -178
  183. data/lib/active_fedora/delegating.rb +0 -72
  184. data/lib/active_fedora/nokogiri_datastream.rb +0 -11
  185. data/spec/integration/delegating_spec.rb +0 -59
  186. data/spec/rails3_test_app/.gitignore +0 -4
  187. data/spec/rails3_test_app/.rspec +0 -1
  188. data/spec/rails3_test_app/Gemfile +0 -40
  189. data/spec/rails3_test_app/Rakefile +0 -7
  190. data/spec/rails3_test_app/app/controllers/application_controller.rb +0 -3
  191. data/spec/rails3_test_app/app/helpers/application_helper.rb +0 -2
  192. data/spec/rails3_test_app/app/views/layouts/application.html.erb +0 -14
  193. data/spec/rails3_test_app/config.ru +0 -4
  194. data/spec/rails3_test_app/config/application.rb +0 -42
  195. data/spec/rails3_test_app/config/boot.rb +0 -6
  196. data/spec/rails3_test_app/config/database.yml +0 -22
  197. data/spec/rails3_test_app/config/environment.rb +0 -5
  198. data/spec/rails3_test_app/config/environments/development.rb +0 -25
  199. data/spec/rails3_test_app/config/environments/production.rb +0 -49
  200. data/spec/rails3_test_app/config/environments/test.rb +0 -35
  201. data/spec/rails3_test_app/config/initializers/backtrace_silencers.rb +0 -7
  202. data/spec/rails3_test_app/config/initializers/inflections.rb +0 -10
  203. data/spec/rails3_test_app/config/initializers/mime_types.rb +0 -5
  204. data/spec/rails3_test_app/config/initializers/secret_token.rb +0 -7
  205. data/spec/rails3_test_app/config/initializers/session_store.rb +0 -8
  206. data/spec/rails3_test_app/config/locales/en.yml +0 -5
  207. data/spec/rails3_test_app/config/routes.rb +0 -58
  208. data/spec/rails3_test_app/db/seeds.rb +0 -7
  209. data/spec/rails3_test_app/run_tests +0 -3
  210. data/spec/rails3_test_app/script/rails +0 -6
  211. data/spec/rails3_test_app/spec/spec_helper.rb +0 -27
  212. data/spec/rails3_test_app/spec/unit/rails_3_init.rb +0 -15
  213. data/spec/unit/association_proxy_spec.rb +0 -12
  214. data/spec/unit/base_delegate_spec.rb +0 -197
  215. data/spec/unit/base_delegate_to_spec.rb +0 -73
@@ -3,12 +3,11 @@ require 'spec_helper'
3
3
  describe ActiveFedora::Base do
4
4
  before :all do
5
5
  class CallbackStub < ActiveFedora::Base
6
- has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'someData' do |m|
7
- m.field 'fubar', :string
8
- m.field 'swank', :text
6
+ has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"someData" do |m|
7
+ m.field "fubar", :string
8
+ m.field "swank", :text
9
9
  end
10
- delegate :fubar, :to => 'someData', multiple: true
11
- delegate :swank, :to => 'someData', multiple: true
10
+ has_attributes :fubar, :swank, datastream: 'someData', multiple: true
12
11
 
13
12
  after_initialize :a_init
14
13
  before_save :b_save
@@ -30,23 +29,23 @@ describe ActiveFedora::Base do
30
29
  Object.send(:remove_const, :CallbackStub)
31
30
  end
32
31
 
33
- it 'Should have after_initialize, before_save,after_save, before_create, after_create, after_update, before_update, before_destroy' do
34
- expect_any_instance_of(CallbackStub).to receive(:a_init)
35
- expect_any_instance_of(CallbackStub).to receive :b_create
36
- expect_any_instance_of(CallbackStub).to receive :a_create
37
- expect_any_instance_of(CallbackStub).to receive(:b_save)
38
- expect_any_instance_of(CallbackStub).to receive(:a_save)
32
+ it "Should have after_initialize, before_save,after_save, before_create, after_create, after_update, before_update, before_destroy" do
33
+ CallbackStub.any_instance.should_receive(:a_init)
34
+ CallbackStub.any_instance.should_receive :b_create
35
+ CallbackStub.any_instance.should_receive :a_create
36
+ CallbackStub.any_instance.should_receive(:b_save)
37
+ CallbackStub.any_instance.should_receive(:a_save)
39
38
  cb = CallbackStub.new :pid => 'test:123'
40
39
  cb.save
41
40
  end
42
- it 'Should have after_initialize, before_save,after_save, before_create, after_create, after_update, before_update, before_destroy' do
43
- expect_any_instance_of(CallbackStub).to receive(:a_init)
44
- expect_any_instance_of(CallbackStub).to receive(:b_save)
45
- expect_any_instance_of(CallbackStub).to receive(:a_save)
46
- expect_any_instance_of(CallbackStub).to receive(:a_find)
47
- expect_any_instance_of(CallbackStub).to receive(:b_update)
48
- expect_any_instance_of(CallbackStub).to receive(:a_update)
49
- expect_any_instance_of(CallbackStub).to receive(:do_stuff)
41
+ it "Should have after_initialize, before_save,after_save, before_create, after_create, after_update, before_update, before_destroy" do
42
+ CallbackStub.any_instance.should_receive(:a_init)
43
+ CallbackStub.any_instance.should_receive(:b_save)
44
+ CallbackStub.any_instance.should_receive(:a_save)
45
+ CallbackStub.any_instance.should_receive(:a_find)
46
+ CallbackStub.any_instance.should_receive(:b_update)
47
+ CallbackStub.any_instance.should_receive(:a_update)
48
+ CallbackStub.any_instance.should_receive(:do_stuff)
50
49
 
51
50
  cb2 = CallbackStub.find('test:123')
52
51
  cb2.save
@@ -2,34 +2,34 @@ require 'spec_helper'
2
2
  require 'config_helper'
3
3
 
4
4
  describe ActiveFedora::FileConfigurator do
5
-
5
+
6
6
  before :all do
7
7
  class TestConfigurator
8
8
  attr_reader :fedora_config, :solr_config, :predicate_config
9
-
9
+
10
10
  def init(options = {})
11
11
  @fedora_config = options[:fedora_config]
12
12
  @solr_config = options[:solr_config]
13
13
  @predicate_config = options[:predicate_config]
14
14
  end
15
15
  end
16
-
16
+
17
17
  @config_params = {
18
18
  :fedora_config => { :url => 'http://codeconfig.example.edu/fedora/', :user => 'fedoraAdmin', :password => 'configurator', :cert_file => '/path/to/cert/file' },
19
19
  :solr_config => { :url => 'http://codeconfig.example.edu/solr/' },
20
- :predicate_config => {
20
+ :predicate_config => {
21
21
  :default_namespace => 'info:fedora/fedora-system:def/relations-external#',
22
22
  :predicate_mapping => {
23
- 'info:fedora/fedora-system:def/relations-external#' => { :has_part => 'hasPart' }
23
+ 'info:fedora/fedora-system:def/relations-external#' => { :has_part => 'hasPart' }
24
24
  }
25
25
  }
26
26
  }
27
27
  end
28
-
28
+
29
29
  before :each do
30
30
  ActiveFedora.configurator = TestConfigurator.new
31
31
  end
32
-
32
+
33
33
  after :all do
34
34
  unstub_rails
35
35
  # Restore to default fedora configs
@@ -37,15 +37,15 @@ describe ActiveFedora::FileConfigurator do
37
37
  restore_spec_configuration
38
38
  end
39
39
 
40
- it 'should initialize from code' do
41
- expect(YAMLAdaptor).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
40
+ it "should initialize from code" do
41
+ YAMLAdaptor.should_receive(:load).never
42
+ File.should_receive(:exists?).never
43
+ File.should_receive(:read).never
44
+ File.should_receive(:open).never
45
45
  ActiveFedora.init(@config_params)
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)
46
+ ActiveFedora.fedora_config.credentials.should == @config_params[:fedora_config]
47
+ ActiveFedora.solr_config.should == @config_params[:solr_config]
48
+ ActiveFedora::Predicates.predicate_mappings['info:fedora/fedora-system:def/relations-external#'].length.should == 1
49
49
  end
50
-
51
- end
50
+
51
+ end
@@ -1,27 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::Config do
4
- describe 'with a single fedora instance' do
4
+ describe "with a single fedora instance" do
5
5
  conf = YAMLAdaptor.load(File.read('spec/fixtures/rails_root/config/fedora.yml'))['test']
6
6
  subject { ActiveFedora::Config.new(conf) }
7
-
8
- describe '#credentials' do
9
- subject { super().credentials }
10
- it { is_expected.to eq({:url => 'http://testhost.com:8983/fedora', :user => 'fedoraAdmin', :password => 'fedoraAdmin'})}
11
- end
12
- it { is_expected.not_to be_sharded }
7
+ its(:credentials) { should == {:url => 'http://testhost.com:8983/fedora', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'}}
8
+ it { should_not be_sharded }
13
9
  end
14
- describe 'with several fedora shards' do
10
+ describe "with several fedora shards" do
15
11
  conf = YAMLAdaptor.load(File.read('spec/fixtures/sharded_fedora.yml'))['test']
16
12
  subject { ActiveFedora::Config.new(conf) }
17
-
18
- describe '#credentials' do
19
- subject { super().credentials }
20
- it { is_expected.to eq([{:url => 'http://127.0.0.1:8983/fedora1', :user => 'fedoraAdmin', :password => 'fedoraAdmin'},
21
- {:url => 'http://127.0.0.1:8983/fedora2', :user => 'fedoraAdmin', :password => 'fedoraAdmin'},
22
- {:url => 'http://127.0.0.1:8983/fedora3', :user => 'fedoraAdmin', :password => 'fedoraAdmin'}])}
23
- end
24
- it { is_expected.to be_sharded }
13
+ its(:credentials) { should == [{:url => 'http://127.0.0.1:8983/fedora1', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'},
14
+ {:url => 'http://127.0.0.1:8983/fedora2', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'},
15
+ {:url => 'http://127.0.0.1:8983/fedora3', :user=> 'fedoraAdmin', :password=> 'fedoraAdmin'}]}
16
+ it { should be_sharded }
25
17
  end
26
18
 
27
19
  end
@@ -1,99 +1,118 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::ContentModel do
4
-
4
+
5
5
  before(:all) do
6
6
  class BaseModel < ActiveFedora::Base
7
7
  end
8
-
8
+
9
9
  class SampleModel < BaseModel
10
10
  end
11
11
 
12
12
  class GenericContent < ActiveFedora::Base
13
13
  end
14
-
14
+
15
15
  module Sample
16
16
  class NamespacedModel < ActiveFedora::Base
17
17
  end
18
18
  end
19
19
  end
20
-
20
+
21
21
  before(:each) do
22
22
  stub_get('__nextid__')
23
- allow(ActiveFedora::Base).to receive(:assign_pid).and_return('__nextid__')
24
- allow_any_instance_of(Rubydora::Repository).to receive(:client).and_return(@mock_client)
23
+ ActiveFedora::Base.stub(:assign_pid).and_return("__nextid__")
24
+ Rubydora::Repository.any_instance.stub(:client).and_return(@mock_client)
25
25
  @test_cmodel = ActiveFedora::ContentModel.new
26
26
  end
27
-
28
- it 'should provide #new' do
29
- expect(ActiveFedora::ContentModel).to respond_to(:new)
27
+
28
+ it "should provide #new" do
29
+ ActiveFedora::ContentModel.should respond_to(:new)
30
30
  end
31
-
32
- describe '#new' do
33
- it 'should create a kind of ActiveFedora::Base object' do
34
- expect(@test_cmodel).to be_kind_of(ActiveFedora::Base)
31
+
32
+ describe "#new" do
33
+ it "should create a kind of ActiveFedora::Base object" do
34
+ @test_cmodel.should be_kind_of(ActiveFedora::Base)
35
35
  end
36
- it 'should set pid_suffix to empty string unless overriden in options hash' do
37
- expect(@test_cmodel.pid_suffix).to eq('')
38
- boo_model = ActiveFedora::ContentModel.new(:pid_suffix => 'boo')
39
- expect(boo_model.pid_suffix).to eq('boo')
36
+ it "should set pid_suffix to empty string unless overriden in options hash" do
37
+ @test_cmodel.pid_suffix.should == ""
38
+ boo_model = ActiveFedora::ContentModel.new(:pid_suffix => "boo")
39
+ boo_model.pid_suffix.should == "boo"
40
40
  end
41
- it 'should set namespace to cmodel unless overriden in options hash' do
42
- expect(@test_cmodel.namespace).to eq('afmodel')
43
- boo_model = ActiveFedora::ContentModel.new(:namespace => 'boo')
44
- expect(boo_model.namespace).to eq('boo')
41
+ it "should set namespace to cmodel unless overriden in options hash" do
42
+ @test_cmodel.namespace.should == "afmodel"
43
+ boo_model = ActiveFedora::ContentModel.new(:namespace => "boo")
44
+ boo_model.namespace.should == "boo"
45
45
  end
46
46
  end
47
-
48
- it 'should provide @pid_suffix' do
49
- expect(@test_cmodel).to respond_to(:pid_suffix)
50
- expect(@test_cmodel).to respond_to(:pid_suffix=)
47
+
48
+ it "should provide @pid_suffix" do
49
+ @test_cmodel.should respond_to(:pid_suffix)
50
+ @test_cmodel.should respond_to(:pid_suffix=)
51
51
  end
52
+
53
+ describe '.best_model_for' do
54
+ it 'should be the input model if no relationships' do
55
+ mock_object = BaseModel.new
56
+ mock_object.should_receive(:relationships).with(:has_model).and_return([])
57
+ expect(ActiveFedora::ContentModel.best_model_for(mock_object)).to eq BaseModel
58
+ end
52
59
 
60
+ it 'should be based on inheritance hierarchy' do
61
+ mock_object = ActiveFedora::Base.new
62
+ mock_object.should_receive(:relationships).with(:has_model).and_return(["info:fedora/fedora-system:ServiceDefinition-3.0", 'info:fedora/afmodel:SampleModel', 'info:fedora/afmodel:BaseModel'])
63
+ expect(ActiveFedora::ContentModel.best_model_for(mock_object)).to eq SampleModel
64
+ end
53
65
 
54
- describe 'models_asserted_by' do
55
- it 'should return an array of all of the content models asserted by the given object' do
56
- mock_object = double('ActiveFedora 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.models_asserted_by(mock_object)).to eq(['info:fedora/fedora-system:ServiceDefinition-3.0', 'info:fedora/afmodel:SampleModel', 'info:fedora/afmodel:NonDefinedModel'])
66
+ it 'should find the deepest descendant of the on inheritance hierarchy' do
67
+ mock_object = BaseModel.new
68
+ mock_object.should_receive(:relationships).with(:has_model).and_return(["info:fedora/fedora-system:ServiceDefinition-3.0", 'info:fedora/afmodel:SampleModel', 'info:fedora/afmodel:BaseModel'])
69
+ expect(ActiveFedora::ContentModel.best_model_for(mock_object)).to eq SampleModel
70
+ end
71
+ end
72
+
73
+ describe "models_asserted_by" do
74
+ it "should return an array of all of the content models asserted by the given object" do
75
+ mock_object = double("ActiveFedora Object")
76
+ mock_object.should_receive(:relationships).with(:has_model).and_return(["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"])
77
+ ActiveFedora::ContentModel.models_asserted_by(mock_object).should == ["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"]
59
78
  end
60
79
  it "should return an empty array if the object doesn't have a RELS-EXT datastream" do
61
- mock_object = double('ActiveFedora Object')
62
- expect(mock_object).to receive(:relationships).with(:has_model).and_return([])
63
- expect(ActiveFedora::ContentModel.models_asserted_by(mock_object)).to eq([])
80
+ mock_object = double("ActiveFedora Object")
81
+ mock_object.should_receive(:relationships).with(:has_model).and_return([])
82
+ ActiveFedora::ContentModel.models_asserted_by(mock_object).should == []
64
83
  end
65
84
  end
66
-
67
- describe 'known_models_asserted_by' do
68
- it 'should figure out the applicable models to load' do
69
- mock_object = double('ActiveFedora Object')
70
- 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'])
71
- expect(ActiveFedora::ContentModel.known_models_for(mock_object)).to eq([SampleModel])
72
- end
73
- it 'should support namespaced models' do
74
- skip 'This is harder than it looks.'
75
- mock_object = double('ActiveFedora Object')
76
- expect(mock_object).to receive(:relationships).with(:has_model).and_return(['info:fedora/afmodel:Sample_NamespacedModel'])
77
- expect(ActiveFedora::ContentModel.known_models_for(mock_object)).to eq([Sample::NamespacedModel])
78
- end
79
- it 'should default to using ActiveFedora::Base as the model' do
80
- mock_object = double('ActiveFedora Object')
81
- expect(mock_object).to receive(:relationships).with(:has_model).and_return(['info:fedora/afmodel:NonDefinedModel'])
82
- expect(ActiveFedora::ContentModel.known_models_for(mock_object)).to eq([ActiveFedora::Base])
85
+
86
+ describe "known_models_asserted_by" do
87
+ it "should figure out the applicable models to load" do
88
+ mock_object = double("ActiveFedora Object")
89
+ mock_object.should_receive(:relationships).with(:has_model).and_return(["info:fedora/fedora-system:ServiceDefinition-3.0", "info:fedora/afmodel:SampleModel", "info:fedora/afmodel:NonDefinedModel"])
90
+ ActiveFedora::ContentModel.known_models_for(mock_object).should == [SampleModel]
91
+ end
92
+ it "should support namespaced models" do
93
+ pending "This is harder than it looks."
94
+ mock_object = double("ActiveFedora Object")
95
+ mock_object.should_receive(:relationships).with(:has_model).and_return(["info:fedora/afmodel:Sample_NamespacedModel"])
96
+ ActiveFedora::ContentModel.known_models_for(mock_object).should == [Sample::NamespacedModel]
97
+ end
98
+ it "should default to using ActiveFedora::Base as the model" do
99
+ mock_object = double("ActiveFedora Object")
100
+ mock_object.should_receive(:relationships).with(:has_model).and_return(["info:fedora/afmodel:NonDefinedModel"])
101
+ ActiveFedora::ContentModel.known_models_for(mock_object).should == [ActiveFedora::Base]
83
102
  end
84
103
  it "should still work even if the object doesn't have a RELS-EXT datastream" do
85
- mock_object = double('ActiveFedora Object')
86
- expect(mock_object).to receive(:relationships).with(:has_model).and_return([])
87
- expect(ActiveFedora::ContentModel.known_models_for(mock_object)).to eq([ActiveFedora::Base])
104
+ mock_object = double("ActiveFedora Object")
105
+ mock_object.should_receive(:relationships).with(:has_model).and_return([])
106
+ ActiveFedora::ContentModel.known_models_for(mock_object).should == [ActiveFedora::Base]
88
107
  end
89
108
  end
90
-
91
- describe 'uri_to_model_class' do
92
- it 'should return an ActiveFedora Model class corresponding to the given uri if a valid model can be found' do
93
- expect(ActiveFedora::ContentModel.uri_to_model_class('info:fedora/afmodel:SampleModel')).to eq(SampleModel)
94
- expect(ActiveFedora::ContentModel.uri_to_model_class('info:fedora/afmodel:NonDefinedModel')).to eq(false)
95
- expect(ActiveFedora::ContentModel.uri_to_model_class('info:fedora/afmodel:String')).to eq(false)
96
- expect(ActiveFedora::ContentModel.uri_to_model_class('info:fedora/hydra-cModel:genericContent')).to eq(GenericContent)
109
+
110
+ describe "uri_to_model_class" do
111
+ it "should return an ActiveFedora Model class corresponding to the given uri if a valid model can be found" do
112
+ ActiveFedora::ContentModel.uri_to_model_class("info:fedora/afmodel:SampleModel").should == SampleModel
113
+ ActiveFedora::ContentModel.uri_to_model_class("info:fedora/afmodel:NonDefinedModel").should == false
114
+ ActiveFedora::ContentModel.uri_to_model_class("info:fedora/afmodel:String").should == false
115
+ ActiveFedora::ContentModel.uri_to_model_class("info:fedora/hydra-cModel:genericContent").should == GenericContent
97
116
  end
98
117
  end
99
118
 
@@ -3,177 +3,177 @@ require 'spec_helper'
3
3
  describe ActiveFedora::DatastreamCollections do
4
4
  describe '.has_datastream' do
5
5
  before(:all) do
6
-
6
+
7
7
  class MockHasDatastream < ActiveFedora::Base
8
8
  include ActiveFedora::DatastreamCollections
9
- has_datastream :name => 'thumbnail', :prefix => 'THUMB', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
10
- has_datastream :name => 'EAD', :type => ActiveFedora::Datastream, :mimeType => 'application/xml', :controlGroup => 'M'
11
- has_datastream :name => 'external', :type => ActiveFedora::Datastream, :controlGroup => 'E'
9
+ has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
10
+ has_datastream :name=>"EAD", :type=>ActiveFedora::Datastream, :mimeType=>"application/xml", :controlGroup=>'M'
11
+ has_datastream :name=>"external", :type=>ActiveFedora::Datastream, :controlGroup=>'E'
12
12
  end
13
13
  end
14
-
14
+
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
- expect(@test_object2.named_datastreams_desc).to eq({'thumbnail' => {:name => 'thumbnail', :prefix => 'THUMB',
19
- :type => 'ActiveFedora::Datastream', :mimeType => 'image/jpeg',
20
- :controlGroup => 'M'},
21
- 'EAD' => {:name => 'EAD', :prefix => 'EAD',
22
- :type => 'ActiveFedora::Datastream', :mimeType => 'application/xml',
23
- :controlGroup => 'M' },
24
- 'external' => {:name => 'external', :prefix => 'EXTERNAL',
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)
18
+ @test_object2.named_datastreams_desc.should == {"thumbnail"=>{:name=>"thumbnail",:prefix => "THUMB",
19
+ :type=>"ActiveFedora::Datastream", :mimeType=>"image/jpeg",
20
+ :controlGroup=>'M'},
21
+ "EAD"=> {:name=>"EAD", :prefix=>"EAD",
22
+ :type=>"ActiveFedora::Datastream", :mimeType=>"application/xml",
23
+ :controlGroup=>'M' },
24
+ "external"=> {:name=>"external", :prefix=>"EXTERNAL",
25
+ :type=>"ActiveFedora::Datastream", :controlGroup=>'E' }}
26
+ @test_object2.should respond_to(:thumbnail_append)
27
+ @test_object2.should respond_to(:thumbnail_file_append)
28
+ @test_object2.should respond_to(:thumbnail)
29
+ @test_object2.should respond_to(:thumbnail_ids)
30
+ @test_object2.should respond_to(:ead_append)
31
+ @test_object2.should respond_to(:ead_file_append)
32
+ @test_object2.should respond_to(:EAD)
33
+ @test_object2.should respond_to(:EAD_ids)
34
+ @test_object2.should respond_to(:external)
35
+ @test_object2.should respond_to(:external_ids)
36
36
  end
37
37
  end
38
38
  describe '#datastream_names' do
39
39
  before(:all) do
40
40
  class MockDatastreamNames < ActiveFedora::Base
41
41
  include ActiveFedora::DatastreamCollections
42
- has_datastream :name => 'thumbnail', :prefix => 'THUMB', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
43
- has_datastream :name => 'EAD', :type => ActiveFedora::Datastream, :mimeType => 'application/xml', :controlGroup => 'M'
42
+ has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
43
+ has_datastream :name=>"EAD", :type=>ActiveFedora::Datastream, :mimeType=>"application/xml", :controlGroup=>'M'
44
44
  end
45
45
  end
46
-
46
+
47
47
  it 'should return a set of datastream names defined by has_datastream' do
48
48
  @test_object2 = MockDatastreamNames.new
49
- expect(@test_object2.datastream_names).to include('thumbnail', 'EAD')
49
+ @test_object2.datastream_names.should include("thumbnail","EAD")
50
50
  end
51
51
  end
52
-
52
+
53
53
  describe '#add_named_datastream' do
54
54
  before(:all) do
55
55
  class MockAddNamedDatastream < ActiveFedora::Base
56
56
  include ActiveFedora::DatastreamCollections
57
- has_datastream :name => 'thumbnail', :prefix => 'THUMB', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
58
- has_datastream :name => 'high', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
59
- has_datastream :name => 'anymime', :type => ActiveFedora::Datastream, :controlGroup => 'M'
60
- has_datastream :name => 'external', :type => ActiveFedora::Datastream, :controlGroup => 'E'
57
+ has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
58
+ has_datastream :name=>"high", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
59
+ has_datastream :name=>"anymime", :type=>ActiveFedora::Datastream, :controlGroup=>'M'
60
+ has_datastream :name=>"external", :type=>ActiveFedora::Datastream, :controlGroup=>'E'
61
61
  end
62
62
  end
63
63
  before do
64
64
 
65
65
  @test_object2 = MockAddNamedDatastream.new
66
- @f = File.new(File.join( File.dirname(__FILE__), '../fixtures/minivan.jpg'))
67
- @f2 = File.new(File.join( File.dirname(__FILE__), '../fixtures/dino.jpg' ))
68
- allow(@f).to receive(:content_type).and_return('image/jpeg')
69
- allow(@f2).to receive(:original_filename).and_return('dino.jpg')
66
+ @f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"))
67
+ @f2 = File.new(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ))
68
+ @f.stub(:content_type).and_return("image/jpeg")
69
+ @f2.stub(: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
73
- expect { @test_object2.add_named_datastream('thumb', {:content_type => 'image/jpeg', :blob => f}) }.to raise_error
73
+ expect { @test_object2.add_named_datastream("thumb",{:content_type=>"image/jpeg",:blob=>f}) }.to raise_error
74
74
  end
75
75
 
76
- it 'should accept a file blob' do
77
- @test_object2.add_named_datastream('thumbnail', {:content_type => 'image/jpeg', :blob => @f})
76
+ it "should accept a file blob" do
77
+ @test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>@f})
78
78
  end
79
79
 
80
- it 'should accept a file handle' do
81
- @test_object2.add_named_datastream('thumbnail', {:content_type => 'image/jpeg', :file => @f})
80
+ it "should accept a file handle" do
81
+ @test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:file=>@f})
82
82
  end
83
83
 
84
- it 'should allow access to file content' do
85
- @test_object2.add_named_datastream('thumbnail', {:content_type => 'image/jpeg', :file => @f})
84
+ it "should allow access to file content" do
85
+ @test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:file=>@f})
86
86
  @test_object2.save!
87
87
  @test_object2.thumbnail[0].content
88
88
  end
89
89
 
90
- it 'should raise an error if neither a blob nor file is set' do
91
- expect { @test_object2.add_named_datastream('thumbnail', {:content_type => 'image/jpeg'}) }.to raise_error
90
+ it "should raise an error if neither a blob nor file is set" do
91
+ expect { @test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg"}) }.to raise_error
92
92
  end
93
93
 
94
- it 'should use the given label for the dsLabel' do
95
- @test_object2.add_named_datastream('high', {:content_type => 'image/jpeg', :blob => @f2, :label => 'my_image'})
96
- expect(@test_object2.high.first.dsLabel).to eq('my_image')
94
+ it "should use the given label for the dsLabel" do
95
+ @test_object2.add_named_datastream("high",{:content_type=>"image/jpeg",:blob=>@f2, :label=>"my_image"})
96
+ @test_object2.high.first.dsLabel.should == "my_image"
97
97
  end
98
98
 
99
- it 'should fallback on using the file name' do
100
- @test_object2.add_named_datastream('high', {:content_type => 'image/jpeg', :blob => @f2})
101
- expect(@test_object2.high.first.dsLabel).to eq('dino.jpg')
102
- end
99
+ it "should fallback on using the file name" do
100
+ @test_object2.add_named_datastream("high",{:content_type=>"image/jpeg",:blob=>@f2})
101
+ @test_object2.high.first.dsLabel.should == "dino.jpg"
102
+ end
103
103
 
104
- it 'should check the file for a content type' do
105
- expect(@f).to receive(:content_type).and_return('image/jpeg')
106
- @test_object2.add_named_datastream('thumbnail', {:file => @f})
104
+ it "should check the file for a content type" do
105
+ @f.should_receive(:content_type).and_return("image/jpeg")
106
+ @test_object2.add_named_datastream("thumbnail",{:file=>@f})
107
107
  end
108
108
 
109
- it 'should raise an error if no content type is avialable' do
110
- expect { @test_object2.add_named_datastream('thumbnail', {:file => @f2}) }.to raise_error
109
+ it "should raise an error if no content type is avialable" do
110
+ expect { @test_object2.add_named_datastream("thumbnail",{:file=>@f2}) }.to raise_error
111
111
  end
112
112
 
113
- it 'should encsure mimetype and content type match' do
114
- allow(@f).to receive(:content_type).and_return('image/tiff')
115
- expect { @test_object2.add_named_datastream('thumbnail', {:file => f}) }.to raise_error
113
+ it "should encsure mimetype and content type match" do
114
+ @f.stub(:content_type).and_return("image/tiff")
115
+ expect { @test_object2.add_named_datastream("thumbnail",{:file=>f}) }.to raise_error
116
116
  end
117
-
118
- it 'should allow any mime type' do
117
+
118
+ it "should allow any mime type" do
119
119
  #check for if any mime type allowed
120
- @test_object2.add_named_datastream('anymime', {:file => @f})
120
+ @test_object2.add_named_datastream("anymime",{:file=>@f})
121
121
  #check datastream created is of type ActiveFedora::Datastream
122
- expect(@test_object2.anymime.first.class).to eq(ActiveFedora::Datastream)
122
+ @test_object2.anymime.first.class.should == ActiveFedora::Datastream
123
123
  end
124
124
 
125
- it 'should cgecj that a dsid forms to the prefix' do
125
+ it "should cgecj that a dsid forms to the prefix" do
126
126
  #if dsid supplied check that conforms to prefix
127
- allow(@f).to receive(:content_type).and_return('image/jpeg')
128
- expect { @test_object2.add_named_datastream('thumbnail', {:file => @f, :dsid => 'DS1'}) }.to raise_error
127
+ @f.stub(:content_type).and_return("image/jpeg")
128
+ expect { @test_object2.add_named_datastream("thumbnail",{:file=>@f,:dsid=>"DS1"}) }.to raise_error
129
129
  end
130
130
 
131
- it 'should have the right properties' do
132
- @test_object2.add_named_datastream('high', {:content_type => 'image/jpeg', :blob => @f2})
131
+ it "should have the right properties" do
132
+ @test_object2.add_named_datastream("high",{:content_type=>"image/jpeg",:blob=>@f2})
133
133
  #if prefix not set check uses name in CAPS and dsid uses prefix
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
- expect(@test_object2.high.first.controlGroup).to eq('M')
137
+ @test_object2.high.first.controlGroup.should == "M"
138
138
  end
139
139
 
140
- it 'should work with external datastreams' do
141
-
140
+ it "should work with external datastreams" do
141
+
142
142
  #check external datastream
143
- @test_object2.add_named_datastream('external', {:dsLocation => 'http://myreasource.com'})
143
+ @test_object2.add_named_datastream("external",{:dsLocation=>"http://myreasource.com"})
144
144
  #check dslocation goes to dslabel
145
- expect(@test_object2.external.first.dsLabel).to eq('http://myreasource.com')
145
+ @test_object2.external.first.dsLabel.should == "http://myreasource.com"
146
146
  #check datastreams added to fedora (may want to stub this at first)
147
147
  end
148
148
  end
149
-
149
+
150
150
  describe '#add_named_file_datastream' do
151
151
  before do
152
152
  class MockAddNamedFileDatastream < ActiveFedora::Base
153
153
  include ActiveFedora::DatastreamCollections
154
- has_datastream :name => 'thumbnail', :prefix => 'THUMB', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
155
- has_datastream :name => 'high', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
156
- has_datastream :name => 'anymime', :type => ActiveFedora::Datastream, :controlGroup => 'M'
154
+ has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
155
+ has_datastream :name=>"high", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
156
+ has_datastream :name=>"anymime", :type=>ActiveFedora::Datastream, :controlGroup=>'M'
157
157
  end
158
158
  end
159
-
159
+
160
160
  it 'should add a datastream as controlGroup M with blob set to file' do
161
161
  @test_object2 = MockAddNamedFileDatastream.new
162
- f = File.new(File.join( File.dirname(__FILE__), '../fixtures/minivan.jpg'))
162
+ f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"))
163
163
  #these normally supplied in multi-part post request
164
- allow(f).to receive(:original_filename).and_return('minivan.jpg')
165
- allow(f).to receive(:content_type).and_return('image/jpeg')
166
- @test_object2.add_named_file_datastream('thumbnail', f)
164
+ f.stub(:original_filename).and_return("minivan.jpg")
165
+ f.stub(:content_type).and_return("image/jpeg")
166
+ @test_object2.add_named_file_datastream("thumbnail",f)
167
167
  thumb = @test_object2.thumbnail.first
168
- expect(thumb.class).to eq(ActiveFedora::Datastream)
169
- expect(thumb.mimeType).to eq('image/jpeg')
170
- expect(thumb.dsid).to eq('THUMB1')
171
- expect(thumb.controlGroup).to eq('M')
172
- expect(thumb.dsLabel).to eq('minivan.jpg')
168
+ thumb.class.should == ActiveFedora::Datastream
169
+ thumb.mimeType.should == "image/jpeg"
170
+ thumb.dsid.should == "THUMB1"
171
+ thumb.controlGroup.should == "M"
172
+ thumb.dsLabel.should == "minivan.jpg"
173
173
  #thumb.name.should == "thumbnail"
174
- # :prefix=>"THUMB", :content_type=>"image/jpeg", :dsid=>"THUMB1", :dsID=>"THUMB1",
174
+ # :prefix=>"THUMB", :content_type=>"image/jpeg", :dsid=>"THUMB1", :dsID=>"THUMB1",
175
175
  # :pid=>@test_object2.pid, :mimeType=>"image/jpeg", :controlGroup=>"M", :dsLabel=>"minivan.jpg", :name=>"thumbnail"}
176
-
176
+
177
177
  end
178
178
  end
179
179
 
@@ -181,72 +181,72 @@ describe ActiveFedora::DatastreamCollections do
181
181
  before do
182
182
  class MockUpdateNamedDatastream < ActiveFedora::Base
183
183
  include ActiveFedora::DatastreamCollections
184
- has_datastream :name => 'thumbnail', :prefix => 'THUMB', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
184
+ has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
185
185
  end
186
186
  end
187
-
187
+
188
188
  it 'should update a datastream and not increment the dsid' do
189
189
  @test_object2 = MockUpdateNamedDatastream.new
190
- f = File.new(File.join( File.dirname(__FILE__), '../fixtures/minivan.jpg'))
191
- f2 = File.new(File.join( File.dirname(__FILE__), '../fixtures/dino.jpg' ))
192
- allow(f).to receive(:content_type).and_return('image/jpeg')
193
- allow(f).to receive(:original_filename).and_return('minivan.jpg')
194
- allow(f2).to receive(:content_type).and_return('image/jpeg')
195
- allow(f2).to receive(:original_filename).and_return('dino.jpg')
190
+ f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"))
191
+ f2 = File.new(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ))
192
+ f.stub(:content_type).and_return("image/jpeg")
193
+ f.stub(:original_filename).and_return("minivan.jpg")
194
+ f2.stub(:content_type).and_return("image/jpeg")
195
+ f2.stub(:original_filename).and_return("dino.jpg")
196
196
  #check raise exception if dsid not supplied
197
- @test_object2.add_named_datastream('thumbnail', {:file => f})
197
+ @test_object2.add_named_datastream("thumbnail",{:file=>f})
198
198
  had_exception = false
199
199
  begin
200
- @test_object2.update_named_datastream('thumbnail', {:file => f})
200
+ @test_object2.update_named_datastream("thumbnail",{:file=>f})
201
201
  rescue
202
202
  had_exception = true
203
203
  end
204
- raise 'Failed to raise exception if dsid not supplied' unless had_exception
204
+ raise "Failed to raise exception if dsid not supplied" unless had_exception
205
205
  #raise exception if dsid does not exist
206
206
  had_exception = false
207
207
  begin
208
- @test_object2.update_named_datastream('thumbnail', {:file => f, :dsid => 'THUMB100'})
208
+ @test_object2.update_named_datastream("thumbnail",{:file=>f,:dsid=>"THUMB100"})
209
209
  rescue
210
210
  had_exception = true
211
211
  end
212
- raise 'Failed to raise exception if dsid does not exist' unless had_exception
213
- #check datastream is updated in place without new dsid
214
- expect(@test_object2.thumbnail.size).to eq(1)
215
- @test_object2.thumbnail_ids == ['THUMB1']
212
+ raise "Failed to raise exception if dsid does not exist" unless had_exception
213
+ #check datastream is updated in place without new dsid
214
+ @test_object2.thumbnail.size.should == 1
215
+ @test_object2.thumbnail_ids == ["THUMB1"]
216
216
  thumb1 = @test_object2.thumbnail.first
217
- expect(thumb1.dsid).to eq('THUMB1')
218
- expect(thumb1.pid).to eq(@test_object2.pid)
219
- expect(thumb1.dsLabel).to eq('minivan.jpg')
217
+ thumb1.dsid.should == 'THUMB1'
218
+ thumb1.pid.should == @test_object2.pid
219
+ thumb1.dsLabel.should == 'minivan.jpg'
220
220
  f.rewind
221
- @test_object2.update_named_datastream('thumbnail', {:file => f2, :dsid => 'THUMB1'})
222
- expect(@test_object2.thumbnail.size).to eq(1)
223
- @test_object2.thumbnail_ids == ['THUMB1']
221
+ @test_object2.update_named_datastream("thumbnail",{:file=>f2,:dsid=>"THUMB1"})
222
+ @test_object2.thumbnail.size.should == 1
223
+ @test_object2.thumbnail_ids == ["THUMB1"]
224
224
  # @test_object2.thumbnail.first.attributes.should == {:type=>"ActiveFedora::Datastream",
225
- # :content_type=>"image/jpeg",
226
- # :prefix=>"THUMB", :mimeType=>"image/jpeg",
227
- # :controlGroup=>"M", :dsid=>"THUMB1",
228
- # :pid=>@test_object2.pid, :dsID=>"THUMB1",
225
+ # :content_type=>"image/jpeg",
226
+ # :prefix=>"THUMB", :mimeType=>"image/jpeg",
227
+ # :controlGroup=>"M", :dsid=>"THUMB1",
228
+ # :pid=>@test_object2.pid, :dsID=>"THUMB1",
229
229
  # :name=>"thumbnail", :dsLabel=>"dino.jpg"}
230
230
  thumb1 = @test_object2.thumbnail.first
231
- expect(thumb1.dsid).to eq('THUMB1')
232
- expect(thumb1.pid).to eq(@test_object2.pid)
233
- expect(thumb1.dsLabel).to eq('dino.jpg')
231
+ thumb1.dsid.should == 'THUMB1'
232
+ thumb1.pid.should == @test_object2.pid
233
+ thumb1.dsLabel.should == 'dino.jpg'
234
234
  end
235
235
  end
236
236
  describe '#named_datastreams_desc' do
237
-
237
+
238
238
  before do
239
239
  class MockNamedDatastreamsDesc < ActiveFedora::Base
240
240
  include ActiveFedora::DatastreamCollections
241
- has_datastream :name => 'thumbnail', :prefix => 'THUMB', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
241
+ has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
242
242
  end
243
243
  end
244
-
244
+
245
245
  it 'should intialize a value to an empty hash and then not modify afterward' do
246
246
  @test_object2 = MockNamedDatastreamsDesc.new
247
- expect(@test_object2.named_datastreams_desc).to eq({'thumbnail' => {:name => 'thumbnail', :prefix => 'THUMB',
248
- :type => 'ActiveFedora::Datastream', :mimeType => 'image/jpeg',
249
- :controlGroup => 'M'}})
247
+ @test_object2.named_datastreams_desc.should == {"thumbnail"=>{:name=>"thumbnail",:prefix => "THUMB",
248
+ :type=>"ActiveFedora::Datastream", :mimeType=>"image/jpeg",
249
+ :controlGroup=>'M'}}
250
250
  end
251
251
  end
252
252
 
@@ -254,166 +254,166 @@ describe ActiveFedora::DatastreamCollections do
254
254
  before do
255
255
  class MockIsNamedDatastream < ActiveFedora::Base
256
256
  include ActiveFedora::DatastreamCollections
257
- has_datastream :name => 'thumbnail', :prefix => 'THUMB', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
257
+ has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
258
258
  end
259
259
  end
260
-
260
+
261
261
  it 'should return true if a named datastream exists in model' do
262
262
  @test_object2 = MockIsNamedDatastream.new
263
- expect(@test_object2.is_named_datastream?('thumbnail')).to eq(true)
264
- expect(@test_object2.is_named_datastream?('thumb')).to eq(false)
263
+ @test_object2.is_named_datastream?("thumbnail").should == true
264
+ @test_object2.is_named_datastream?("thumb").should == false
265
265
  end
266
266
  end
267
-
268
-
267
+
268
+
269
269
  describe '#named_datastreams' do
270
270
  before do
271
271
  class MockNamedDatastreams < ActiveFedora::Base
272
272
  include ActiveFedora::DatastreamCollections
273
- has_datastream :name => 'thumbnail', :prefix => 'THUMB', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
274
- has_datastream :name => 'high', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
275
- has_datastream :name => 'external', :type => ActiveFedora::Datastream, :controlGroup => 'E'
273
+ has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
274
+ has_datastream :name=>"high", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
275
+ has_datastream :name=>"external", :type=>ActiveFedora::Datastream, :controlGroup=>'E'
276
276
  end
277
277
  end
278
-
278
+
279
279
  it 'should return a hash of datastream names to arrays of datastreams' do
280
280
  @test_object2 = MockNamedDatastreams.new
281
- f = File.new(File.join( File.dirname(__FILE__), '../fixtures/minivan.jpg' ))
282
- allow(f).to receive(:content_type).and_return('image/jpeg')
283
- allow(f).to receive(:original_filename).and_return('minivan.jpg')
284
- f2 = File.new(File.join( File.dirname(__FILE__), '../fixtures/dino.jpg' ))
285
- allow(f2).to receive(:content_type).and_return('image/jpeg')
286
- allow(f2).to receive(:original_filename).and_return('dino.jpg')
281
+ f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg" ))
282
+ f.stub(:content_type).and_return("image/jpeg")
283
+ f.stub(:original_filename).and_return("minivan.jpg")
284
+ f2 = File.new(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ))
285
+ f2.stub(:content_type).and_return("image/jpeg")
286
+ f2.stub(:original_filename).and_return("dino.jpg")
287
287
  @test_object2.thumbnail_file_append(f)
288
288
  @test_object2.high_file_append(f2)
289
- @test_object2.external_append({:dsLocation => 'http://myresource.com'})
289
+ @test_object2.external_append({:dsLocation=>"http://myresource.com"})
290
290
  datastreams = @test_object2.named_datastreams
291
- expect(datastreams.keys.include?('thumbnail')).to eq(true)
292
- expect(datastreams.keys.include?('external')).to eq(true)
293
- expect(datastreams.keys.include?('high')).to eq(true)
294
- expect(datastreams.keys.size).to eq(3)
295
- expect(datastreams['thumbnail'].size).to eq(1)
296
- expect(datastreams['thumbnail'].first.dsid).to eq('THUMB1')
297
- expect(datastreams['thumbnail'].first.dsLabel).to eq('minivan.jpg')
298
- expect(datastreams['thumbnail'].first.controlGroup).to eq('M')
299
-
300
- expect(datastreams['external'].size).to eq(1)
301
- expect(datastreams['external'].first.dsid).to eq('EXTERNAL1')
302
- expect(datastreams['external'].first.dsLocation).to eq('http://myresource.com')
303
- expect(datastreams['external'].first.controlGroup).to eq('E')
304
- expect(datastreams['external'].first.content).to eq('')
305
-
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')
291
+ datastreams.keys.include?("thumbnail").should == true
292
+ datastreams.keys.include?("external").should == true
293
+ datastreams.keys.include?("high").should == true
294
+ datastreams.keys.size.should == 3
295
+ datastreams["thumbnail"].size.should == 1
296
+ datastreams["thumbnail"].first.dsid.should == 'THUMB1'
297
+ datastreams["thumbnail"].first.dsLabel.should == 'minivan.jpg'
298
+ datastreams["thumbnail"].first.controlGroup.should == "M"
299
+
300
+ datastreams["external"].size.should == 1
301
+ datastreams["external"].first.dsid.should == "EXTERNAL1"
302
+ datastreams["external"].first.dsLocation.should == "http://myresource.com"
303
+ datastreams["external"].first.controlGroup.should == "E"
304
+ datastreams["external"].first.content.should == ""
305
+
306
+ datastreams["high"].size.should == 1
307
+ datastreams["high"].first.dsLabel.should == 'dino.jpg'
308
+ datastreams["high"].first.controlGroup.should == "M"
309
+ datastreams["high"].first.dsid.should == "HIGH1"
310
310
  end
311
311
  end
312
-
313
-
314
-
312
+
313
+
314
+
315
315
  describe '#named_datastreams_ids' do
316
316
  before do
317
317
  class MockNamedDatastreamsIds < ActiveFedora::Base
318
318
  include ActiveFedora::DatastreamCollections
319
- has_datastream :name => 'thumbnail', :prefix => 'THUMB', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
320
- has_datastream :name => 'high', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
321
- has_datastream :name => 'external', :type => ActiveFedora::Datastream, :controlGroup => 'E'
319
+ has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
320
+ has_datastream :name=>"high", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
321
+ has_datastream :name=>"external", :type=>ActiveFedora::Datastream, :controlGroup=>'E'
322
322
  end
323
323
  end
324
-
324
+
325
325
  it 'should provide a hash of datastreams names to array of datastream ids' do
326
326
  @test_object2 = MockNamedDatastreamsIds.new
327
- f = File.new(File.join( File.dirname(__FILE__), '../fixtures/minivan.jpg' ))
328
- allow(f).to receive(:content_type).and_return('image/jpeg')
329
- allow(f).to receive(:original_filename).and_return('minivan.jpg')
330
- f2 = File.new(File.join( File.dirname(__FILE__), '../fixtures/dino.jpg' ))
331
- allow(f2).to receive(:content_type).and_return('image/jpeg')
332
- allow(f2).to receive(:original_filename).and_return('dino.jpg')
327
+ f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg" ))
328
+ f.stub(:content_type).and_return("image/jpeg")
329
+ f.stub(:original_filename).and_return("minivan.jpg")
330
+ f2 = File.new(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ))
331
+ f2.stub(:content_type).and_return("image/jpeg")
332
+ f2.stub(:original_filename).and_return("dino.jpg")
333
333
  @test_object2.thumbnail_file_append(f)
334
334
  @test_object2.high_file_append(f2)
335
- @test_object2.external_append({:dsLocation => 'http://myresource.com'})
336
- expect(@test_object2.named_datastreams_ids).to eq({'thumbnail' => ['THUMB1'], 'high' => ['HIGH1'], 'external' => ['EXTERNAL1']})
335
+ @test_object2.external_append({:dsLocation=>"http://myresource.com"})
336
+ @test_object2.named_datastreams_ids.should == {"thumbnail"=>["THUMB1"],"high"=>["HIGH1"],"external"=>["EXTERNAL1"]}
337
337
  end
338
338
  end
339
-
340
-
339
+
340
+
341
341
  describe '#create_named_datastream_finders' do
342
342
  before do
343
343
  class MockCreateNamedDatastreamFinder < ActiveFedora::Base
344
344
  include ActiveFedora::DatastreamCollections
345
- has_datastream :name => 'thumbnail', :prefix => 'THUMB', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
346
- has_datastream :name => 'high', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
345
+ has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
346
+ has_datastream :name=>"high", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
347
347
  end
348
348
  end
349
-
349
+
350
350
  it 'should create helper methods to get named datastreams or dsids' do
351
351
  @test_object2 = MockCreateNamedDatastreamFinder.new
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
- f = File.new(File.join( File.dirname(__FILE__), '../fixtures/minivan.jpg'))
357
- f2 = File.new(File.join( File.dirname(__FILE__), '../fixtures/dino.jpg' ))
358
- allow(f2).to receive(:original_filename).and_return('dino.jpg')
359
- allow(f).to receive(:content_type).and_return('image/jpeg')
360
- @test_object2.add_named_datastream('thumbnail', {:content_type => 'image/jpeg', :blob => f, :label => 'testDS'})
361
- @test_object2.add_named_datastream('high', {:content_type => 'image/jpeg', :blob => f2})
362
- @test_object2.add_named_datastream('high', {:content_type => 'image/jpeg', :blob => f2})
352
+ @test_object2.should respond_to(:thumbnail)
353
+ @test_object2.should respond_to(:thumbnail_ids)
354
+ @test_object2.should respond_to(:high)
355
+ @test_object2.should respond_to(:high_ids)
356
+ f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"))
357
+ f2 = File.new(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ))
358
+ f2.stub(:original_filename).and_return("dino.jpg")
359
+ f.stub(:content_type).and_return("image/jpeg")
360
+ @test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f, :label=>"testDS"})
361
+ @test_object2.add_named_datastream("high",{:content_type=>"image/jpeg",:blob=>f2})
362
+ @test_object2.add_named_datastream("high",{:content_type=>"image/jpeg",:blob=>f2})
363
363
  t2_thumb1 = @test_object2.thumbnail.first
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
- # :type=>"ActiveFedora::Datastream",
370
- # :prefix=>"THUMB", :content_type=>"image/jpeg", :dsid=>"THUMB1", :dsID=>"THUMB1",
364
+ t2_thumb1.mimeType.should == "image/jpeg"
365
+ t2_thumb1.controlGroup.should == "M"
366
+ t2_thumb1.dsLabel.should == "testDS"
367
+ t2_thumb1.pid.should == @test_object2.pid
368
+ t2_thumb1.dsid.should == "THUMB1"
369
+ # :type=>"ActiveFedora::Datastream",
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
- expect(@test_object2.thumbnail_ids).to eq(['THUMB1'])
373
- @test_object2.high_ids.include?('HIGH1') == true
374
- @test_object2.high_ids.include?('HIGH2') == true
375
- expect(@test_object2.high_ids.size).to eq(2)
372
+ @test_object2.thumbnail_ids.should == ["THUMB1"]
373
+ @test_object2.high_ids.include?("HIGH1") == true
374
+ @test_object2.high_ids.include?("HIGH2") == true
375
+ @test_object2.high_ids.size.should == 2
376
376
  #just check returning datastream object at this point
377
- expect(@test_object2.high.first.class).to eq(ActiveFedora::Datastream)
377
+ @test_object2.high.first.class.should == ActiveFedora::Datastream
378
378
  end
379
379
  end
380
-
380
+
381
381
  describe '#create_named_datastream_update_methods' do
382
382
  before do
383
383
  class MockCreateNamedDatastreamUpdateMethods < ActiveFedora::Base
384
384
  include ActiveFedora::DatastreamCollections
385
- has_datastream :name => 'thumbnail', :prefix => 'THUMB', :type => ActiveFedora::Datastream, :mimeType => 'image/jpeg', :controlGroup => 'M'
386
- has_datastream :name => 'EAD', :type => ActiveFedora::Datastream, :mimeType => 'application/xml', :controlGroup => 'M'
387
- has_datastream :name => 'external', :type => ActiveFedora::Datastream, :controlGroup => 'E'
385
+ has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
386
+ has_datastream :name=>"EAD", :type=>ActiveFedora::Datastream, :mimeType=>"application/xml", :controlGroup=>'M'
387
+ has_datastream :name=>"external", :type=>ActiveFedora::Datastream, :controlGroup=>'E'
388
388
  end
389
389
  end
390
-
390
+
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
- expect(@test_object2).to respond_to(:thumbnail_append)
395
- expect(@test_object2).to respond_to(:ead_append)
396
- f = File.new(File.join( File.dirname(__FILE__), '../fixtures/minivan.jpg'))
397
- allow(f).to receive(:content_type).and_return('image/jpeg')
398
- allow(f).to receive(:original_filename).and_return('minivan.jpg')
394
+ @test_object2.should respond_to(:thumbnail_append)
395
+ @test_object2.should respond_to(:ead_append)
396
+ f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"))
397
+ f.stub(:content_type).and_return("image/jpeg")
398
+ f.stub(:original_filename).and_return("minivan.jpg")
399
399
  @test_object2.thumbnail_file_append(f)
400
400
  t2_thumb1 = @test_object2.thumbnail.first
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
- @test_object3.thumbnail_append({:file => f})
401
+ t2_thumb1.mimeType.should == "image/jpeg"
402
+ t2_thumb1.dsLabel.should == "minivan.jpg"
403
+ t2_thumb1.pid.should == @test_object2.pid
404
+ t2_thumb1.dsid.should == "THUMB1"
405
+ @test_object3.thumbnail_append({:file=>f})
406
406
  t3_thumb1 = @test_object3.thumbnail.first
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
- @test_object3.external_append({:dsLocation => 'http://myresource.com'})
407
+ t3_thumb1.mimeType.should == "image/jpeg"
408
+ t3_thumb1.dsLabel.should == "minivan.jpg"
409
+ t3_thumb1.pid.should == @test_object3.pid
410
+ t3_thumb1.dsid.should == "THUMB1"
411
+ @test_object3.external_append({:dsLocation=>"http://myresource.com"})
412
412
  t3_external1 = @test_object3.external.first
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')
413
+ t3_external1.dsLabel.should == "http://myresource.com"
414
+ t3_external1.dsLocation.should == "http://myresource.com"
415
+ t3_external1.pid.should == @test_object3.pid
416
+ t3_external1.dsid.should == "EXTERNAL1"
417
417
  t3_external1.controlGroup == 'E'
418
418
  end
419
419
  end