ddr-models 2.7.3 → 2.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b40e42bff6d22b301a1b06925cf23a5583bcb727
4
- data.tar.gz: d82f30c7c237c53bb375c8f307ce50420059bbc2
3
+ metadata.gz: f3c6181e57a1a67d5f374d1d83d5afa6e33d1962
4
+ data.tar.gz: 11ee5833bb3cb7730b30ed8e2ef38579de97ac59
5
5
  SHA512:
6
- metadata.gz: 2b2a22ff451d8c58a36b31ab245b9e5b3570e8e994eaca1a5e8f91698ff1c1111767175cd6d6c5bc011662aea234ac1bd88a4a2c96abbc21374ffc896aeee530
7
- data.tar.gz: ae332fd91309fdf16e90ed94c3de73f8fa225cdc47404f32ec92f61dc1121f5c8f9d1f9737ed0e3851d975c8cd01a2fc317ed983e5c638a1883205bdad7847f8
6
+ metadata.gz: e52d6d3b398d55289c9eb51d97fad7a08661849918e1077523ae770dbf8f77b261382befd8f7695f186981e9fba2c9dc40fc89039df701a3a9391473746cf8b0
7
+ data.tar.gz: 49ce6887894e3857da80afa8ba9f97bedb27a6b155405b64d8706e17d983d68d4f2086fd22ee51268d0d73e1a654dc60a9fa894609fe26d2ed1560d8178fcd2e
@@ -19,10 +19,10 @@ module Ddr::Models
19
19
  # @param external [Boolean] Add file to external datastream.
20
20
  # Not required for external datastream classes
21
21
  # or datastream instances having controlGroup 'E'.
22
- def add_file(file, dsid, mime_type: nil, external: false)
23
- mime_type ||= Ddr::Utils.mime_type_for(file)
24
- source_path = Ddr::Utils.file_path(file)
25
- original_filename = Ddr::Utils.file_name(file)
22
+ def add_file(file, dsid, mime_type: nil, external: false, original_filename: nil)
23
+ mime_type ||= Ddr::Utils.mime_type_for(file)
24
+ source_path = Ddr::Utils.file_path(file)
25
+ original_filename ||= Ddr::Utils.file_name(file)
26
26
  file_to_add = FileToAdd.new(dsid, source_path, original_filename)
27
27
  cache.with(file_to_add: file_to_add) do
28
28
  run_callbacks(:add_file) do
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "2.7.3"
3
+ VERSION = "2.7.4"
4
4
  end
5
5
  end
@@ -1,17 +1,17 @@
1
1
  RSpec.shared_examples "a repository external file" do
2
- it "should be owned by the effective user" do
2
+ it "is owned by the effective user" do
3
3
  expect(File.owned?(file_path)).to be true
4
4
  end
5
- it "should be readable by the effective user" do
5
+ it "is readable by the effective user" do
6
6
  expect(File.readable?(file_path)).to be true
7
7
  end
8
- it "should be writable by the effective user" do
8
+ it "is writable by the effective user" do
9
9
  expect(File.writable?(file_path)).to be true
10
10
  end
11
- it "should not have the sticky bit set" do
11
+ it "does not have the sticky bit set" do
12
12
  expect(File.sticky?(file_path)).to be false
13
13
  end
14
- it "should have 644 mode" do
14
+ it "has 644 mode" do
15
15
  expect("%o" % File.world_readable?(file_path)).to eq "644"
16
16
  end
17
17
  end
@@ -24,51 +24,61 @@ module Ddr::Models
24
24
  let(:xml_file) { fixture_file_upload("fits/image.xml", "text/xml") }
25
25
 
26
26
  describe "#add_file" do
27
- it "should run a virus scan on the file" do
27
+ it "runs a virus scan on the file" do
28
28
  expect(object).to receive(:virus_scan)
29
29
  object.add_file image_file, "content"
30
30
  end
31
- it "should call add_file_datastream by default" do
31
+ it "calls add_file_datastream by default" do
32
32
  expect(object).to receive(:add_file_datastream)
33
33
  object.add_file image_file, "random_ds_1"
34
34
  end
35
- it "should call add_file_datastream when dsid spec is managed" do
35
+ it "calls add_file_datastream when dsid spec is managed" do
36
36
  expect(object).to receive(:add_file_datastream)
37
37
  object.add_file xml_file, "fits"
