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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b9040fdb0b6cda2736d299291211c5a4dde620d7
4
- data.tar.gz: 42b318beb27882963fc49a4d1278cb94e1116851
3
+ metadata.gz: 423038a832d4b54a31f8f97b4db56125f018baae
4
+ data.tar.gz: c0a001fc155f0d5b810974cd7800b3b2cd4c2dac
5
5
  SHA512:
6
- metadata.gz: 54f897c2bd20fe04d9877aa5e7b761fe3a29896128009d03d2cf2b80ab3cca5761cfac041bf11043e2fff9cf879f0bfdd714eb72a4355a934876f76c00a33515
7
- data.tar.gz: 8a7a65a4d731561e19baf8b19439bffd467d0ec02cfcf68951af458c4645e1238b04aee7b8497ce2f16d1d015423cf6dc8e99776b5f431d94fdf44ae3ce71332
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)
@@ -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
- evt = new
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
@@ -2,7 +2,6 @@ module Ddr
2
2
  module Jobs
3
3
  extend ActiveSupport::Autoload
4
4
 
5
- autoload :DeleteMultiresImage
6
5
  autoload :FitsFileCharacterization
7
6
  autoload :FixityCheck
8
7
  autoload :Job
@@ -14,7 +14,7 @@ module Ddr::Models
14
14
  extend AutoVersion
15
15
 
16
16
  after_destroy do
17
- notify_event(:deletion, deletion_event_payload)
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
@@ -6,9 +6,5 @@ module Ddr::Models
6
6
  property :multires_image_file_path, predicate: Ddr::Vocab::Asset.multiresImageFilePath, multiple: false
7
7
  end
8
8
 
9
- def deletion_event_payload
10
- super.merge(multires_image_file_path: multires_image_file_path)
11
- end
12
-
13
9
  end
14
10
  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.mimeType = other.thumbnail.mimeType if thumbnail_changed?
16
+ self.thumbnail.mime_type = other.thumbnail.mime_type if thumbnail_changed?
17
17
  end
18
18
  thumbnail_changed?
19
19
  end
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "3.0.0.beta.8"
3
+ VERSION = "3.0.0.beta.9"
4
4
  end
5
5
  end
@@ -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.8
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-06 00:00:00.000000000 Z
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