delayed_paperclip 2.9.1 → 2.9.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/.gitignore +2 -2
- data/.travis.yml +5 -6
- data/Appraisals +1 -5
- data/CONTRIBUTING +0 -3
- data/README.md +43 -11
- data/Rakefile +0 -13
- data/delayed_paperclip.gemspec +3 -3
- data/gemfiles/3.2.gemfile +0 -1
- data/gemfiles/4.0.gemfile +0 -1
- data/gemfiles/4.1.gemfile +0 -1
- data/gemfiles/4.2.gemfile +0 -1
- data/lib/delayed_paperclip.rb +6 -7
- data/lib/delayed_paperclip/attachment.rb +12 -6
- data/lib/delayed_paperclip/jobs/active_job.rb +3 -5
- data/lib/delayed_paperclip/jobs/delayed_job.rb +3 -2
- data/lib/delayed_paperclip/jobs/resque.rb +2 -3
- data/lib/delayed_paperclip/jobs/sidekiq.rb +7 -1
- data/lib/delayed_paperclip/railtie.rb +1 -1
- data/lib/delayed_paperclip/url_generator.rb +19 -25
- data/lib/delayed_paperclip/version.rb +1 -1
- data/spec/delayed_paperclip/attachment_spec.rb +98 -26
- data/spec/delayed_paperclip/class_methods_spec.rb +20 -12
- data/spec/delayed_paperclip/instance_methods_spec.rb +8 -12
- data/spec/delayed_paperclip/url_generator_spec.rb +24 -24
- data/spec/delayed_paperclip_spec.rb +37 -22
- data/spec/integration/active_job_inline_spec.rb +3 -3
- data/spec/integration/active_job_resque_spec.rb +4 -7
- data/spec/integration/active_job_sidekiq_spec.rb +17 -18
- data/spec/integration/base_delayed_paperclip_spec.rb +5 -6
- data/spec/integration/delayed_job_spec.rb +3 -4
- data/spec/integration/examples/base.rb +33 -25
- data/spec/integration/resque_spec.rb +4 -6
- data/spec/integration/sidekiq_spec.rb +8 -11
- data/spec/spec_helper.rb +15 -0
- metadata +23 -19
- data/gemfiles/3.2.gemfile.lock +0 -162
- data/gemfiles/4.0.gemfile.lock +0 -156
- data/gemfiles/4.1.gemfile.lock +0 -156
- data/gemfiles/4.2.gemfile.lock +0 -181
- data/test/base_delayed_paperclip_test.rb +0 -254
- data/test/database.yml +0 -4
- data/test/test_helper.rb +0 -106
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
require 'uri'
|
|
2
|
+
require 'paperclip/url_generator'
|
|
2
3
|
|
|
3
4
|
module DelayedPaperclip
|
|
4
|
-
|
|
5
|
-
def
|
|
6
|
-
|
|
7
|
-
base.alias_method_chain :timestamp_possible?, :processed
|
|
8
|
-
base.alias_method_chain :for, :processed
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def for_with_processed(style_name, options)
|
|
12
|
-
most_appropriate_url = @attachment.processing_style?(style_name) ? most_appropriate_url(style_name) : most_appropriate_url_without_processed
|
|
5
|
+
class UrlGenerator < ::Paperclip::UrlGenerator
|
|
6
|
+
def for(style_name, options)
|
|
7
|
+
most_appropriate_url = @attachment.processing_style?(style_name) ? most_appropriate_url(style_name) : most_appropriate_url()
|
|
13
8
|
|
|
14
9
|
timestamp_as_needed(
|
|
15
10
|
escape_url_as_needed(
|
|
@@ -20,27 +15,28 @@ module DelayedPaperclip
|
|
|
20
15
|
end
|
|
21
16
|
|
|
22
17
|
# This method is a mess
|
|
23
|
-
def
|
|
24
|
-
if @attachment.
|
|
25
|
-
if @attachment.
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
def most_appropriate_url(style = nil)
|
|
19
|
+
if @attachment.processing_style?(style)
|
|
20
|
+
if @attachment.original_filename.nil? || delayed_default_url?(style)
|
|
21
|
+
|
|
22
|
+
if @attachment.delayed_options.nil? ||
|
|
23
|
+
@attachment.processing_image_url.nil? ||
|
|
24
|
+
!@attachment.processing?
|
|
25
|
+
default_url
|
|
26
|
+
else
|
|
27
|
+
@attachment.processing_image_url
|
|
28
|
+
end
|
|
28
29
|
|
|
29
|
-
default_url
|
|
30
30
|
else
|
|
31
|
-
@
|
|
31
|
+
@attachment_options[:url]
|
|
32
32
|
end
|
|
33
33
|
else
|
|
34
|
-
|
|
34
|
+
super()
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
def
|
|
39
|
-
|
|
40
|
-
false
|
|
41
|
-
else
|
|
42
|
-
timestamp_possible_without_processed?
|
|
43
|
-
end
|
|
38
|
+
def timestamp_possible?
|
|
39
|
+
delayed_default_url? ? false : super
|
|
44
40
|
end
|
|
45
41
|
|
|
46
42
|
def delayed_default_url?(style = nil)
|
|
@@ -55,9 +51,7 @@ module DelayedPaperclip
|
|
|
55
51
|
|
|
56
52
|
def processing?(style)
|
|
57
53
|
return true if @attachment.processing?
|
|
58
|
-
|
|
59
54
|
return @attachment.processing_style?(style) if style
|
|
60
55
|
end
|
|
61
56
|
end
|
|
62
|
-
|
|
63
57
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe DelayedPaperclip::Attachment do
|
|
4
|
-
|
|
5
4
|
before :each do
|
|
6
5
|
DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::Resque
|
|
7
6
|
reset_dummy(dummy_options)
|
|
@@ -11,27 +10,26 @@ describe DelayedPaperclip::Attachment do
|
|
|
11
10
|
let(:dummy) { Dummy.create }
|
|
12
11
|
|
|
13
12
|
describe "#delayed_options" do
|
|
14
|
-
|
|
15
13
|
it "returns the specific options for delayed paperclip" do
|
|
16
|
-
dummy.image.delayed_options.
|
|
14
|
+
expect(dummy.image.delayed_options).to eq({
|
|
17
15
|
:priority => 0,
|
|
18
16
|
:only_process => [],
|
|
19
17
|
:url_with_processing => true,
|
|
20
18
|
:processing_image_url => nil,
|
|
21
|
-
:queue =>
|
|
22
|
-
}
|
|
19
|
+
:queue => "paperclip"
|
|
20
|
+
})
|
|
23
21
|
end
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
describe "#post_processing_with_delay" do
|
|
27
25
|
it "is true if delay_processing? is false" do
|
|
28
26
|
dummy.image.stubs(:delay_processing?).returns false
|
|
29
|
-
dummy.image.post_processing_with_delay.should
|
|
27
|
+
dummy.image.post_processing_with_delay.should be_truthy
|
|
30
28
|
end
|
|
31
29
|
|
|
32
30
|
it "is false if delay_processing? is true" do
|
|
33
31
|
dummy.image.stubs(:delay_processing?).returns true
|
|
34
|
-
dummy.image.post_processing_with_delay.should
|
|
32
|
+
dummy.image.post_processing_with_delay.should be_falsey
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
context "on a non-delayed image" do
|
|
@@ -39,7 +37,7 @@ describe DelayedPaperclip::Attachment do
|
|
|
39
37
|
|
|
40
38
|
it "is false if delay_processing? is true" do
|
|
41
39
|
dummy.image.stubs(:delay_processing?).returns true
|
|
42
|
-
dummy.image.post_processing_with_delay.should
|
|
40
|
+
dummy.image.post_processing_with_delay.should be_falsey
|
|
43
41
|
end
|
|
44
42
|
end
|
|
45
43
|
end
|
|
@@ -47,12 +45,12 @@ describe DelayedPaperclip::Attachment do
|
|
|
47
45
|
describe "#delay_processing?" do
|
|
48
46
|
it "returns delayed_options existence if post_processing_with_delay is nil" do
|
|
49
47
|
dummy.image.post_processing_with_delay = nil
|
|
50
|
-
dummy.image.delay_processing?.should
|
|
48
|
+
dummy.image.delay_processing?.should be_truthy
|
|
51
49
|
end
|
|
52
50
|
|
|
53
51
|
it "returns inverse of post_processing_with_delay if it's set" do
|
|
54
52
|
dummy.image.post_processing_with_delay = true
|
|
55
|
-
dummy.image.delay_processing?.should
|
|
53
|
+
dummy.image.delay_processing?.should be_falsey
|
|
56
54
|
end
|
|
57
55
|
end
|
|
58
56
|
|
|
@@ -66,7 +64,7 @@ describe DelayedPaperclip::Attachment do
|
|
|
66
64
|
let(:dummy_options) { { with_processed: false } }
|
|
67
65
|
|
|
68
66
|
it "returns false" do
|
|
69
|
-
expect(dummy.image.processing?).to
|
|
67
|
+
expect(dummy.image.processing?).to be_falsey
|
|
70
68
|
end
|
|
71
69
|
end
|
|
72
70
|
end
|
|
@@ -78,39 +76,55 @@ describe DelayedPaperclip::Attachment do
|
|
|
78
76
|
context "without a processing column" do
|
|
79
77
|
let(:dummy_options) { { with_processed: true, process_column: false } }
|
|
80
78
|
|
|
81
|
-
specify { expect(processing_style?).to
|
|
79
|
+
specify { expect(processing_style?).to be_falsey }
|
|
82
80
|
end
|
|
83
81
|
|
|
84
82
|
context "with a processing column" do
|
|
85
83
|
context "when not processing" do
|
|
86
84
|
before { dummy.image_processing = false }
|
|
87
85
|
|
|
88
|
-
specify { expect(processing_style?).to
|
|
86
|
+
specify { expect(processing_style?).to be_falsey }
|
|
89
87
|
end
|
|
90
88
|
|
|
91
89
|
context "when processing" do
|
|
92
90
|
before { dummy.image_processing = true }
|
|
93
91
|
|
|
94
92
|
context "when not split processing" do
|
|
95
|
-
specify { expect(processing_style?).to
|
|
93
|
+
specify { expect(processing_style?).to be_truthy }
|
|
96
94
|
end
|
|
97
95
|
|
|
98
96
|
context "when split processing" do
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
context "when delayed :only_process is an Array" do
|
|
98
|
+
let(:dummy_options) { {
|
|
99
|
+
paperclip: {
|
|
100
|
+
styles: {
|
|
101
|
+
online: "400x400x",
|
|
102
|
+
background: "600x600x"
|
|
103
|
+
},
|
|
104
|
+
only_process: [:online]
|
|
104
105
|
},
|
|
105
|
-
only_process: [:online]
|
|
106
|
-
},
|
|
107
106
|
|
|
108
|
-
delayed_paperclip: {
|
|
109
107
|
only_process: [:background]
|
|
110
|
-
}
|
|
111
|
-
|
|
108
|
+
}}
|
|
109
|
+
|
|
110
|
+
specify { expect(processing_style?).to be }
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
context "when delayed :only_process is callable" do
|
|
114
|
+
let(:dummy_options) { {
|
|
115
|
+
paperclip: {
|
|
116
|
+
styles: {
|
|
117
|
+
online: "400x400x",
|
|
118
|
+
background: "600x600x"
|
|
119
|
+
},
|
|
120
|
+
only_process: [:online]
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
only_process: lambda { |a| [:background] }
|
|
124
|
+
}}
|
|
112
125
|
|
|
113
|
-
|
|
126
|
+
specify { expect(processing_style?).to be }
|
|
127
|
+
end
|
|
114
128
|
end
|
|
115
129
|
end
|
|
116
130
|
end
|
|
@@ -220,7 +234,7 @@ describe DelayedPaperclip::Attachment do
|
|
|
220
234
|
|
|
221
235
|
dummy.image.send(:update_processing_column)
|
|
222
236
|
|
|
223
|
-
dummy.image_processing.should
|
|
237
|
+
dummy.image_processing.should be_falsey
|
|
224
238
|
end
|
|
225
239
|
end
|
|
226
240
|
|
|
@@ -252,4 +266,62 @@ describe DelayedPaperclip::Attachment do
|
|
|
252
266
|
dummy.image.instance_variable_get(:@post_processing_with_delay).should == true
|
|
253
267
|
end
|
|
254
268
|
end
|
|
269
|
+
|
|
270
|
+
describe "#split_processing?" do
|
|
271
|
+
let(:split_processing?) { dummy.image.split_processing? }
|
|
272
|
+
|
|
273
|
+
let(:paperclip_styles) { {
|
|
274
|
+
online: "400x400x",
|
|
275
|
+
background: "600x600x"
|
|
276
|
+
} }
|
|
277
|
+
|
|
278
|
+
context ":only_process option is set on attachment" do
|
|
279
|
+
let(:dummy_options) { {
|
|
280
|
+
paperclip: {
|
|
281
|
+
styles: paperclip_styles,
|
|
282
|
+
only_process: [:online]
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
only_process: delayed_only_process
|
|
286
|
+
}}
|
|
287
|
+
|
|
288
|
+
context "processing different styles in background" do
|
|
289
|
+
context "when delayed :only_process is an Array" do
|
|
290
|
+
let(:delayed_only_process) { [:background] }
|
|
291
|
+
|
|
292
|
+
specify { expect(split_processing?).to be true }
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
context "when delayed :only_process is callable" do
|
|
296
|
+
let(:delayed_only_process) { lambda { |a| [:background] } }
|
|
297
|
+
|
|
298
|
+
specify { expect(split_processing?).to be true }
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
context "processing same styles in background" do
|
|
303
|
+
context "when delayed :only_process is an Array" do
|
|
304
|
+
let(:delayed_only_process) { [:online] }
|
|
305
|
+
|
|
306
|
+
specify { expect(split_processing?).to be false }
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
context "when delayed :only_process is callable" do
|
|
310
|
+
let(:delayed_only_process) { lambda { |a| [:online] } }
|
|
311
|
+
|
|
312
|
+
specify { expect(split_processing?).to be false }
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
context ":only_process option is not set on attachment" do
|
|
318
|
+
let(:dummy_options) { {
|
|
319
|
+
paperclip: {
|
|
320
|
+
styles: paperclip_styles
|
|
321
|
+
}
|
|
322
|
+
}}
|
|
323
|
+
|
|
324
|
+
specify { expect(split_processing?).to be false }
|
|
325
|
+
end
|
|
326
|
+
end
|
|
255
327
|
end
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe DelayedPaperclip::ClassMethods do
|
|
4
|
-
|
|
5
|
-
before :all do
|
|
4
|
+
before :each do
|
|
6
5
|
DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::Resque
|
|
7
6
|
reset_dummy(with_processed: false)
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
describe ".process_in_background" do
|
|
11
|
-
|
|
12
10
|
it "is empty to start" do
|
|
13
11
|
Dummy.paperclip_definitions.should == { :image => {} }
|
|
14
12
|
end
|
|
@@ -21,11 +19,24 @@ describe DelayedPaperclip::ClassMethods do
|
|
|
21
19
|
:only_process => [],
|
|
22
20
|
:url_with_processing => true,
|
|
23
21
|
:processing_image_url => nil,
|
|
24
|
-
:queue =>
|
|
22
|
+
:queue => "paperclip"}
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
end
|
|
28
26
|
|
|
27
|
+
it "allows to set queue name" do
|
|
28
|
+
Dummy.process_in_background(:image, :queue => "custom")
|
|
29
|
+
expect(Dummy.paperclip_definitions).to eq({ :image => {
|
|
30
|
+
:delayed => {
|
|
31
|
+
:priority => 0,
|
|
32
|
+
:only_process => [],
|
|
33
|
+
:url_with_processing => true,
|
|
34
|
+
:processing_image_url => nil,
|
|
35
|
+
:queue => "custom"}
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
end
|
|
39
|
+
|
|
29
40
|
context "with processing_image_url" do
|
|
30
41
|
before :each do
|
|
31
42
|
Dummy.process_in_background(:image, processing_image_url: "/processing/url")
|
|
@@ -38,7 +49,7 @@ describe DelayedPaperclip::ClassMethods do
|
|
|
38
49
|
:only_process => [],
|
|
39
50
|
:url_with_processing => true,
|
|
40
51
|
:processing_image_url => "/processing/url",
|
|
41
|
-
:queue =>
|
|
52
|
+
:queue => "paperclip"}
|
|
42
53
|
}
|
|
43
54
|
}
|
|
44
55
|
end
|
|
@@ -58,7 +69,7 @@ describe DelayedPaperclip::ClassMethods do
|
|
|
58
69
|
:only_process => [:small, :large],
|
|
59
70
|
:url_with_processing => true,
|
|
60
71
|
:processing_image_url => nil,
|
|
61
|
-
:queue =>
|
|
72
|
+
:queue => "paperclip"}
|
|
62
73
|
}
|
|
63
74
|
}
|
|
64
75
|
end
|
|
@@ -73,16 +84,13 @@ describe DelayedPaperclip::ClassMethods do
|
|
|
73
84
|
end
|
|
74
85
|
|
|
75
86
|
context "save" do
|
|
76
|
-
before :each do
|
|
77
|
-
Dummy.stubs(:respond_to?).with(:after_commit).returns(false)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
87
|
it "sets after_save callback" do
|
|
88
|
+
Dummy.stubs(:respond_to?).with(:attachment_definitions).returns(true)
|
|
89
|
+
Dummy.stubs(:respond_to?).with(:after_commit).returns(false)
|
|
81
90
|
Dummy.expects(:after_save).with(:enqueue_delayed_processing)
|
|
82
91
|
Dummy.process_in_background(:image)
|
|
83
92
|
end
|
|
84
93
|
end
|
|
85
94
|
end
|
|
86
95
|
end
|
|
87
|
-
|
|
88
|
-
end
|
|
96
|
+
end
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe DelayedPaperclip::InstanceMethods do
|
|
4
|
-
|
|
5
|
-
before :all do
|
|
4
|
+
before :each do
|
|
6
5
|
DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::Resque
|
|
7
6
|
reset_dummy
|
|
8
7
|
end
|
|
@@ -10,7 +9,6 @@ describe DelayedPaperclip::InstanceMethods do
|
|
|
10
9
|
let(:dummy) { Dummy.create }
|
|
11
10
|
|
|
12
11
|
describe "#enqueue_delayed_processing" do
|
|
13
|
-
|
|
14
12
|
it "marks enqueue_delayed_processing" do
|
|
15
13
|
dummy.expects(:mark_enqueue_delayed_processing)
|
|
16
14
|
dummy.enqueue_delayed_processing
|
|
@@ -25,25 +23,25 @@ describe DelayedPaperclip::InstanceMethods do
|
|
|
25
23
|
it "clears instance variables" do
|
|
26
24
|
dummy.instance_variable_set(:@_enqued_for_processing, ['foo'])
|
|
27
25
|
dummy.instance_variable_set(:@_enqued_for_processing_with_processing, ['image'])
|
|
26
|
+
dummy.expects(:enqueue_post_processing_for).with('foo')
|
|
28
27
|
dummy.enqueue_delayed_processing
|
|
29
28
|
dummy.instance_variable_get(:@_enqued_for_processing).should == []
|
|
30
29
|
dummy.instance_variable_get(:@_enqued_for_processing_with_processing).should == []
|
|
31
30
|
end
|
|
32
|
-
|
|
33
31
|
end
|
|
34
32
|
|
|
35
33
|
describe "#mark_enqueue_delayed_processing" do
|
|
36
34
|
it "updates columns of _processing" do
|
|
37
|
-
dummy.image_processing.should
|
|
35
|
+
dummy.image_processing.should be_falsey
|
|
38
36
|
dummy.instance_variable_set(:@_enqued_for_processing_with_processing, ['image'])
|
|
39
37
|
dummy.mark_enqueue_delayed_processing
|
|
40
|
-
dummy.reload.image_processing.should
|
|
38
|
+
dummy.reload.image_processing.should be_truthy
|
|
41
39
|
end
|
|
42
40
|
|
|
43
41
|
it "does nothing if instance variable not set" do
|
|
44
|
-
dummy.image_processing.should
|
|
42
|
+
dummy.image_processing.should be_falsey
|
|
45
43
|
dummy.mark_enqueue_delayed_processing
|
|
46
|
-
dummy.reload.image_processing.should
|
|
44
|
+
dummy.reload.image_processing.should be_falsey
|
|
47
45
|
end
|
|
48
46
|
end
|
|
49
47
|
|
|
@@ -56,9 +54,9 @@ describe DelayedPaperclip::InstanceMethods do
|
|
|
56
54
|
|
|
57
55
|
describe "#prepare_enqueueing_for" do
|
|
58
56
|
it "updates processing column to true" do
|
|
59
|
-
dummy.image_processing.should
|
|
57
|
+
dummy.image_processing.should be_falsey
|
|
60
58
|
dummy.prepare_enqueueing_for("image")
|
|
61
|
-
dummy.image_processing.should
|
|
59
|
+
dummy.image_processing.should be_truthy
|
|
62
60
|
end
|
|
63
61
|
|
|
64
62
|
it "sets instance variables for column updating" do
|
|
@@ -71,6 +69,4 @@ describe DelayedPaperclip::InstanceMethods do
|
|
|
71
69
|
dummy.instance_variable_get(:@_enqued_for_processing).should == ["image"]
|
|
72
70
|
end
|
|
73
71
|
end
|
|
74
|
-
|
|
75
|
-
|
|
76
72
|
end
|
|
@@ -10,13 +10,13 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
10
10
|
let(:attachment) { dummy.image }
|
|
11
11
|
let(:dummy_options) { {} }
|
|
12
12
|
|
|
13
|
-
describe "
|
|
14
|
-
before do
|
|
13
|
+
describe "for" do
|
|
14
|
+
before :each do
|
|
15
15
|
attachment.stubs(:original_filename).returns "12k.png"
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
context "with split processing" do
|
|
19
|
-
# everything in this hash is passed to delayed_paperclip,
|
|
19
|
+
# everything in this hash is passed to delayed_paperclip, except for the
|
|
20
20
|
# paperclip stuff
|
|
21
21
|
let(:dummy_options) { {
|
|
22
22
|
paperclip: {
|
|
@@ -31,7 +31,7 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
31
31
|
}}
|
|
32
32
|
|
|
33
33
|
context "processing" do
|
|
34
|
-
before do
|
|
34
|
+
before :each do
|
|
35
35
|
attachment.stubs(:processing?).returns true
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -45,7 +45,7 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
context "not processing" do
|
|
48
|
-
before do
|
|
48
|
+
before :each do
|
|
49
49
|
attachment.stubs(:processing?).returns false
|
|
50
50
|
end
|
|
51
51
|
|
|
@@ -86,9 +86,9 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
describe "#
|
|
89
|
+
describe "#most_appropriate_url" do
|
|
90
90
|
context "without delayed_default_url" do
|
|
91
|
-
subject {
|
|
91
|
+
subject { DelayedPaperclip::UrlGenerator.new(attachment, {url: "/blah/url.jpg"})}
|
|
92
92
|
|
|
93
93
|
before :each do
|
|
94
94
|
subject.stubs(:delayed_default_url?).returns false
|
|
@@ -99,7 +99,7 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
it "returns options url" do
|
|
102
|
-
subject.
|
|
102
|
+
subject.most_appropriate_url.should == "/blah/url.jpg"
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
|
|
@@ -115,13 +115,13 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
115
115
|
|
|
116
116
|
it "gets default url" do
|
|
117
117
|
subject.expects(:default_url)
|
|
118
|
-
subject.
|
|
118
|
+
subject.most_appropriate_url
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
context "with delayed_options" do
|
|
123
123
|
before :each do
|
|
124
|
-
attachment.stubs(:delayed_options).returns
|
|
124
|
+
attachment.stubs(:delayed_options).returns(some: 'thing')
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
context "without processing_image_url" do
|
|
@@ -131,7 +131,7 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
131
131
|
|
|
132
132
|
it "gets default url" do
|
|
133
133
|
subject.expects(:default_url)
|
|
134
|
-
subject.
|
|
134
|
+
subject.most_appropriate_url
|
|
135
135
|
end
|
|
136
136
|
end
|
|
137
137
|
|
|
@@ -146,14 +146,14 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
146
146
|
end
|
|
147
147
|
|
|
148
148
|
it "gets processing url" do
|
|
149
|
-
subject.
|
|
149
|
+
subject.most_appropriate_url.should == "/processing/image.jpg"
|
|
150
150
|
end
|
|
151
151
|
end
|
|
152
152
|
|
|
153
153
|
context "and is not processing" do
|
|
154
154
|
it "gets default url" do
|
|
155
155
|
subject.expects(:default_url)
|
|
156
|
-
subject.
|
|
156
|
+
subject.most_appropriate_url
|
|
157
157
|
end
|
|
158
158
|
end
|
|
159
159
|
end
|
|
@@ -162,8 +162,8 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
162
162
|
end
|
|
163
163
|
end
|
|
164
164
|
|
|
165
|
-
describe "#
|
|
166
|
-
subject {
|
|
165
|
+
describe "#timestamp_possible?" do
|
|
166
|
+
subject { DelayedPaperclip::UrlGenerator.new(attachment, {})}
|
|
167
167
|
|
|
168
168
|
context "with delayed_default_url" do
|
|
169
169
|
before :each do
|
|
@@ -171,7 +171,7 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
171
171
|
end
|
|
172
172
|
|
|
173
173
|
it "is false" do
|
|
174
|
-
subject.
|
|
174
|
+
subject.timestamp_possible?.should be_falsey
|
|
175
175
|
end
|
|
176
176
|
end
|
|
177
177
|
|
|
@@ -181,14 +181,14 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
181
181
|
end
|
|
182
182
|
|
|
183
183
|
it "goes up the chain" do
|
|
184
|
-
subject.expects(:
|
|
185
|
-
subject.
|
|
184
|
+
subject.class.superclass.any_instance.expects(:timestamp_possible?)
|
|
185
|
+
subject.timestamp_possible?
|
|
186
186
|
end
|
|
187
187
|
end
|
|
188
188
|
end
|
|
189
189
|
|
|
190
190
|
describe "#delayed_default_url?" do
|
|
191
|
-
subject {
|
|
191
|
+
subject { DelayedPaperclip::UrlGenerator.new(attachment, {})}
|
|
192
192
|
|
|
193
193
|
before :each do
|
|
194
194
|
attachment.stubs(:job_is_processing).returns false
|
|
@@ -200,7 +200,7 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
200
200
|
end
|
|
201
201
|
|
|
202
202
|
it "has all false, delayed_default_url returns true" do
|
|
203
|
-
subject.delayed_default_url?.should
|
|
203
|
+
subject.delayed_default_url?.should be_truthy
|
|
204
204
|
end
|
|
205
205
|
|
|
206
206
|
context "job is processing" do
|
|
@@ -209,7 +209,7 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
209
209
|
end
|
|
210
210
|
|
|
211
211
|
it "returns true" do
|
|
212
|
-
subject.delayed_default_url?.should
|
|
212
|
+
subject.delayed_default_url?.should be_falsey
|
|
213
213
|
end
|
|
214
214
|
end
|
|
215
215
|
|
|
@@ -219,7 +219,7 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
219
219
|
end
|
|
220
220
|
|
|
221
221
|
it "returns true" do
|
|
222
|
-
subject.delayed_default_url?.should
|
|
222
|
+
subject.delayed_default_url?.should be_falsey
|
|
223
223
|
end
|
|
224
224
|
end
|
|
225
225
|
|
|
@@ -229,7 +229,7 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
229
229
|
end
|
|
230
230
|
|
|
231
231
|
it "returns true" do
|
|
232
|
-
subject.delayed_default_url?.should
|
|
232
|
+
subject.delayed_default_url?.should be_falsey
|
|
233
233
|
end
|
|
234
234
|
end
|
|
235
235
|
|
|
@@ -240,7 +240,7 @@ describe DelayedPaperclip::UrlGenerator do
|
|
|
240
240
|
end
|
|
241
241
|
|
|
242
242
|
it "returns true" do
|
|
243
|
-
subject.delayed_default_url?.should
|
|
243
|
+
subject.delayed_default_url?.should be_falsey
|
|
244
244
|
end
|
|
245
245
|
end
|
|
246
246
|
|