ddr-models 1.14.1 → 1.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ FactoryGirl.define do
4
4
  title [ "Test Component" ]
5
5
  sequence(:identifier) { |n| [ "cmp%05d" % n ] }
6
6
  after(:build) do |c|
7
- c.upload File.new(File.join(Ddr::Models::Engine.root.to_s, "spec", "fixtures", "library-devil.tiff"))
7
+ c.upload File.new(File.join(Ddr::Models::Engine.root.to_s, "spec", "fixtures", "imageA.tif"))
8
8
  end
9
9
  end
10
10
  end
@@ -56,7 +56,7 @@ FactoryGirl.define do
56
56
  title [ "DulHydra Test Content Object" ]
57
57
  sequence(:identifier) { |n| [ "testcontent%05d" % n ] }
58
58
  after(:build) do |c|
59
- c.upload File.join(Ddr::Models::Engine.root, "spec", "fixtures", "library-devil.tiff")
59
+ c.upload File.join(Ddr::Models::Engine.root, "spec", "fixtures", "imageA.tif")
60
60
  end
61
61
 
62
62
  factory :test_content_with_fixity_check do
@@ -68,7 +68,7 @@ FactoryGirl.define do
68
68
  title [ "DulHydra Test Omnibus Object" ]
69
69
  sequence(:identifier) { |n| [ "test%05d" % n ] }
70
70
  after(:build) do |c|
71
- c.upload File.join(Ddr::Models::Engine.root, "spec", "fixtures", "library-devil.tiff")
71
+ c.upload File.join(Ddr::Models::Engine.root, "spec", "fixtures", "imageA.tif")
72
72
  end
73
73
  end
74
74
 
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -12,14 +12,14 @@ module Ddr
12
12
  include Ddr::Models::EventLoggable
13
13
  _save_callbacks.clear
14
14
  end
15
- # class MultiresImageable < ContentBearing
16
- # include Ddr::Models::HasMultiresImage
17
- # _save_callbacks.clear
18
- # end
15
+ class MultiresImageable < ContentBearing
16
+ include Ddr::Models::HasMultiresImage
17
+ _save_callbacks.clear
18
+ end
19
19
  end
20
20
 
21
21
  after(:all) do
22
- # Ddr::Managers.send(:remove_const, :MultiresImageable)
22
+ Ddr::Managers.send(:remove_const, :MultiresImageable)
23
23
  Ddr::Managers.send(:remove_const, :ContentBearing)
24
24
  end
25
25
 
@@ -28,10 +28,10 @@ module Ddr
28
28
  context "not multires_image_able" do
29
29
  let(:object) { ContentBearing.new }
30
30
  context "content is image" do
31
- let(:file) { fixture_file_upload("image1.tiff", "image/tiff") }
31
+ let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
32
32
  it "should generate a thumbnail and not a ptif" do
33
33
  expect(object.derivatives).to receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:thumbnail])
34
- # expect(object.derivatives).to_not receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:multires_image])
34
+ expect(object.derivatives).to_not receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:multires_image])
35
35
  object.derivatives.update_derivatives(:now)
36
36
  end
37
37
  end
@@ -39,7 +39,7 @@ module Ddr
39
39
  let(:file) { fixture_file_upload("sample.pdf", "application/pdf") }
40
40
  it "should generate a thumbnail and not a ptif" do
41
41
  expect(object.derivatives).to receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:thumbnail])
42
- # expect(object.derivatives).to_not receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:multires_image])
42
+ expect(object.derivatives).to_not receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:multires_image])
43
43
  object.derivatives.update_derivatives(:now)
44
44
  end
45
45
  end
@@ -47,34 +47,34 @@ module Ddr
47
47
  let(:file) { fixture_file_upload("sample.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document") }
48
48
  it "should generate neither a thumbnail nor a ptif" do
49
49
  expect(object.derivatives).to_not receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:thumbnail])
