hydra-derivatives 3.3.2 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +53 -34
  3. data/.rubocop_todo.yml +42 -9
  4. data/.travis.yml +12 -0
  5. data/Gemfile +3 -3
  6. data/Rakefile +1 -1
  7. data/VERSION +1 -1
  8. data/config/fcrepo_wrapper_test.yml +6 -0
  9. data/hydra-derivatives.gemspec +7 -10
  10. data/lib/hydra/derivatives.rb +2 -2
  11. data/lib/hydra/derivatives/audio_encoder.rb +1 -1
  12. data/lib/hydra/derivatives/io_decorator.rb +11 -6
  13. data/lib/hydra/derivatives/logger.rb +5 -1
  14. data/lib/hydra/derivatives/processors/active_encode.rb +1 -1
  15. data/lib/hydra/derivatives/processors/full_text.rb +5 -0
  16. data/lib/hydra/derivatives/processors/jpeg2k_image.rb +5 -8
  17. data/lib/hydra/derivatives/runners/full_text_extract.rb +1 -1
  18. data/lib/hydra/derivatives/services/capability_service.rb +1 -1
  19. data/lib/hydra/derivatives/services/persist_basic_contained_output_file_service.rb +5 -1
  20. data/lib/hydra/derivatives/services/persist_output_file_service.rb +4 -2
  21. data/spec/processors/active_encode_spec.rb +8 -8
  22. data/spec/processors/document_spec.rb +2 -2
  23. data/spec/processors/full_text_spec.rb +32 -12
  24. data/spec/processors/image_spec.rb +12 -10
  25. data/spec/processors/processor_spec.rb +4 -4
  26. data/spec/processors/video_spec.rb +5 -3
  27. data/spec/runners/active_encode_derivatives_spec.rb +2 -2
  28. data/spec/services/audio_derivatives_spec.rb +1 -1
  29. data/spec/services/persist_basic_contained_output_file_service_spec.rb +4 -2
  30. data/spec/services/remote_source_file_spec.rb +3 -3
  31. data/spec/services/tempfile_service_spec.rb +3 -2
  32. data/spec/units/config_spec.rb +2 -2
  33. data/spec/units/derivatives_spec.rb +6 -4
  34. data/spec/units/io_decorator_spec.rb +14 -2
  35. data/spec/units/logger_spec.rb +1 -1
  36. data/spec/units/transcoding_spec.rb +23 -15
  37. metadata +53 -52
@@ -20,14 +20,14 @@ describe Hydra::Derivatives::Processors::ActiveEncode do
20
20
  let(:external_url) { 'http://www.example.com/external/content' }
21
21
  let(:output) { [{ url: external_url }] }
22
22
  let(:encode_job_double) do
23
- enc = double('encode_job',
24
- state: state,
25
- errors: errors,
26
- output: output,
27
- running?: false,
28
- completed?: completed_status,
29
- failed?: failed_status,
30
- cancelled?: cancelled_status)
23
+ enc = instance_double('encode_job',
24
+ state: state,
25
+ errors: errors,
26
+ output: output,
27
+ running?: false,
28
+ completed?: completed_status,
29
+ failed?: failed_status,
30
+ cancelled?: cancelled_status)
31
31
  allow(enc).to receive(:reload).and_return(enc)
32
32
  enc
33
33
  end
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Hydra::Derivatives::Processors::Document do
4
+ subject { described_class.new(source_path, directives) }
5
+
4
6
  let(:source_path) { File.join(fixture_path, "test.doc") }
5
7
  let(:output_service) { Hydra::Derivatives::PersistBasicContainedOutputFileService }
6
8
 
7
9
  before { allow(subject).to receive(:converted_file).and_return(converted_file) }
8
10
 
9
- subject { described_class.new(source_path, directives) }
10
-
11
11
  describe "#encode_file" do
12
12
  context "when converting to jpg" do
13
13
  let(:directives) { { format: "jpg" } }
@@ -16,47 +16,54 @@ describe Hydra::Derivatives::Processors::FullText do
16
16
  end
17
17
 
18
18
  describe "fetch" do
19
+ subject { processor.send(:fetch) }
20
+
19
21
  let(:request) { double }
