ddr-models 3.0.0.beta.8 → 3.0.0.beta.9
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/config/initializers/subscriptions.rb +0 -1
- data/lib/ddr/events/event.rb +1 -3
- data/lib/ddr/jobs.rb +0 -1
- data/lib/ddr/models/base.rb +1 -5
- data/lib/ddr/models/has_multires_image.rb +0 -4
- data/lib/ddr/models/has_thumbnail.rb +1 -1
- data/lib/ddr/models/version.rb +1 -1
- data/spec/models/has_thumbnail_spec.rb +32 -0
- metadata +4 -5
- data/lib/ddr/jobs/delete_multires_image.rb +0 -21
- data/spec/models/has_multires_image_spec.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 423038a832d4b54a31f8f97b4db56125f018baae
|
4
|
+
data.tar.gz: c0a001fc155f0d5b810974cd7800b3b2cd4c2dac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9fc9f1685c4cd2401742d4604da2f36e68cb02f5a4a40e6933e5c460b15c48f14f39d1e0eccb5f78cfb608504b4569fdb80bf6dabb0805a22ced925fc322775
|
7
|
+
data.tar.gz: 1ebe59d6ab822b9abbecbde28876a0bdc050533e6b3cf965056bf4a4105de19037bf5e48dc64e25777f2433936e90432ac58d1e7fbc2b6bdd9595193cb91fdf6
|
@@ -16,4 +16,3 @@ ActiveSupport::Notifications.subscribe(Ddr::Notifications::UPDATE, Ddr::Events::
|
|
16
16
|
|
17
17
|
# Deletion
|
18
18
|
ActiveSupport::Notifications.subscribe(Ddr::Notifications::DELETION, Ddr::Events::DeletionEvent)
|
19
|
-
ActiveSupport::Notifications.subscribe(Ddr::Notifications::DELETION, Ddr::Jobs::DeleteMultiresImage)
|
data/lib/ddr/events/event.rb
CHANGED
@@ -39,9 +39,7 @@ module Ddr
|
|
39
39
|
# Receive message sent by ActiveSupport::Notifications
|
40
40
|
def self.call(*args)
|
41
41
|
notification = ActiveSupport::Notifications::Event.new(*args)
|
42
|
-
|
43
|
-
attrs = notification.payload.dup.keep_if { |k, v| evt.has_attribute?(k) }
|
44
|
-
evt.update(attrs)
|
42
|
+
create(notification.payload)
|
45
43
|
end
|
46
44
|
|
47
45
|
# Scopes
|
data/lib/ddr/jobs.rb
CHANGED
data/lib/ddr/models/base.rb
CHANGED
@@ -14,7 +14,7 @@ module Ddr::Models
|
|
14
14
|
extend AutoVersion
|
15
15
|
|
16
16
|
after_destroy do
|
17
|
-
notify_event
|
17
|
+
notify_event :deletion
|
18
18
|
end
|
19
19
|
|
20
20
|
DescriptiveMetadata.mapping.each do |name, term|
|
@@ -116,9 +116,5 @@ module Ddr::Models
|
|
116
116
|
self
|
117
117
|
end
|
118
118
|
|
119
|
-
def deletion_event_payload
|
120
|
-
{}
|
121
|
-
end
|
122
|
-
|
123
119
|
end
|
124
120
|
end
|
@@ -13,7 +13,7 @@ module Ddr::Models
|
|
13
13
|
def copy_thumbnail_from(other)
|
14
14
|
if other && other.has_thumbnail?
|
15
15
|
self.thumbnail.content = other.thumbnail.content
|
16
|
-
self.thumbnail.
|
16
|
+
self.thumbnail.mime_type = other.thumbnail.mime_type if thumbnail_changed?
|
17
17
|
end
|
18
18
|
thumbnail_changed?
|
19
19
|
end
|
data/lib/ddr/models/version.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Ddr::Models
|
4
|
+
RSpec.describe HasThumbnail, type: :model do
|
5
|
+
|
6
|
+
let(:component) { Component.new }
|
7
|
+
let(:item) { Item.new }
|
8
|
+
|
9
|
+
describe '#copy_thumbnail_from' do
|
10
|
+
describe 'other has thumbnail' do
|
11
|
+
before do
|
12
|
+
component.thumbnail.content = 'abcdef'
|
13
|
+
component.thumbnail.mime_type = 'image/png'
|
14
|
+
end
|
15
|
+
it "should copy the thumbnail content and mime type" do
|
16
|
+
result = item.copy_thumbnail_from(component)
|
17
|
+
expect(result).to be(true)
|
18
|
+
expect(item.thumbnail.content).to eq('abcdef')
|
19
|
+
expect(item.thumbnail.mime_type).to eq('image/png')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
describe 'other does not hav thumbnail' do
|
23
|
+
it "should copy the thumbnail content and mime type" do
|
24
|
+
result = item.copy_thumbnail_from(component)
|
25
|
+
expect(result).to be(false)
|
26
|
+
expect(item.thumbnail.content).to be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
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: 3.0.0.beta.
|
4
|
+
version: 3.0.0.beta.9
|
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-02-
|
12
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -510,7 +510,6 @@ files:
|
|
510
510
|
- lib/ddr/index/sort_order.rb
|
511
511
|
- lib/ddr/index/unique_key_field.rb
|
512
512
|
- lib/ddr/jobs.rb
|
513
|
-
- lib/ddr/jobs/delete_multires_image.rb
|
514
513
|
- lib/ddr/jobs/fits_file_characterization.rb
|
515
514
|
- lib/ddr/jobs/fixity_check.rb
|
516
515
|
- lib/ddr/jobs/job.rb
|
@@ -707,8 +706,8 @@ files:
|
|
707
706
|
- spec/models/finding_aid_spec.rb
|
708
707
|
- spec/models/has_admin_metadata_spec.rb
|
709
708
|
- spec/models/has_children_spec.rb
|
710
|
-
- spec/models/has_multires_image_spec.rb
|
711
709
|
- spec/models/has_struct_metadata_spec.rb
|
710
|
+
- spec/models/has_thumbnail_spec.rb
|
712
711
|
- spec/models/indexing_spec.rb
|
713
712
|
- spec/models/item_spec.rb
|
714
713
|
- spec/models/license_spec.rb
|
@@ -881,8 +880,8 @@ test_files:
|
|
881
880
|
- spec/models/finding_aid_spec.rb
|
882
881
|
- spec/models/has_admin_metadata_spec.rb
|
883
882
|
- spec/models/has_children_spec.rb
|
884
|
-
- spec/models/has_multires_image_spec.rb
|
885
883
|
- spec/models/has_struct_metadata_spec.rb
|
884
|
+
- spec/models/has_thumbnail_spec.rb
|
886
885
|
- spec/models/indexing_spec.rb
|
887
886
|
- spec/models/item_spec.rb
|
888
887
|
- spec/models/license_spec.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Ddr::Jobs
|
2
|
-
class DeleteMultiresImage
|
3
|
-
extend Job
|
4
|
-
|
5
|
-
@queue = :general
|
6
|
-
|
7
|
-
def self.call(*args)
|
8
|
-
event = ActiveSupport::Notifications::Event.new(*args)
|
9
|
-
if event.name == Ddr::Notifications::DELETION &&
|
10
|
-
file_uri = event.payload[:multires_image_file_path]
|
11
|
-
Resque.enqueue(self, file_uri)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.perform(file_uri)
|
16
|
-
path = Ddr::Utils.path_from_uri(file_uri)
|
17
|
-
File.unlink(path)
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Ddr::Models
|
2
|
-
RSpec.describe HasMultiresImage do
|
3
|
-
|
4
|
-
subject { FactoryGirl.create(:component) }
|
5
|
-
|
6
|
-
describe "cleaning up multires image file after destroy" do
|
7
|
-
before {
|
8
|
-
@file = Tempfile.create('foo')
|
9
|
-
@path = @file.path
|
10
|
-
}
|
11
|
-
after {
|
12
|
-
::File.unlink(@path) if ::File.exist?(@path)
|
13
|
-
}
|
14
|
-
it "deletes the file" do
|
15
|
-
subject.multires_image_file_path = "file:#{@path}"
|
16
|
-
subject.save!
|
17
|
-
subject.destroy
|
18
|
-
expect(::File.exist?(@path)).to be false
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|