50
- # expect(object.derivatives).to_not receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:multires_image])
50
+ expect(object.derivatives).to_not receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:multires_image])
51
+ object.derivatives.update_derivatives(:now)
52
+ end
53
+ end
54
+ end
55
+ context "multires_image_able" do
56
+ let(:object) { MultiresImageable.new }
57
+ context "content is tiff image" do
58
+ let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
59
+ it "should generate a thumbnail and a ptif" do
60
+ expect(object.derivatives).to receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:thumbnail])
61
+ expect(object.derivatives).to receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:multires_image])
62
+ object.derivatives.update_derivatives(:now)
63
+ end
64
+ end
65
+ context "content is not tiff image" do
66
+ let(:file) { fixture_file_upload("sample.pdf", "application/pdf") }
67
+ it "should generate a thumbnail but not a ptif" do
68
+ expect(object.derivatives).to receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:thumbnail])
69
+ expect(object.derivatives).to_not receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:multires_image])
51
70
  object.derivatives.update_derivatives(:now)
52
71
  end
53
72
  end
54
73
  end
55
- # context "multires_image_able" do
56
- # let(:object) { MultiresImageable.new }
57
- # context "content is tiff image" do
58
- # let(:file) { fixture_file_upload("image1.tiff", "image/tiff") }
59
- # it "should generate a thumbnail and a ptif" do
60
- # expect(object.derivatives).to receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:thumbnail])
61
- # expect(object.derivatives).to receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:multires_image])
62
- # object.derivatives.update_derivatives(:now)
63
- # end
64
- # end
65
- # context "content is not tiff image" do
66
- # let(:file) { fixture_file_upload("sample.pdf", "application/pdf") }
67
- # it "should generate a thumbnail but not a ptif" do
68
- # expect(object.derivatives).to receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:thumbnail])
69
- # expect(object.derivatives).to_not receive(:generate_derivative!).with(Ddr::Derivatives::DERIVATIVES[:multires_image])
70
- # object.derivatives.update_derivatives(:now)
71
- # end
72
- # end
73
- # end
74
74
  end
75
75
 
76
76
  describe "derivative generation" do
77
- let(:file) { fixture_file_upload("image1.tiff", "image/tiff") }
77
+ let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
78
78
  before { object.upload! file }
79
79
  describe "thumbnail" do
80
80
  let(:object) { ContentBearing.create }
@@ -82,26 +82,27 @@ module Ddr
82
82
  expect(object.datastreams[Ddr::Datastreams::THUMBNAIL]).to_not be_present
83
83
  object.derivatives.generate_derivative! Ddr::Derivatives::DERIVATIVES[:thumbnail]
84
84
  expect(object.datastreams[Ddr::Datastreams::THUMBNAIL]).to be_present
85
+ expect(object.datastreams[Ddr::Datastreams::THUMBNAIL].size).to be > 0
86
+ end
87
+ end
88
+ describe "ptif" do
89
+ let(:object) { MultiresImageable.create }
90
+ it "should create content in the multires image datastream" do
91
+ expect(object.datastreams[Ddr::Datastreams::MULTIRES_IMAGE]).to_not be_present
92
+ object.derivatives.generate_derivative! Ddr::Derivatives::DERIVATIVES[:multires_image]
93
+ expect(object.datastreams[Ddr::Datastreams::MULTIRES_IMAGE]).to be_present
94
+ file_uri = object.datastreams[Ddr::Datastreams::MULTIRES_IMAGE].dsLocation
95
+ expect(File.size(Ddr::Utils.path_from_uri(file_uri))).to be > 0
85
96
  end
86
97
  end
87
- # describe "ptif" do
88
- # let(:object) { MultiresImageable.create }
89
- # it "should create content in the multires image datastream" do
90
- # expect(object.datastreams[Ddr::Datastreams::MULTIRES_IMAGE]).to_not be_present
91
- # object.derivatives.generate_derivative! Ddr::Derivatives::DERIVATIVES[:multires_image]
92
- # expect(object.datastreams[Ddr::Datastreams::MULTIRES_IMAGE]).to be_present
93
- # end
94
- # end
95
98
  end
96
99
 
97
100
  describe "event creation" do
98
- let(:file) { fixture_file_upload("image1.tiff", "image/tiff") }
101
+ let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
99
102
  before { object.upload! file }
100
- # let(:object) { MultiresImageable.create }
101
- let(:object) { ContentBearing.create }
103
+ let(:object) { MultiresImageable.create }
102
104
  it "should create an update event for each derivative updated" do
