asset_cloud 2.2.8 → 2.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1331f148d5e428464e3d7f539963c1c2651f528656a3c8ef0266d6aa299379c
4
- data.tar.gz: 7f62fa26ae75e6e630aee982c08067cfbf38e1e6e3e49cd9afc99a33505825c3
3
+ metadata.gz: 2e767cf7119375ff7308f312b510f99cd89705e1d44ae556e89853bc8f55f2dd
4
+ data.tar.gz: 285705891684bc782af8326be994698a9282a4abf19d24df0759cc9a53461752
5
5
  SHA512:
6
- metadata.gz: 03aca7a78234bbb51998cad8a0740e7f7ae2d0a14a2b3dc32ed9317bea003cf1e684845c56ae1554e90e2cf7d4f6ba64dbabdf63b1b90f2e85f7a8186b27c7d1
7
- data.tar.gz: 7284d30086ea786bdc0b1a18fe6a8a27ea829bedacded167244d21a7334926aa8d444202ad594c98f0c8ed2cb7c998b7c9725fcf4ab4519008970865146908e0
6
+ metadata.gz: b10838d5eb09a7efcb7a09ecbdc0ac63e879b233e6208a28aefde0faa811f53464eafb944aaf46bc8f71de3115cdade371bcd8516ad09e18162b8bfe2e383eb7
7
+ data.tar.gz: 738c8e086da574cfe5200b19da555a765cf482c8df341eb6168ee3864f08a42a211844f340177fda5aa34573473552d764063e7df6510a11ae0b2d66c8aa5cfe
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{asset_cloud}
5
- s.version = "2.2.8"
5
+ s.version = "2.2.9"
6
6
 
7
7
  s.authors = %w(Shopify)
8
8
  s.summary = %q{An abstraction layer around arbitrary and diverse asset stores.}
@@ -41,8 +41,8 @@ AssetCloud::Asset.class_eval do
41
41
  validate :valid_key
42
42
 
43
43
  def execute_callbacks(symbol, args)
44
- super
45
- @extensions.each {|ext| ext.execute_callbacks(symbol, args)}
44
+ result = super
45
+ result && @extensions.all? { |ext| ext.execute_callbacks(symbol, args) }
46
46
  end
47
47
 
48
48
  protected
@@ -27,7 +27,7 @@ module AssetCloud
27
27
  result = nil
28
28
  if execute_callbacks(before, args)
29
29
  result = super(*args, &block)
30
- execute_callbacks(after, args)
30
+ execute_callbacks(after, args) if result
31
31
  end
32
32
  result
33
33
  end
@@ -2,15 +2,20 @@ require 'spec_helper'
2
2
 
3
3
  class CallbackAsset < AssetCloud::Asset
4
4
  before_store :callback_before_store
5
+ before_delete :callback_before_delete
5
6
  after_delete :callback_after_delete
6
7
  before_validate :make_value_valid
7
8
  after_validate :add_spice
8
9
  validate :valid_value
9
10
 
10
11
  private
12
+
13
+ def callback_before_delete(*args); end
14
+
11
15
  def make_value_valid
12
16
  self.value = 'valid'
13
17
  end
18
+
14
19
  def add_spice
15
20
  self.value += ' spice'
16
21
  end
@@ -32,6 +37,9 @@ class CallbackCloud < AssetCloud::Base
32
37
 
33
38
  after_write :callback_after_write
34
39
  before_write :callback_before_write
40
+
41
+ def callback_before_write(*args); end
42
+ def callback_after_write(*args); end
35
43
  end
36
44
 
37
45
  class MethodRecordingCloud < AssetCloud::Base
@@ -48,21 +56,34 @@ class MethodRecordingCloud < AssetCloud::Base
48
56
  end
49
57
 
50
58
  describe CallbackCloud do
51
- before { @fs = CallbackCloud.new(File.dirname(__FILE__) + '/files', 'http://assets/') }
59
+ before do
60
+ @fs = CallbackCloud.new(File.dirname(__FILE__) + '/files', 'http://assets/')
61
+ @fs.write('tmp/file.txt', 'foo')
62
+ end
52
63
 
53
64
  it "should invoke callbacks after store" do
54
65
  @fs.should_receive(:callback_before_write).with('tmp/file.txt', 'text').and_return(true)
55
66
  @fs.should_receive(:callback_after_write).with('tmp/file.txt', 'text').and_return(true)
56
67
 
57
68
 
58
- @fs.write 'tmp/file.txt', 'text'
69
+ @fs.write('tmp/file.txt', 'text').should == true
70
+ @fs.read('tmp/file.txt').should == 'text'
59
71
  end
60
72
 
61
73
  it "should invoke callbacks after delete" do
62
74
  @fs.should_receive(:callback_before_delete).with('tmp/file.txt').and_return(true)
63
75
  @fs.should_receive(:callback_after_delete).with('tmp/file.txt').and_return(true)
64
76
 
65
- @fs.delete 'tmp/file.txt'
77
+ @fs.delete('tmp/file.txt').should == 'foo'
78
+ end
79
+
80
+ it "should not invoke other callbacks when a before_ filter returns false" do
81
+ @fs.should_receive(:callback_before_delete)
82
+ .with('tmp/file.txt')
83
+ .and_return(false)
84
+ @fs.should_not_receive(:callback_after_delete)
85
+
86
+ @fs.delete('tmp/file.txt').should == nil
66
87
  end
67
88
 
68
89
  it "should invoke callbacks even when constructing a new asset" do
@@ -72,7 +93,7 @@ describe CallbackCloud do
72
93
 
73
94
  asset = @fs.build('tmp/file.txt')
74
95
  asset.value = 'hello'
75
- asset.store
96
+ asset.store.should == true
76
97
  end
77
98
  end
78
99
 
@@ -113,6 +134,13 @@ describe CallbackAsset do
113
134
  @asset.should_not_receive(:callback_before_store)
114
135
  @asset.should_receive(:callback_after_delete).and_return(true)
115
136
 
116
- @asset.delete
137
+ @asset.delete.should == 'bar'
138
+ end
139
+
140
+ it "not invoke other callbacks when a before_ filter returns false" do
141
+ @asset.should_receive(:callback_before_delete).and_return(false)
142
+ @asset.should_not_receive(:callback_after_delete)
143
+
144
+ @asset.delete.should == nil
117
145
  end
118
146
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asset_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.8
4
+ version: 2.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-16 00:00:00.000000000 Z
11
+ date: 2019-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport