delayed_paperclip 2.8.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +14 -12
  3. data/Appraisals +14 -6
  4. data/README.md +275 -0
  5. data/Rakefile +1 -1
  6. data/delayed_paperclip.gemspec +2 -2
  7. data/gemfiles/3.2.gemfile +8 -0
  8. data/gemfiles/{rails3_2.gemfile.lock → 3.2.gemfile.lock} +37 -36
  9. data/gemfiles/4.0.gemfile +8 -0
  10. data/gemfiles/{rails4.gemfile.lock → 4.0.gemfile.lock} +39 -40
  11. data/gemfiles/4.1.gemfile +8 -0
  12. data/gemfiles/4.1.gemfile.lock +156 -0
  13. data/gemfiles/4.2.gemfile +8 -0
  14. data/gemfiles/4.2.gemfile.lock +181 -0
  15. data/lib/delayed_paperclip/jobs/active_job.rb +16 -0
  16. data/lib/delayed_paperclip/jobs.rb +1 -0
  17. data/lib/delayed_paperclip/url_generator.rb +1 -1
  18. data/lib/delayed_paperclip/version.rb +1 -1
  19. data/lib/delayed_paperclip.rb +1 -0
  20. data/spec/delayed_paperclip/url_generator_spec.rb +31 -3
  21. data/spec/integration/active_job_inline_spec.rb +26 -0
  22. data/spec/integration/active_job_resque_spec.rb +31 -0
  23. data/spec/integration/active_job_sidekiq_spec.rb +35 -0
  24. data/spec/integration/delayed_job_spec.rb +1 -1
  25. data/spec/spec_helper.rb +9 -0
  26. data/test/base_delayed_paperclip_test.rb +4 -0
  27. data/test/test_helper.rb +14 -1
  28. metadata +27 -27
  29. data/.rbenv-version +0 -1
  30. data/README.textile +0 -219
  31. data/gemfiles/rails3_1.gemfile +0 -7
  32. data/gemfiles/rails3_1.gemfile.lock +0 -163
  33. data/gemfiles/rails3_2.gemfile +0 -7
  34. data/gemfiles/rails4.gemfile +0 -7
  35. data/test/delayed_paperclip_test.rb +0 -47
  36. data/test/fixtures/12k.png +0 -0
  37. data/test/resque_paperclip_test.rb +0 -32
  38. data/test/sidekiq_paperclip.rb +0 -39
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed_paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Storimer
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-06-26 00:00:00.000000000 Z
14
+ date: 2014-12-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: paperclip
@@ -45,16 +45,16 @@ dependencies:
45
45
  name: rspec
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - ">="
48
+ - - "<"
49
49
  - !ruby/object:Gem::Version
50
- version: '0'
50
+ version: '3.0'
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - ">="
55
+ - - "<"
56
56
  - !ruby/object:Gem::Version
57
- version: '0'
57
+ version: '3.0'
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: sqlite3
60
60
  requirement: !ruby/object:Gem::Requirement
@@ -115,16 +115,16 @@ dependencies:
115
115
  name: sidekiq
116
116
  requirement: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - ">="
118
+ - - "<"
119
119
  - !ruby/object:Gem::Version
120
- version: '0'
120
+ version: '3.0'
121
121
  type: :development
122
122
  prerelease: false
123
123
  version_requirements: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - ">="
125
+ - - "<"
126
126
  - !ruby/object:Gem::Version
127
- version: '0'
127
+ version: '3.0'
128
128
  - !ruby/object:Gem::Dependency
129
129
  name: appraisal
130
130
  requirement: !ruby/object:Gem::Requirement
@@ -191,26 +191,28 @@ extensions: []
191
191
  extra_rdoc_files: []
192
192
  files:
193
193
  - ".gitignore"
194
- - ".rbenv-version"
195
194
  - ".travis.yml"
196
195
  - Appraisals
197
196
  - CONTRIBUTING
198
197
  - ChangeLog