103
- # expect {object.derivatives.update_derivatives(:now) }.to change { object.update_events.count }.by(2)
104
- expect {object.derivatives.update_derivatives(:now) }.to change { object.update_events.count }.by(1)
105
+ expect {object.derivatives.update_derivatives(:now) }.to change { object.update_events.count }.by(2)
105
106
  end
106
107
  end
107
108
 
@@ -23,7 +23,7 @@ module Ddr
23
23
  RSpec.describe FileManagement, :type => :model do
24
24
 
25
25
  let(:object) { FileManageable.new(pid: 'test:543') }
26
- let(:file) { fixture_file_upload("library-devil.tiff", "image/tiff") }
26
+ let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
27
27
 
28
28
  before(:all) do
29
29
  class FileManageable < ActiveFedora::Base
@@ -178,9 +178,9 @@ module Ddr
178
178
  end
179
179
 
180
180
  describe "#external_datastream_file_paths" do
181
- let(:file1) { fixture_file_upload("image1.tiff", "image/tiff") }
182
- let(:file2) { fixture_file_upload("image2.tiff", "image/tiff") }
183
- let(:file3) { fixture_file_upload("image3.tiff", "image/tiff") }
181
+ let(:file1) { fixture_file_upload("imageA.tif", "image/tiff") }
182
+ let(:file2) { fixture_file_upload("imageB.tif", "image/tiff") }
183
+ let(:file3) { fixture_file_upload("imageC.tif", "image/tiff") }
184
184
  before do
185
185
  object.add_file(file1, "e_content")
186
186
  object.save
@@ -199,9 +199,9 @@ module Ddr
199
199
  end
200
200
 
201
201
  describe "cleanup on destroy" do
202
- let(:file1) { fixture_file_upload("image1.tiff", "image/tiff") }
203
- let(:file2) { fixture_file_upload("image2.tiff", "image/tiff") }
204
- let(:file3) { fixture_file_upload("image3.tiff", "image/tiff") }
202
+ let(:file1) { fixture_file_upload("imageA.tif", "image/tiff") }
203
+ let(:file2) { fixture_file_upload("imageB.tif", "image/tiff") }
204
+ let(:file3) { fixture_file_upload("imageC.tif", "image/tiff") }
205
205
  before do
206
206
  object.add_file(file1, "e_content")
207
207
  object.save
@@ -12,7 +12,7 @@ RSpec.shared_examples "an object that can have content" do
12
12
  end
13
13
 
14
14
  describe "indexing" do
15
- let(:file) { fixture_file_upload("library-devil.tiff", "image/tiff") }
15
+ let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
16
16
  before { subject.upload file }
17
17
  it "should index the content ds control group" do
18
18
  expect(subject.to_solr).to include(Ddr::IndexFields::CONTENT_CONTROL_GROUP)
@@ -36,11 +36,11 @@ RSpec.shared_examples "an object that can have content" do
36
36
  end
37
37
 
38
38
  describe "adding a file" do
39
- let(:file) { fixture_file_upload("library-devil.tiff", "image/tiff") }
39
+ let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
40
40
  context "defaults" do
41
41
  before { subject.add_file file, "content" }
42
42
  it "should have an original_filename" do
43
- expect(subject.original_filename).to eq("library-devil.tiff")
43
+ expect(subject.original_filename).to eq("imageA.tif")
44
44
  end
45
45
  it "should have a content_type" do
46
46
  expect(subject.content_type).to eq("image/tiff")
@@ -69,7 +69,7 @@ RSpec.shared_examples "an object that can have content" do
69
69
 
70
70
  context "and it's a new object" do
71
71
  before { subject.add_file file, "content" }
72
- let(:file) { fixture_file_upload("library-devil.tiff", "image/tiff") }
72
+ let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
73
73
  it "should generate derivatives" do
74
74
  expect(subject.derivatives).to receive(:update_derivatives)
75
75
  subject.save
@@ -77,8 +77,8 @@ RSpec.shared_examples "an object that can have content" do
77
77
  end
78
78
 
79
79
  context "and it's an existing object with content" do