20
22
  let(:response_body) { 'returned by Solr' }
21
- let(:uri) { URI('http://example.com:99/solr/update') }
22
-
23
- subject { processor.send(:fetch) }
23
+ let(:uri) { URI('https://example.com:99/solr/update') }
24
24
 
25
25
  before do
26
26
  allow(processor).to receive(:uri).and_return(uri)
27
27
  allow(Net::HTTP).to receive(:new).with('example.com', 99).and_return(request)
28
28
  end
29
29
 
30
- context "that is successful" do
30
+ context "when that is successful" do
31
31
  let(:resp) { double(code: '200', type_params: {}, body: response_body) }
32
+
32
33
  it "calls the extraction service" do
33
- expect(request).to receive(:post).with('http://example.com:99/solr/update', String, "Content-Type" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Content-Length" => "24244").and_return(resp)
34
+ expect(processor).to receive(:check_for_ssl)
35
+ expect(request).to receive(:post).with('https://example.com:99/solr/update', String, "Content-Type" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Content-Length" => "24244").and_return(resp)
34
36
  expect(subject).to eq response_body
35
37
  end
36
38
  end
37
39
 
38
- context "that is successful with UTF-8 content" do
40
+ context "when that is successful with UTF-8 content" do
39
41
  let(:response_utf8) { "returned by “Solr”" }
40
42
  let(:response_ascii) { response_utf8.dup.force_encoding("ASCII-8BIT") }
41
43
  let(:resp) { double(code: '200', type_params: { "charset" => "UTF-8" }, body: response_ascii) }
44
+
42
45
  it "calls the extraction service" do
43
- expect(request).to receive(:post).with('http://example.com:99/solr/update', String, "Content-Type" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Content-Length" => "24244").and_return(resp)
46
+ expect(processor).to receive(:check_for_ssl)
47
+ expect(request).to receive(:post).with('https://example.com:99/solr/update', String, "Content-Type" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Content-Length" => "24244").and_return(resp)
44
48
  expect(subject).to eq response_utf8
45
49
  end
46
50
  end
47
51
 
48
- context "that fails" do
52
+ context "when that fails" do
49
53
  let(:resp) { double(code: '500', body: response_body) }
54
+
50
55
  it "raises an error" do
51
- expect(request).to receive(:post).with('http://example.com:99/solr/update', String, "Content-Type" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Content-Length" => "24244").and_return(resp)
52
- expect { subject }.to raise_error(RuntimeError, %r{^Solr Extract service was unsuccessful. 'http://example\.com:99/solr/update' returned code 500})
56
+ expect(processor).to receive(:check_for_ssl)
57
+ expect(request).to receive(:post).with('https://example.com:99/solr/update', String, "Content-Type" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Content-Length" => "24244").and_return(resp)
58
+ expect { subject }.to raise_error(RuntimeError, %r{^Solr Extract service was unsuccessful. 'https://example\.com:99/solr/update' returned code 500})
53
59
  end
54
60
  end
55
61
  end
56
62
 
57
63
  describe "uri" do
58
64
  subject { processor.send(:uri) }
59
- let(:root) { URI('http://example.com/solr/myCollection/') }
65
+
66
+ let(:root) { URI('https://example.com/solr/myCollection/') }
60
67
 
61
68
  before do
62
69
  allow(ActiveFedora::SolrService.instance.conn).to receive(:uri).and_return(root)
@@ -64,7 +71,20 @@ describe Hydra::Derivatives::Processors::FullText do
64
71
 
65
72
  it "points at the extraction service" do
66
73
  expect(subject).to be_kind_of URI
67
- expect(subject.to_s).to eq 'http://example.com/solr/myCollection/update/extract?extractOnly=true&wt=json&extractFormat=text'
74
+ expect(subject.to_s).to eq 'https://example.com/solr/myCollection/update/extract?extractOnly=true&wt=json&extractFormat=text'
75
+ end
76
+ end
77
+
78
+ describe "check_for_ssl" do
79
+ subject { processor.send(:check_for_ssl) }
80
+
81
+ it "returns false if uri.scheme is http" do
82
+ allow(processor).to receive(:uri).and_return(URI('http://example.com:99/solr/update'))
83
+ expect(subject).to be false
84
+ end
85
+ it "returns true if uri.scheme is https" do
86
+ allow(processor).to receive(:uri).and_return(URI('https://example.com:99/solr/update'))
87
+ expect(subject).to be true
68
88
  end
69
89
  end
70
90
  end
@@ -1,20 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Hydra::Derivatives::Processors::Image do
4
- let(:file_name) { "file_name" }
5
4
  subject { described_class.new(file_name, directives) }
6
5
 
6
+ let(:file_name) { "file_name" }
7
+
7
8
  context "when arguments are passed as a hash" do
8
9
  before { allow(subject).to receive(:load_image_transformer).and_return(mock_image) }
9
10
 
10
11
  context "with a multi-page pdf source file" do
11
- let(:first_page) { double("MockPage") }
12
- let(:second_page) { double("MockPage") }
13
- let(:mock_image) { double("MockImageOfPdf", layers: [first_page, second_page]) }
12
+ let(:first_page) { instance_double("MockPage") }
13
+ let(:second_page) { instance_double("MockPage") }
14
+ let(:mock_image) { instance_double("MockImageOfPdf", layers: [first_page, second_page]) }
14
15
 
15
16
  before { allow(mock_image).to receive(:type).and_return("PDF") }
16
17
 
17
- context "by default" do
18
+ context "when default" do
18
19
  let(:directives) { { label: :thumb, size: "200x300>", format: 'png', quality: 75 } }
19
20
 
20
21
  it "uses the first page" do
@@ -52,8 +53,8 @@ describe Hydra::Derivatives::Processors::Image do
52
53
  context "with an image source file" do
53
54
  before { allow(mock_image).to receive(:type).and_return("JPEG") }
54
55
 
55
- context "by default" do
56
- let(:mock_image) { double("MockImage") }
56
+ context "when default" do
57
+ let(:mock_image) { instance_double("MockImage") }
57
58
  let(:directives) { { label: :thumb, size: "200x300>", format: 'png', quality: 75 } }
58
59
 
59
60
  it "uses the image file" do
@@ -68,9 +69,9 @@ describe Hydra::Derivatives::Processors::Image do
68
69
  end
69
70
 
70
71
  context "when specifying a layer" do
71
- let(:first_layer) { double("MockPage") }
72
- let(:second_layer) { double("MockPage") }
73
- let(:mock_image) { double("MockImage", layers: [first_layer, second_layer]) }
72
+ let(:first_layer) { instance_double("MockPage") }
73
+ let(:second_layer) { instance_double("MockPage") }
74
+ let(:mock_image) { instance_double("MockImage", layers: [first_layer, second_layer]) }
74
75
  let(:directives) { { label: :thumb, size: "200x300>", format: 'png', quality: 75, layer: 1 } }
75
76
 
76
77
  it "uses the layer" do
@@ -113,6 +114,7 @@ describe Hydra::Derivatives::Processors::Image do
113
114
 
114
115
  context "when running the complete command", requires_imagemagick: true do
115
116
  let(:file_name) { File.join(fixture_path, "test.tif") }
117
+
116
118
  it "converts the image" do
117
119
  expect(Hydra::Derivatives::PersistBasicContainedOutputFileService).to receive(:call).with(kind_of(StringIO), directives)
118
120
  subject.process
@@ -1,18 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Hydra::Derivatives::Processors::Processor do
4
+ subject { described_class.new(file_path, directives) }
5
+
4
6
  let(:object) { "Fake Object" }
5
7
  let(:source_name) { 'content' }
6
8
  let(:directives) { { thumb: "100x100>" } }
7
9
  let(:file_path) { double }
8
10
 
9
- subject { described_class.new(file_path, directives) }
10
-
11
11
  describe "output_file_service" do
12
12
  let(:custom_output_file_service) { "fake service" }
13
13
  let(:another_custom_output_file_service) { "another fake service" }
14
14
 
15
- context "as a global configuration setting" do
15
+ context "with a global configuration setting" do
16
16
  before do
17
17
  allow(Hydra::Derivatives).to receive(:output_file_service).and_return(custom_output_file_service)
18
18
  end
@@ -21,7 +21,7 @@ describe Hydra::Derivatives::Processors::Processor do
21
21
  end
22
22
  end
23
23
 
24
- context "as an instance level configuration setting" do
24
+ context "with an instance level configuration setting" do
25
25
  subject do
26
26
  described_class.new('/opt/derivatives/foo.mp4', directives,
27
27
  output_file_service: another_custom_output_file_service)
@@ -1,9 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Hydra::Derivatives::Processors::Video::Processor do
4
- let(:file_name) { 'foo/bar.mov' }
5
4
  subject { described_class.new(file_name, directives) }
6
5
 
6
+ let(:file_name) { 'foo/bar.mov' }
7
+
7
8
  describe ".config" do
8
9
  before do
9
10
  @original_config = described_class.config.dup
@@ -20,7 +21,7 @@ describe Hydra::Derivatives::Processors::Video::Processor do
20
21
  end
21
22
 
22
23
  context "when arguments are passed as a hash" do
23
- context "and a video format is requested" do
24
+ context "when a video format is requested" do
24
25
  let(:directives) { { label: :thumb, format: 'webm', url: 'http://localhost:8983/fedora/rest/dev/1234/thumbnail' } }
25
26
 
26
27
  it "creates a fedora resource and infers the name" do
@@ -29,8 +30,9 @@ describe Hydra::Derivatives::Processors::Video::Processor do
29
30
  end
30
31
  end
31
32
 
32
- context "and jpg is requested" do
33
+ context "when a jpg is requested" do
33
34
  let(:directives) { { label: :thumb, format: 'jpg', url: 'http://localhost:8983/fedora/rest/dev/1234/thumbnail' } }
35
+
34
36
  it "creates a fedora resource and infers the name" do
35
37
  expect(subject).to receive(:encode_file).with("jpg", output_options: "-s 320x240 -vcodec mjpeg -vframes 1 -an -f rawvideo", input_options: " -itsoffset -2")
36
38
  subject.process
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Hydra::Derivatives::ActiveEncodeDerivatives do
4
- context '.create' do
4
+ describe '.create' do
5
5
  before do
6
6
  class TestVideo < ActiveFedora::Base
7
7
  attr_accessor :remote_file_name
@@ -14,7 +14,7 @@ describe Hydra::Derivatives::ActiveEncodeDerivatives do
14
14
  let(:video_record) { TestVideo.new(remote_file_name: file_path) }
15
15
  let(:options) { { source: :remote_file_name, outputs: [low_res_video] } }
16
16
  let(:low_res_video) { { some_key: 'some options to pass to my encoder service' } }
17
- let(:processor) { double('processor') }
17
+ let(:processor) { instance_double('processor') }
18
18
 
19
19
  it 'calls the processor with the right arguments' do
20
20
  expect(Hydra::Derivatives::Processors::ActiveEncode).to receive(:new).with(file_path, low_res_video, output_file_service: Hydra::Derivatives::PersistExternalFileOutputFileService).and_return(processor)
@@ -31,7 +31,7 @@ describe Hydra::Derivatives::AudioDerivatives do
31
31
  context "with an object" do
32
32
  let(:object) { "Fake Object" }
33
33
  let(:source_name) { :content }
34
- let(:file) { double("the file") }
34
+ let(:file) { instance_double("the file") }
35
35
 
36
36
  before do
37
37
  allow(object).to receive(:original_file).and_return(file)
@@ -19,7 +19,8 @@ describe Hydra::Derivatives::PersistBasicContainedOutputFileService do
19
19
  let(:object) { BasicContainerObject.create }
20
20
  let(:content) { StringIO.new("fake file content") }
21
21
  let(:resource) { object.public_send(destination_name.to_sym) }
22
- context "and the content is a stream" do
22
+
23
+ context "when the content is a stream" do
23
24
  it "persists the file to the specified destination on the given object" do
24
25
  described_class.call(content, format: 'jpg', url: "#{object.uri}/the_derivative_name")
25
26
  expect(resource.content).to start_with("fake file content")
@@ -28,8 +29,9 @@ describe Hydra::Derivatives::PersistBasicContainedOutputFileService do
28
29
  end
29
30
  end
30
31
 
31
- context "and content is a string" do
32
+ context "when the content is a string" do
32
33
  let(:content) { "fake file content - ÅÄÖ" }
34
+
33
35
  it "persists the file to the specified destination on the given object" do
34
36
  described_class.call(content, format: 'txt', url: "#{object.uri}/the_derivative_name")
35
37
  expect(resource.content).to eq("fake file content - ÅÄÖ")
@@ -10,9 +10,9 @@ describe Hydra::Derivatives::RemoteSourceFile do
10
10
 
11
11
  context 'when you pass in a String file name' do
12
12
  let(:input_obj) { file_name }
13
- let(:options) { Hash.new }
13
+ let(:options) { {} }
14
14
 
15
- it 'it yields the file name' do
15
+ it 'yields the file name' do
16
16
  expect do |blk|
17
17
  described_class.call(input_obj, options, &blk)
18
18
  end.to yield_with_args(file_name)
@@ -23,7 +23,7 @@ describe Hydra::Derivatives::RemoteSourceFile do
23
23
  let(:input_obj) { TestObject.new(source_file_name: file_name) }
24
24
  let(:options) { { source: :source_file_name } }
25
25
 
26
- it 'it yields the file name' do
26
+ it 'yields the file name' do
27
27
  expect do |blk|
28
28
  described_class.call(input_obj, options, &blk)
29
29
  end.to yield_with_args(file_name)
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Hydra::Derivatives::TempfileService do
4
+ subject { described_class.new(file) }
5
+
4
6
  let(:class_with_metadata_extraction) do
5
7
  Class.new do
6
8
  attr_reader :content, :mime_type, :uri
@@ -21,8 +23,7 @@ describe Hydra::Derivatives::TempfileService do
21
23
 
22
24
  let(:file) { class_with_metadata_extraction.new(initialization_options) }
23
25
 
24
- subject { described_class.new(file) }
25
- context '#tempfile' do
26
+ describe '#tempfile' do
26
27
  it 'has a method called to_tempfile' do
27
28
  expect { |b| subject.tempfile(&b) }.to yield_with_args(Tempfile)
28
29
  end
@@ -31,13 +31,13 @@ describe "the configuration" do
31
31
  end
32
32
 
33
33
  it "lets you set a custom output file service" do
34
- output_file_service = double("MyOutputFileService")
34
+ output_file_service = instance_double("MyOutputFileService")
35
35
  subject.output_file_service = output_file_service
36
36
  expect(subject.output_file_service).to eq(output_file_service)
37
37
  end
38
38
 
39
39
  it "lets you set a custom source file service" do
40
- source_file_service = double("MyRetriveSourceFileService")
40
+ source_file_service = instance_double("MyRetriveSourceFileService")
41
41
  subject.source_file_service = source_file_service
42
42
  expect(subject.source_file_service).to eq(source_file_service)
43
43
  end
@@ -12,19 +12,21 @@ describe Hydra::Derivatives do
12
12
  describe "source_file_service" do
13
13
  before { subject.source_file_service = custom_source_file_service }
14
14
 
15
- context "as a global configuration setting" do
16
- let(:custom_source_file_service) { "fake service" }
15
+ context "with a global configuration setting" do
17
16
  subject { CustomFile }
18
17
 
18
+ let(:custom_source_file_service) { "fake service" }
19
+
19
20
  it "utilizes the default source file service" do
20
21
  expect(subject.source_file_service).to eq(custom_source_file_service)
21
22
  end
22
23
  end
23
24
 
24
- context "as an instance level configuration setting" do
25
- let(:custom_source_file_service) { "another fake service" }
25
+ context "with an instance level configuration setting" do
26
26
  subject { CustomFile.new }
27
27
 
28
+ let(:custom_source_file_service) { "another fake service" }
29
+
28
30
  it "accepts a custom source file service as an option" do
29
31
  expect(subject.source_file_service).to eq(custom_source_file_service)
30
32
  end
@@ -4,29 +4,41 @@ require 'stringio'
4
4
  describe Hydra::Derivatives::IoDecorator do
5
5
  let(:file) { StringIO.new('hello') }
6
6
 
7
- context "one argument" do
7
+ context "with one argument" do
8
8
  let(:decorator) { described_class.new(file) }
9
+
9
10
  describe "#read" do
10
11
  subject { decorator.read }
12
+
11
13
  it { is_expected.to eq 'hello' }
12
14
  end
13
15
  end
14
16
 
15
- context "three arguments" do
17
+ context "with three arguments" do
16
18
  let(:decorator) { described_class.new(file, 'text/plain', 'help.txt') }
17
19
 
18
20
  describe "#read" do
19
21
  subject { decorator.read }
22
+
20
23
  it { is_expected.to eq 'hello' }
21
24
  end
22
25
 
23
26
  describe "mime_type" do
24
27
  subject { decorator.mime_type }
28
+
25
29
  it { is_expected.to eq 'text/plain' }
26
30
  end
27
31
 
32
+ describe "original_filename" do
33
+ subject { decorator.original_filename }
34
+
35
+ it { is_expected.to eq 'help.txt' }
36
+ end
37
+
28
38
  describe "original_name" do
29
39
  subject { decorator.original_name }
40
+
41
+ before { allow(Deprecation).to receive(:warn) }
30
42
  it { is_expected.to eq 'help.txt' }
31
43
  end
32
44
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Hydra::Derivatives::Logger do
4
4
  context "with log levels" do
5
- let(:levels) { %w(unknown fatal error warn info debug) }
5
+ let(:levels) { %w[unknown fatal error warn info debug] }
6
6
 
7
7
  it "responds successfully" do
8
8
  levels.each do |level|
@@ -17,56 +17,64 @@ describe "Transcoding" do
17
17
  AudioDerivatives.create(self, source: :original_file,
18
18
  outputs: [
19
19
  { label: :mp3, format: 'mp3', url: "#{uri}/original_file_mp3" },
20
- { label: :ogg, format: 'ogg', url: "#{uri}/original_file_ogg" }])
20
+ { label: :ogg, format: 'ogg', url: "#{uri}/original_file_ogg" }
21
+ ])
21
22
  when 'video/x-msvideo'
22
23
  VideoDerivatives.create(self, source: :original_file,
23
24
  outputs: [
24
25
  { label: :mp4, format: 'mp4', url: "#{uri}/original_file_mp4" },
25
26
  { label: :webm, format: 'webm', url: "#{uri}/original_file_webm" },
26
- { label: :thumbnail, format: 'jpg', url: "#{uri}/thumbnail" }])
27
+ { label: :thumbnail, format: 'jpg', url: "#{uri}/thumbnail" }
28
+ ])
27
29
  when 'image/png', 'image/jpg'
28
30
  ImageDerivatives.create(self, source: :original_file,
29
- outputs: [
30
- { label: :medium, size: "300x300>", url: "#{uri}/original_file_medium" },
31
- { label: :thumb, size: "100x100>", url: "#{uri}/original_file_thumb" },
32
- { label: :access, format: 'jpg', url: "#{uri}/access" },
33
- ])
31
+ outputs: [
32
+ { label: :medium, size: "300x300>", url: "#{uri}/original_file_medium" },
33
+ { label: :thumb, size: "100x100>", url: "#{uri}/original_file_thumb" },
34
+ { label: :access, format: 'jpg', url: "#{uri}/access" }
35
+ ])
34
36
  when 'application/vnd.ms-powerpoint'
35
37
  DocumentDerivatives.create(self, source: :original_file,
36
38
  outputs: [
37
39
  { label: :preservation, format: 'pptx', url: "#{uri}/original_file_preservation" },
38
40
  { label: :access, format: 'pdf', url: "#{uri}/original_file_access" },
39
- { label: :thumnail, format: 'jpg', url: "#{uri}/original_file_thumbnail" }])
41
+ { label: :thumnail, format: 'jpg', url: "#{uri}/original_file_thumbnail" }
42
+ ])
40
43
  when 'text/rtf'