199
198
  - Gemfile
200
199
  - LICENSE
201
- - README.textile
200
+ - README.md
202
201
  - Rakefile
203
202
  - delayed_paperclip.gemspec
204
- - gemfiles/rails3_1.gemfile
205
- - gemfiles/rails3_1.gemfile.lock
206
- - gemfiles/rails3_2.gemfile
207
- - gemfiles/rails3_2.gemfile.lock
208
- - gemfiles/rails4.gemfile
209
- - gemfiles/rails4.gemfile.lock
203
+ - gemfiles/3.2.gemfile
204
+ - gemfiles/3.2.gemfile.lock
205
+ - gemfiles/4.0.gemfile
206
+ - gemfiles/4.0.gemfile.lock
207
+ - gemfiles/4.1.gemfile
208
+ - gemfiles/4.1.gemfile.lock
209
+ - gemfiles/4.2.gemfile
210
+ - gemfiles/4.2.gemfile.lock
210
211
  - init.rb
211
212
  - lib/delayed_paperclip.rb
212
213
  - lib/delayed_paperclip/attachment.rb
213
214
  - lib/delayed_paperclip/jobs.rb
215
+ - lib/delayed_paperclip/jobs/active_job.rb
214
216
  - lib/delayed_paperclip/jobs/delayed_job.rb
215
217
  - lib/delayed_paperclip/jobs/resque.rb
216
218
  - lib/delayed_paperclip/jobs/sidekiq.rb
@@ -225,6 +227,9 @@ files:
225
227
  - spec/delayed_paperclip_spec.rb
226
228
  - spec/fixtures/12k.png
227
229
  - spec/fixtures/missing.png
230
+ - spec/integration/active_job_inline_spec.rb
231
+ - spec/integration/active_job_resque_spec.rb
232
+ - spec/integration/active_job_sidekiq_spec.rb
228
233
  - spec/integration/base_delayed_paperclip_spec.rb
229
234
  - spec/integration/delayed_job_spec.rb
230
235
  - spec/integration/examples/base.rb
@@ -233,10 +238,6 @@ files:
233
238
  - spec/spec_helper.rb
234
239
  - test/base_delayed_paperclip_test.rb
235
240
  - test/database.yml
236
- - test/delayed_paperclip_test.rb
237
- - test/fixtures/12k.png
238
- - test/resque_paperclip_test.rb
239
- - test/sidekiq_paperclip.rb
240
241
  - test/test_helper.rb
241
242
  homepage: http://github.com/jrgifford/delayed_paperclip
242
243
  licenses: []
@@ -257,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
258
  version: '0'
258
259
  requirements: []
259
260
  rubyforge_project:
260
- rubygems_version: 2.2.2
261
+ rubygems_version: 2.4.2
261
262
  signing_key:
262
263
  specification_version: 4
263
264
  summary: Process your Paperclip attachments in the background.
@@ -269,6 +270,9 @@ test_files:
269
270
  - spec/delayed_paperclip_spec.rb
270
271
  - spec/fixtures/12k.png
271
272
  - spec/fixtures/missing.png
273
+ - spec/integration/active_job_inline_spec.rb
274
+ - spec/integration/active_job_resque_spec.rb
275
+ - spec/integration/active_job_sidekiq_spec.rb
272
276
  - spec/integration/base_delayed_paperclip_spec.rb
273
277
  - spec/integration/delayed_job_spec.rb
274
278
  - spec/integration/examples/base.rb
@@ -277,8 +281,4 @@ test_files:
277
281
  - spec/spec_helper.rb
278
282
  - test/base_delayed_paperclip_test.rb
279
283
  - test/database.yml
280
- - test/delayed_paperclip_test.rb
281
- - test/fixtures/12k.png
282
- - test/resque_paperclip_test.rb
283
- - test/sidekiq_paperclip.rb
284
284
  - test/test_helper.rb