80
- before { subject.upload! fixture_file_upload('library-devil.tiff', 'image/tiff') }
81
- let(:file) { fixture_file_upload("image1.tiff", "image/tiff") }
80
+ before { subject.upload! fixture_file_upload('imageA.tif', 'image/tiff') }
81
+ let(:file) { fixture_file_upload("imageB.tif", "image/tiff") }
82
82
  it "should generate derivatives" do
83
83
  expect(subject.derivatives).to receive(:update_derivatives)
84
84
  subject.upload! file
@@ -88,7 +88,7 @@ RSpec.shared_examples "an object that can have content" do
88
88
  end
89
89
 
90
90
  describe "#upload" do
91
- let(:file) { fixture_file_upload("library-devil.tiff", "image/tiff") }
91
+ let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
92
92
  it "should add the file to the content datastream" do
93
93
  expect(subject).to receive(:add_file).with(file, "content", {})
94
94
  subject.upload(file)
@@ -96,7 +96,7 @@ RSpec.shared_examples "an object that can have content" do
96
96
  end
97
97
 
98
98
  describe "#upload!" do
99
- let(:file) { fixture_file_upload("library-devil.tiff", "image/tiff") }
99
+ let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
100
100
  it "should add the file to the content datastream and save the object" do
101
101
  expect(subject).to receive(:add_file).with(file, "content", {}).and_call_original
102
102
  expect(subject).to receive(:save)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.1
4
+ version: 1.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-05 00:00:00.000000000 Z
12
+ date: 2015-05-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -435,6 +435,8 @@ files:
435
435
  - spec/controllers/application_controller_spec.rb
436
436
  - spec/controllers/including_role_based_access_controls_enforcement_spec.rb
437
437
  - spec/controllers/users/sessions_controller_spec.rb
438
+ - spec/derivatives/png_generator_spec.rb
439
+ - spec/derivatives/ptif_generator_spec.rb
438
440
  - spec/dummy/README.rdoc
439
441
  - spec/dummy/Rakefile
440
442
  - spec/dummy/app/assets/javascripts/application.js
@@ -483,10 +485,11 @@ files:
483
485
  - spec/factories/target_factories.rb
484
486
  - spec/factories/test_model_factories.rb
485
487
  - spec/factories/user_factories.rb
486
- - spec/fixtures/image1.tiff
487
- - spec/fixtures/image2.tiff
488
- - spec/fixtures/image3.tiff
489
- - spec/fixtures/library-devil.tiff
488
+ - spec/fixtures/16bit.tif
489
+ - spec/fixtures/8bit.tif
490
+ - spec/fixtures/imageA.tif
491
+ - spec/fixtures/imageB.tif
492
+ - spec/fixtures/imageC.tif
490
493
  - spec/fixtures/sample.docx
491
494
  - spec/fixtures/sample.pdf
492
495
  - spec/fixtures/target.png
@@ -561,6 +564,8 @@ test_files:
561
564
  - spec/controllers/application_controller_spec.rb
562
565
  - spec/controllers/including_role_based_access_controls_enforcement_spec.rb
563
566
  - spec/controllers/users/sessions_controller_spec.rb
567
+ - spec/derivatives/png_generator_spec.rb
568
+ - spec/derivatives/ptif_generator_spec.rb
564
569
  - spec/dummy/app/assets/javascripts/application.js
565
570
  - spec/dummy/app/assets/stylesheets/application.css
566
571
  - spec/dummy/app/controllers/application_controller.rb
@@ -609,10 +614,11 @@ test_files:
609
614
  - spec/factories/target_factories.rb
610
615
  - spec/factories/test_model_factories.rb
611
616
  - spec/factories/user_factories.rb
612
- - spec/fixtures/image1.tiff
613
- - spec/fixtures/image2.tiff
614
- - spec/fixtures/image3.tiff
615
- - spec/fixtures/library-devil.tiff
617
+ - spec/fixtures/16bit.tif
618
+ - spec/fixtures/8bit.tif
619
+ - spec/fixtures/imageA.tif
620
+ - spec/fixtures/imageB.tif
621
+ - spec/fixtures/imageC.tif
616
622
  - spec/fixtures/sample.docx
617
623
  - spec/fixtures/sample.pdf
618
624
  - spec/fixtures/target.png
Binary file
Binary file
Binary file