ddr-models 2.4.1 → 2.4.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.
- checksums.yaml +4 -4
- data/lib/ddr/models/has_content.rb +5 -4
- data/lib/ddr/models/version.rb +1 -1
- data/spec/support/shared_examples_for_has_content.rb +22 -29
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1aeee77be1941cef872cdef9833e667f3e5c93e
|
4
|
+
data.tar.gz: cf6d46b137d160d69bef0f300a7230f223f7d7fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbabe3f6c1a20248a908bd5b0e57f3ce6ac8bd3688d8dffa29008ed8a863fbafe0cc0c32a4183a3c908ca815af990982d2b284367f8f62a78880b1d49e96b366
|
7
|
+
data.tar.gz: b8900cd65a8d06bfb1395cd36f975cb51b7228342713800443f050ee984a0d7d9a6579c2c9e759a012eb8e6c45fda1070cdc42aa3f8a887233dd9917880596b3
|
@@ -40,7 +40,9 @@ module Ddr
|
|
40
40
|
|
41
41
|
around_save :update_derivatives, if: :content_changed?
|
42
42
|
|
43
|
-
|
43
|
+
before_save if: :re_characterize? do
|
44
|
+
fits.delete
|
45
|
+
end
|
44
46
|
|
45
47
|
after_add_file do
|
46
48
|
if file_to_add.original_name && file_to_add.dsid == "content"
|
@@ -137,9 +139,8 @@ module Ddr
|
|
137
139
|
derivatives.update_derivatives(:later)
|
138
140
|
end
|
139
141
|
|
140
|
-
def
|
141
|
-
|
142
|
-
Resque.enqueue(Ddr::Jobs::FitsFileCharacterization, pid)
|
142
|
+
def re_characterize?
|
143
|
+
content_changed? && !fits.new?
|
143
144
|
end
|
144
145
|
|
145
146
|
def default_content_type
|
data/lib/ddr/models/version.rb
CHANGED
@@ -73,22 +73,6 @@ RSpec.shared_examples "an object that can have content" do
|
|
73
73
|
expect(subject.derivatives).to receive(:update_derivatives)
|
74
74
|
subject.save
|
75
75
|
end
|
76
|
-
describe "file characterization" do
|
77
|
-
context "characterize files is false" do
|
78
|
-
before { allow(Ddr::Models).to receive(:characterize_files?) { false } }
|
79
|
-
it "should not enqueue a FITS file characterization job" do
|
80
|
-
expect(Resque).to_not receive(:enqueue).with(Ddr::Jobs::FitsFileCharacterization, instance_of(String))
|
81
|
-
subject.save
|
82
|
-
end
|
83
|
-
end
|
84
|
-
context "characterize files is true" do
|
85
|
-
before { allow(Ddr::Models).to receive(:characterize_files?) { true } }
|
86
|
-
it "should enqueue a FITS file characterization job" do
|
87
|
-
expect(Resque).to receive(:enqueue).with(Ddr::Jobs::FitsFileCharacterization, instance_of(String))
|
88
|
-
subject.save
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
76
|
end
|
93
77
|
|
94
78
|
context "and it's an existing object with content" do
|
@@ -98,20 +82,29 @@ RSpec.shared_examples "an object that can have content" do
|
|
98
82
|
expect(subject.derivatives).to receive(:update_derivatives)
|
99
83
|
subject.upload! file
|
100
84
|
end
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
expect(Resque).to_not receive(:enqueue).with(Ddr::Jobs::FitsFileCharacterization, instance_of(String))
|
106
|
-
subject.upload! file
|
107
|
-
end
|
85
|
+
context "and the file has not previously been characterized" do
|
86
|
+
it "does not try to delete the existing characterization data" do
|
87
|
+
expect(subject.fits).not_to receive(:delete)
|
88
|
+
subject.upload! file
|
108
89
|
end
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
90
|
+
end
|
91
|
+
context "and the file has new characterization data" do
|
92
|
+
before {
|
93
|
+
subject.fits.content = fixture_file_upload("fits/document.xml")
|
94
|
+
}
|
95
|
+
it "preserves the characterization data" do
|
96
|
+
subject.upload! file
|
97
|
+
expect(subject.reload.fits).to have_content
|
98
|
+
end
|
99
|
+
end
|
100
|
+
context "and the file has previously been characterized" do
|
101
|
+
before {
|
102
|
+
subject.fits.content = fixture_file_upload("fits/document.xml")
|
103
|
+
subject.save!
|
104
|
+
}
|
105
|
+
it "deletes the existing characterization data" do
|
106
|
+
subject.upload! file
|
107
|
+
expect(subject.reload.fits).to_not have_content
|
115
108
|
end
|
116
109
|
end
|
117
110
|
end
|
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.4.
|
4
|
+
version: 2.4.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: 2016-01-
|
12
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|