41
44
  DocumentDerivatives.create(self, source: :original_file,
42
45
  outputs: [
43
46
  { label: :preservation, format: 'odt', url: "#{uri}/original_file_preservation" },
44
47
  { label: :access, format: 'pdf', url: "#{uri}/original_file_access" },
45
- { label: :thumnail, format: 'jpg', url: "#{uri}/original_file_thumbnail" }])
48
+ { label: :thumnail, format: 'jpg', url: "#{uri}/original_file_thumbnail" }
49
+ ])
46
50
  when 'application/msword'
47
51
  DocumentDerivatives.create(self, source: :original_file,
48
52
  outputs: [
49
53
  { label: :preservation, format: 'docx', url: "#{uri}/original_file_preservation" },
50
54
  { label: :access, format: 'pdf', url: "#{uri}/original_file_access" },
51
- { label: :thumnail, format: 'jpg', url: "#{uri}/original_file_thumbnail" }])
55
+ { label: :thumnail, format: 'jpg', url: "#{uri}/original_file_thumbnail" }
56
+ ])
52
57
  when 'application/vnd.ms-excel'
53
58
  DocumentDerivatives.create(self, source: :original_file,
54
59
  outputs: [
55
60
  { label: :preservation, format: 'xlsx', url: "#{uri}/original_file_preservation" },
56
61
  { label: :access, format: 'pdf', url: "#{uri}/original_file_access" },
57
- { label: :thumnail, format: 'jpg', url: "#{uri}/original_file_thumbnail" }])
62
+ { label: :thumnail, format: 'jpg', url: "#{uri}/original_file_thumbnail" }
63
+ ])
58
64
  when 'image/tiff'