data/.rbenv-version DELETED
@@ -1 +0,0 @@
1
- 1.9.3-p429
data/README.textile DELETED
@@ -1,219 +0,0 @@
1
- h1. Delayed::Paperclip !https://travis-ci.org/jrgifford/delayed_paperclip.png?branch=master!:https://travis-ci.org/jrgifford/delayed_paperclip "!https://codeclimate.com/github/jrgifford/delayed_paperclip.png!":https://codeclimate.com/github/jrgifford/delayed_paperclip
2
-
3
- Delayed_paperclip lets you process your "Paperclip":http://github.com/thoughtbot/paperclip attachments in a background task with "delayed_job":http://github.com/tobi/delayed_job, "Resque":https://github.com/resque/resque or "Sidekiq":http://github.com/mperham/sidekiq.
4
-
5
- h2. Why?
6
-
7
- The most common use case for Paperclip is to easily attach image files to ActiveRecord models. Most of the time these image files will have multiple styles and will need to be resized when they are created. This is usually a pretty "slow operation":http://www.jstorimer.com/ruby/2010/01/05/speep-up-your-paperclip-tests.html and should be handled in a background task.
8
-
9
- I'm sure that everyone knows this, this gem just makes it easy to do.
10
-
11
- h2. Installation
12
-
13
- Install the gem:
14
-
15
- <pre><code>gem install delayed_paperclip</code></pre>
16
-
17
- Or even better, add it to your Gemfile.
18
-
19
- <pre><code>source "https://rubygems.org"
20
- gem 'delayed_paperclip'
21
- </code></pre>
22
-
23
-
24
- Dependencies:
25
- * Paperclip
26
- * DJ, Resque or Sidekiq
27
-
28
- h2. Usage
29
-
30
- In your model:
31
-
32
- <pre><code>
33
- class User < ActiveRecord::Base
34
- has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
35
-
36
- process_in_background :avatar
37
- end
38
- </code></pre>
39
-
40
- Use your Paperclip attachment just like always in controllers and views.
41
-
42
- To select between using Resque or Delayed::Job, just install and configure your choice properly within your application, and delayed_paperclip will do the rest. It will detect which library is loaded and make a decision about which sort of job to enqueue at that time.
43
-
44
- h3. Resque
45
-
46
- Make sure that you have "Resque":https://github.com/resque/resque up and running. The jobs will be dispatched to the <code>:paperclip</code> queue, so you can correctly dispatch your worker. Configure resque and your workers exactly as you would otherwise.
47
-
48
- h3. DJ
49
-
50
- Just make sure that you have DJ up and running.
51
-
52
- h3. Sidekiq
53
-
54
- Make sure that "Sidekiq":http://github.com/mperham/sidekiq is running and listening to the <code>paperclip</code> queue, either by adding it to your <code>sidekiq.yml</code> config file under <code>- queues:</code> or by passing the command line argument <code>-q paperclip</code> to Sidekiq.
55
-
56
- h3. Displaying images during processing
57
-
58
- In the default setup, when you upload an image for the first time and try to display it before the job has been completed, Paperclip will be none the wiser and output the url of the image which is yet to be processed, which will result in a broken image link being displayed on the page.
59
-
60
- To have the missing image url be outputted by paperclip while the image is being processed, all you need to do is add a #{attachment_name}_processing column to the specific model you want to enable this feature for. This feature gracefully degrades and will not affect models which do not have the column added to them.
61
-
62
- <pre><code>
63
- class AddAvatarProessingToUser < ActiveRecord::Migration
64
- def self.up
65
- add_column :users, :avatar_processing, :boolean
66
- end
67
-
68
- def self.down
69
- remove_column :users, :avatar_processing
70
- end
71
- end
72
-
73
- @user = User.new(:avatar => File.new(...))
74
- @user.save
75
- @user.avatar.url #=> "/images/original/missing.png"
76
- Delayed::Worker.new.work_off
77
-
78
- @user.reload
79
- @user.avatar.url #=> "/system/images/3/original/IMG_2772.JPG?1267562148"
80
- </code></pre>
81
-
82
- h4. Custom image for processing
83
-
84
- This is useful if you have a difference between missing images and images currently
85
- being processed.
86
-
87
- <pre><code>
88
-
89
- class User < ActiveRecord::Base
90
- has_attached_file :avatar
91
-
92
- process_in_background :avatar, :processing_image_url => "/images/original/processing.jpg"
93
- end
94
-
95
- @user = User.new(:avatar => File.new(...))
96
- @user.save
97
- @user.avatar.url #=> "/images/original/processing.png"
98
- Delayed::Worker.new.work_off
99
-
100
- @user.reload
101
- @user.avatar.url #=> "/system/images/3/original/IMG_2772.JPG?1267562148"
102
-
103
- </code></pre>
104
-
105
- h4. Have processing? status available, but construct image URLs as if delayed_paperclip wasn't present
106
-
107
- If you define the #{attachment_name}_processing column, but set the url_with_processing option to false,
108
- this opens up other options (other than modifying the url that paperclip returns) for giving feedback to
109
- the user while the image is processing. This is useful for advanced situations, for example when dealing
110
- with caching systems.
111
-
112
- Note especially the method .processing? which passes through the value of the boolean created via migration.
113
-
114
- <pre><code>
115
-
116
- class User < ActiveRecord::Base
117
- has_attached_file :avatar
118
-
119
- process_in_background :avatar, :url_with_processing => false
120
- end
121
-
122
- @user = User.new(:avatar => File.new(...))
123
- @user.save
124
- @user.avatar.url #=> "/system/images/3/original/IMG_2772.JPG?1267562148"
125
- @user.avatar.processing? #=> true
126
- Delayed::Worker.new.work_off
127
-
128
- @user.reload
129
- @user.avatar.url #=> "/system/images/3/original/IMG_2772.JPG?1267562148"
130
- @user.avatar.processing? #=> false
131
-
132
- </code></pre>
133
-
134
- h4. Only process certain styles
135
-
136
- This is useful if you don't want the background job to reprocess all styles.
137
-
138
- <pre><code>
139
- class User < ActiveRecord::Base
140
- has_attached_file :avatar, :styles => { :small => "25x25#", :medium => "50x50x" }
141
-
142
- process_in_background :avatar, :only_process => [:small]
143
- end
144
- </code></pre>
145
-
146
- Like paperclip, you could also supply a lambda function to define only_process dynamically.
147
-
148
- <pre><code>
149
- class User < ActiveRecord::Base
150
- has_attached_file :avatar, :styles => { :small => "25x25#", :medium => "50x50x" }
151
-
152
- process_in_background :avatar, :only_process => lambda { |a| a.instance.small_supported? ? [:small, :large] : [:large] }
153
- end
154
- </code></pre>
155
-
156
- h4. Split processing
157
-
158
- You can process some styles in the foreground and some in the background by setting only_process on both has_attached_file and process_in_background.
159
-
160
- <pre><code>
161
- class User < ActiveRecord::Base
162
- has_attached_file :avatar, :styles => { :small => "25x25#", :medium => "50x50x" }, :only_process => [:small]
163
-
164
- process_in_background :avatar, :only_process => [:medium]
165
- end
166
- </code></pre>
167
-
168
- h4. Reprocess Without Delay
169
-
170
- This is useful if you don't want the background job. It accepts individual styles to. Take note, normal `reprocess!` does not accept
171
- styles as arguments anymore. It will delegate to DelayedPaperclip and reprocess all styles.
172
-
173
- <pre><code>
174
- class User < ActiveRecord::Base
175
- has_attached_file :avatar, :styles => { :small => "25x25#", :medium => "50x50x" }
176
-
177
- process_in_background :avatar
178
- end
179
-
180
- @user.avatar.url #=> "/system/images/3/original/IMG_2772.JPG?1267562148"
181
- @user.avatar.reprocess_without_delay!(:medium)
182
- </code></pre>
183
-
184
- h2. Defaults
185
-
186
- Global defaults for all delayed_paperclip instances in your app can be defined by changing the
187
- DelayedPaperclip.options Hash, this can be useful for setting a default 'processing image,' so you
188
- won't have to define it in every process_in_background definition.
189
-
190
- If you're using Rails you can define a Hash with default options in config/application.rb or in any
191
- of the config/environments/*.rb files on config.delayed_paperclip_defaults, these will get merged into
192
- DelayedPaperclip.options as your Rails app boots. An example:
193
-
194
- <pre><code>
195
- module YourApp
196
- class Application < Rails::Application
197
- # Other code...
198
-
199
- config.delayed_paperclip_defaults = {
200
- :url_with_processing => true,
201
- :processing_image_url => 'custom_processing.png'
202
- }
203
- end
204
- end
205
- </code></pre>
206
-
207
- h2. What if I'm not using images?
208
-
209
- This library works no matter what kind of post-processing you are doing with Paperclip.
210
-
211
- h2. Does it work with s3?
212
-
213
- Yes.
214
-
215
- h2. Contributing
216
-
217
- Checkout out CONTRIBUTING. In short, you'll need a redis server running for testing. Run all tests with
218
-
219
- <pre><code>rake</code></pre>
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 3.1.12"
6
-
7
- gemspec :path=>"../"
@@ -1,163 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- delayed_paperclip (2.7.1)
5
- paperclip (>= 3.3)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- actionmailer (3.1.12)
11
- actionpack (= 3.1.12)
12
- mail (~> 2.4.4)
13
- actionpack (3.1.12)
14
- activemodel (= 3.1.12)
15
- activesupport (= 3.1.12)
16
- builder (~> 3.0.0)
17
- erubis (~> 2.7.0)
18
- i18n (~> 0.6)
19
- rack (~> 1.3.6)
20
- rack-cache (~> 1.2)
21
- rack-mount (~> 0.8.2)
22
- rack-test (~> 0.6.1)
23
- sprockets (~> 2.0.4)
24
- activemodel (3.1.12)
25
- activesupport (= 3.1.12)
26
- builder (~> 3.0.0)
27
- i18n (~> 0.6)
28
- activerecord (3.1.12)
29
- activemodel (= 3.1.12)
30
- activesupport (= 3.1.12)
31
- arel (~> 2.2.3)
32
- tzinfo (~> 0.3.29)
33
- activeresource (3.1.12)
34
- activemodel (= 3.1.12)
35
- activesupport (= 3.1.12)
36
- activesupport (3.1.12)
37
- multi_json (~> 1.0)
38
- appraisal (0.5.2)
39
- bundler
40
- rake
41
- arel (2.2.3)
42
- builder (3.0.4)
43
- celluloid (0.15.2)
44
- timers (~> 1.1.0)
45
- climate_control (0.0.3)
46
- activesupport (>= 3.0)
47
- cocaine (0.5.4)
48
- climate_control (>= 0.0.3, < 1.0)
49
- connection_pool (2.0.0)
50
- delayed_job (4.0.0)
51
- activesupport (>= 3.0, < 4.1)
52
- delayed_job_active_record (4.0.0)
53
- activerecord (>= 3.0, < 4.1)
54
- delayed_job (>= 3.0, < 4.1)
55
- diff-lcs (1.2.5)
56
- erubis (2.7.0)
57
- hike (1.2.3)
58
- i18n (0.6.9)
59
- json (1.8.1)
60
- mail (2.4.4)
61
- i18n (>= 0.4.0)
62
- mime-types (~> 1.16)
63
- treetop (~> 1.4.8)
64
- metaclass (0.0.4)
65
- mime-types (1.25.1)
66
- mocha (1.0.0)
67
- metaclass (~> 0.0.1)
68
- mono_logger (1.1.0)
69
- multi_json (1.8.4)
70
- paperclip (4.1.1)
71
- activemodel (>= 3.0.0)
72
- activesupport (>= 3.0.0)
73
- cocaine (~> 0.5.3)
74
- mime-types
75
- polyglot (0.3.4)
76
- rack (1.3.10)
77
- rack-cache (1.2)
78
- rack (>= 0.4)
79
- rack-mount (0.8.3)
80
- rack (>= 1.0.0)
81
- rack-protection (1.5.2)
82
- rack
83
- rack-ssl (1.3.3)
84
- rack
85
- rack-test (0.6.2)
86
- rack (>= 1.0)
87
- rails (3.1.12)
88
- actionmailer (= 3.1.12)
89
- actionpack (= 3.1.12)
90
- activerecord (= 3.1.12)
91
- activeresource (= 3.1.12)
92
- activesupport (= 3.1.12)
93
- bundler (~> 1.0)
94
- railties (= 3.1.12)
95
- railties (3.1.12)
96
- actionpack (= 3.1.12)
97
- activesupport (= 3.1.12)
98
- rack-ssl (~> 1.3.2)
99
- rake (>= 0.8.7)
100
- rdoc (~> 3.4)
101
- thor (~> 0.14.6)
102
- rake (10.1.1)
103
- rdoc (3.12.2)
104
- json (~> 1.4)
105
- redis (3.0.7)
106
- redis-namespace (1.4.1)
107
- redis (~> 3.0.4)
108
- resque (1.25.2)
109
- mono_logger (~> 1.0)
110
- multi_json (~> 1.0)
111
- redis-namespace (~> 1.3)
112
- sinatra (>= 0.9.2)
113
- vegas (~> 0.1.2)
114
- rspec (2.14.1)
115
- rspec-core (~> 2.14.0)
116
- rspec-expectations (~> 2.14.0)
117
- rspec-mocks (~> 2.14.0)
118
- rspec-core (2.14.8)
119
- rspec-expectations (2.14.5)
120
- diff-lcs (>= 1.1.3, < 2.0)
121
- rspec-mocks (2.14.6)
122
- sidekiq (2.17.7)
123
- celluloid (>= 0.15.2)
124
- connection_pool (>= 1.0.0)
125
- json
126
- redis (>= 3.0.6)
127
- redis-namespace (>= 1.3.1)
128
- sinatra (1.3.3)
129
- rack (~> 1.3, >= 1.3.6)
130
- rack-protection (~> 1.2)
131
- tilt (~> 1.3, >= 1.3.3)
132
- sprockets (2.0.4)
133
- hike (~> 1.2)
134
- rack (~> 1.0)
135
- tilt (~> 1.1, != 1.3.0)
136
- sqlite3 (1.3.9)
137
- thor (0.14.6)
138
- tilt (1.4.1)
139
- timers (1.1.0)
140
- treetop (1.4.15)
141
- polyglot
142
- polyglot (>= 0.3.1)
143
- tzinfo (0.3.38)
144
- vegas (0.1.11)
145
- rack (>= 1.0.0)
146
-
147
- PLATFORMS
148
- ruby
149
-
150
- DEPENDENCIES
151
- appraisal
152
- bundler
153
- delayed_job
154
- delayed_job_active_record
155
- delayed_paperclip!
156
- mocha
157
- rails (~> 3.1.12)
158
- railties
159
- rake
160
- resque
161
- rspec
162
- sidekiq
163
- sqlite3
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 3.2.17"
6
-
7
- gemspec :path=>"../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 4.0.3"
6
-
7
- gemspec :path=>"../"
@@ -1,47 +0,0 @@
1
- require 'test_helper'
2
- require 'base_delayed_paperclip_test'
3
- require 'delayed_job'
4
-
5
- Delayed::Worker.backend = :active_record
6
-
7
- class DelayedPaperclipTest < Test::Unit::TestCase
8
- include BaseDelayedPaperclipTest
9
-
10
- def setup
11
- super
12
- DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::DelayedJob
13
- build_delayed_jobs
14
- end
15
-
16
- def process_jobs
17
- Delayed::Worker.new.work_off
18
- end
19
-
20
- def jobs_count
21
- Delayed::Job.count
22
- end
23
-
24
- def test_perform_job
25
- dummy = Dummy.new(:image => File.open("#{RAILS_ROOT}/test/fixtures/12k.png"))
26
- dummy.image = File.open("#{RAILS_ROOT}/test/fixtures/12k.png")
27
- Paperclip::Attachment.any_instance.expects(:reprocess!)
28
- dummy.save!
29
- Delayed::Job.last.payload_object.perform
30
- end
31
-
32
- def build_delayed_jobs
33
- ActiveRecord::Base.connection.create_table :delayed_jobs, :force => true do |table|
34
- table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
35
- table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
36
- table.text :handler # YAML-encoded string of the object that will do work
37
- table.string :last_error # reason for last failure (See Note below)
38
- table.datetime :run_at # When to run. Could be Time.now for immediately, or sometime in the future.
39
- table.datetime :locked_at # Set when a client is working on this object
40
- table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
41
- table.string :locked_by # Who is working on this object (if locked)
42
- table.string :queue
43
- table.timestamps
44
- end
45
- end
46
-
47
- end
Binary file
@@ -1,32 +0,0 @@
1
- require 'test_helper'
2
- require 'base_delayed_paperclip_test'
3
- require 'resque'
4
-
5
- class ResquePaperclipTest < Test::Unit::TestCase
6
- include BaseDelayedPaperclipTest
7
-
8
- def setup
9
- super
10
- # Make sure that we just test Resque in here
11
- DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::Resque
12
- Resque.remove_queue(:paperclip)
13
- end
14
-
15
- def process_jobs
16
- worker = Resque::Worker.new(:paperclip)
17
- worker.process
18
- end
19
-
20
- def jobs_count
21
- Resque.size(:paperclip)
22
- end
23
-
24
- def test_perform_job
25
- dummy = Dummy.new(:image => File.open("#{RAILS_ROOT}/test/fixtures/12k.png"))
26
- dummy.image = File.open("#{RAILS_ROOT}/test/fixtures/12k.png")
27
- Paperclip::Attachment.any_instance.expects(:reprocess!)
28
- dummy.save!
29
- DelayedPaperclip::Jobs::Resque.perform(dummy.class.name, dummy.id, :image)
30
- end
31
-
32
- end
@@ -1,39 +0,0 @@
1
- require 'test_helper'
2
- require 'base_delayed_paperclip_test'
3
- require 'sidekiq'
4
-
5
- class SidekiqPaperclipTest < Test::Unit::TestCase
6
- include BaseDelayedPaperclipTest
7
-
8
- def setup
9
- super
10
- # Make sure that we just test Sidekiq in here
11
- DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::Sidekiq
12
- Sidekiq::Queue.new(:paperclip).clear
13
- end
14
-
15
- def process_jobs
16
- Sidekiq::Queue.new(:paperclip).each do |job|
17
- worker = job.klass.constantize.new
18
- args = job.args
19
- begin
20
- worker.perform(*args)
21
- rescue # Assume sidekiq handle exception properly
22
- end
23
- job.delete
24
- end
25
- end
26
-
27
- def jobs_count
28
- Sidekiq::Queue.new(:paperclip).size
29
- end
30
-
31
- def test_perform_job
32
- dummy = Dummy.new(:image => File.open("#{RAILS_ROOT}/test/fixtures/12k.png"))
33
- dummy.image = File.open("#{RAILS_ROOT}/test/fixtures/12k.png")
34
- Paperclip::Attachment.any_instance.expects(:reprocess!)
35
- dummy.save!
36
- DelayedPaperclip::Jobs::Sidekiq.new.perform(dummy.class.name, dummy.id, :image)
37
- end
38
-
39
- end