38
38
  end
39
- it "should call add_external_file when dsid spec is external" do
39
+ it "calls add_external_file when dsid spec is external" do
40
40
  expect(object).to receive(:add_external_file)
41
41
  .with(image_file, "content", mime_type: "image/tiff")
42
42
  object.add_file image_file, "content"
43
43
  end
44
- it "should call add_external_file when :external => true option passed" do
44
+ it "calls add_external_file when :external => true option passed" do
45
45
  expect(object).to receive(:add_external_file)
46
46
  .with(image_file, "random_ds_2", mime_type: "image/tiff")
47
47
  object.add_file image_file, "random_ds_2", external: true
48
48
  end
49
- it "sets original filename when dsid == 'content'" do
50
- expect { object.add_file image_file, "content" }
51
- .to change(object, :original_filename).to("imageA.tif")
52
- end
53
- it "does not set original filename when dsid != 'content'" do
54
- expect { object.add_file xml_file, "fits" }
55
- .not_to change(object, :original_filename)
49
+ context "original_filename" do
50
+ context "when dsid == 'content'" do
51
+ it "sets original_filename" do
52
+ expect { object.add_file image_file, "content" }
53
+ .to change(object, :original_filename).to("imageA.tif")
54
+ expect { object.add_file image_file, "content", original_filename: "foo.tif" }
55
+ .to change(object, :original_filename).to("foo.tif")
56
+ end
57
+ end
58
+ context "when dsid != 'content'" do
59
+ it "does not set original_filename" do
60
+ expect { object.add_file xml_file, "fits" }
61
+ .not_to change(object, :original_filename)
62
+ expect { object.add_file xml_file, "fits", original_filename: "foo" }
63
+ .not_to change(object, :original_filename)
64
+ end
65
+ end
56
66
  end
57
67
  end
58
68
 
59
69
  describe "#add_external_file" do
60
- it "should call add_external_datastream if no spec for dsid" do
70
+ it "calls add_external_datastream if no spec for dsid" do
61
71
  expect(object).to receive(:add_external_datastream).with("random_ds_3").and_call_original
62
72
  object.add_external_file(image_file, "random_ds_3")
63
73
  end
64
- it "should raise an error if datastream is not external" do
74
+ it "raises an exception if datastream is not external" do
65
75
  expect { object.add_external_file(xml_file, "fits") }.to raise_error(ArgumentError)
66
76
  end
67
- it "should set the mimeType" do
77
+ it "sets the mimeType" do
68
78
  expect(object.content).to receive(:mimeType=).with("image/tiff")
69
79
  object.add_external_file(image_file, "content", mime_type: "image/tiff")
70
80
  end
71
- it "should set dsLocation to URI for generated file path by default" do
81
+ it "sets dsLocation to URI for generated file path by default" do
72
82
  object.add_external_file(image_file, "content")
73
83
  expect(object.content.dsLocation).not_to eq URI.escape("file:#{image_file.path}")
74
84
  expect(object.content.dsLocation).not_to be_nil
@@ -83,7 +93,7 @@ module Ddr::Models
83
93
  end
84
94
 
85
95
  describe "#add_external_datastream" do
86
- it "should return a new external datastream" do
96
+ it "returns a new external datastream" do
87
97
  ds = object.add_external_datastream("random_ds_27")
88
98
  expect(ds.controlGroup).to eq "E"
89
99
  expect(object.datastreams["random_ds_27"]).to eq ds
@@ -100,7 +110,7 @@ module Ddr::Models
100
110
  object.add_file(file2, "e_content_2", external: true)
101
111
  object.save
102
112
  end
103
- it "should return a list of file paths for all versions of all external datastreams for the object" do
113
+ it "returns a list of file paths for all versions of all external datastreams for the object" do
104
114
  paths = object.external_datastream_file_paths
105
115
  expect(paths.size).to eq 2
106
116
  paths.each do |path|
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: 2.7.3
4
+ version: 2.7.4
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: 2017-04-26 00:00:00.000000000 Z
12
+ date: 2017-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -780,7 +780,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
780
780
  version: '0'
781
781
  requirements: []
782
782
  rubyforge_project:
783
- rubygems_version: 2.6.11
783
+ rubygems_version: 2.6.8
784
784
  signing_key:
785
785
  specification_version: 4
786
786
  summary: Models used in the Duke Digital Repository