59
65
  Jpeg2kImageDerivatives.create(self, source: :original_file,
60
66
  outputs: [
61
67
  { label: :resized, format: 'jp2', recipe: :default, processor: 'jpeg2k_image', resize: "600x600>", url: "#{uri}/resized" },
62
68
  { label: :config_lookup, format: 'jp2', recipe: :default, processor: 'jpeg2k_image', url: "#{uri}/config_lookup" },
63
69
  { label: :string_recipe, format: 'jp2', recipe: '-jp2_space sRGB', processor: 'jpeg2k_image', url: "#{uri}/string_recipe" },
64
- { label: :diy, format: 'jp2', processor: 'jpeg2k_image', url: "#{uri}/original_file_diy" }])
70
+ { label: :diy, format: 'jp2', processor: 'jpeg2k_image', url: "#{uri}/original_file_diy" }
71
+ ])
65
72
  when 'image/x-adobe-dng'
66
73
  ImageDerivatives.create(self, source: :original_file,
67
74
  outputs: [
68
75
  { label: :access, size: "300x300>", format: 'jpg', processor: :raw_image, url: "#{uri}/original_file_access" },
69
- { label: :thumb, size: "100x100>", format: 'jpg', processor: :raw_image, url: "#{uri}/original_file_thumb" }])
76
+ { label: :thumb, size: "100x100>", format: 'jpg', processor: :raw_image, url: "#{uri}/original_file_thumb" }
77
+ ])
70
78
  end
71
79
  end
72
80
  end
@@ -143,7 +151,7 @@ describe "Transcoding" do
143
151
  expect(file.attached_files['original_file_thumb']).to have_content
144
152
  expect(file.attached_files['original_file_thumb'].mime_type).to eq('image/png')
145
153
  expect(file.attached_files['fulltext'].content).to match(/This PDF file was created using CutePDF/)
146
- expect(file.attached_files['fulltext'].mime_type).to eq 'text/plain'
154
+ expect(file.attached_files['fulltext'].mime_type).to eq 'text/plain;charset=UTF-8'
147
155
  end
148
156
  end
149
157
 
@@ -210,7 +218,7 @@ describe "Transcoding" do
210
218
  expect(file.attached_files['thumbnail'].mime_type).to eq('image/jpeg')
211
219
  end
212
220
 
213
- context "and the timeout is set" do
221
+ context "when the timeout is set" do
214
222
  before do
215
223
  Hydra::Derivatives::Processors::Video::Processor.timeout = 0.2 # 200ms
216
224
  end