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.
- checksums.yaml +4 -4
- data/.travis.yml +14 -12
- data/Appraisals +14 -6
- data/README.md +275 -0
- data/Rakefile +1 -1
- data/delayed_paperclip.gemspec +2 -2
- data/gemfiles/3.2.gemfile +8 -0
- data/gemfiles/{rails3_2.gemfile.lock → 3.2.gemfile.lock} +37 -36
- data/gemfiles/4.0.gemfile +8 -0
- data/gemfiles/{rails4.gemfile.lock → 4.0.gemfile.lock} +39 -40
- data/gemfiles/4.1.gemfile +8 -0
- data/gemfiles/4.1.gemfile.lock +156 -0
- data/gemfiles/4.2.gemfile +8 -0
- data/gemfiles/4.2.gemfile.lock +181 -0
- data/lib/delayed_paperclip/jobs/active_job.rb +16 -0
- data/lib/delayed_paperclip/jobs.rb +1 -0
- data/lib/delayed_paperclip/url_generator.rb +1 -1
- data/lib/delayed_paperclip/version.rb +1 -1
- data/lib/delayed_paperclip.rb +1 -0
- data/spec/delayed_paperclip/url_generator_spec.rb +31 -3
- data/spec/integration/active_job_inline_spec.rb +26 -0
- data/spec/integration/active_job_resque_spec.rb +31 -0
- data/spec/integration/active_job_sidekiq_spec.rb +35 -0
- data/spec/integration/delayed_job_spec.rb +1 -1
- data/spec/spec_helper.rb +9 -0
- data/test/base_delayed_paperclip_test.rb +4 -0
- data/test/test_helper.rb +14 -1
- metadata +27 -27
- data/.rbenv-version +0 -1
- data/README.textile +0 -219
- data/gemfiles/rails3_1.gemfile +0 -7
- data/gemfiles/rails3_1.gemfile.lock +0 -163
- data/gemfiles/rails3_2.gemfile +0 -7
- data/gemfiles/rails4.gemfile +0 -7
- data/test/delayed_paperclip_test.rb +0 -47
- data/test/fixtures/12k.png +0 -0
- data/test/resque_paperclip_test.rb +0 -32
- data/test/sidekiq_paperclip.rb +0 -39
@@ -0,0 +1,156 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
delayed_paperclip (2.8.0)
|
5
|
+
paperclip (>= 3.3)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (4.1.8)
|
11
|
+
actionpack (= 4.1.8)
|
12
|
+
actionview (= 4.1.8)
|
13
|
+
mail (~> 2.5, >= 2.5.4)
|
14
|
+
actionpack (4.1.8)
|
15
|
+
actionview (= 4.1.8)
|
16
|
+
activesupport (= 4.1.8)
|
17
|
+
rack (~> 1.5.2)
|
18
|
+
rack-test (~> 0.6.2)
|
19
|
+
actionview (4.1.8)
|
20
|
+
activesupport (= 4.1.8)
|
21
|
+
builder (~> 3.1)
|
22
|
+
erubis (~> 2.7.0)
|
23
|
+
activemodel (4.1.8)
|
24
|
+
activesupport (= 4.1.8)
|
25
|
+
builder (~> 3.1)
|
26
|
+
activerecord (4.1.8)
|
27
|
+
activemodel (= 4.1.8)
|
28
|
+
activesupport (= 4.1.8)
|
29
|
+
arel (~> 5.0.0)
|
30
|
+
activesupport (4.1.8)
|
31
|
+
i18n (~> 0.6, >= 0.6.9)
|
32
|
+
json (~> 1.7, >= 1.7.7)
|
33
|
+
minitest (~> 5.1)
|
34
|
+
thread_safe (~> 0.1)
|
35
|
+
tzinfo (~> 1.1)
|
36
|
+
appraisal (1.0.2)
|
37
|
+
bundler
|
38
|
+
rake
|
39
|
+
thor (>= 0.14.0)
|
40
|
+
arel (5.0.1.20140414130214)
|
41
|
+
builder (3.2.2)
|
42
|
+
celluloid (0.15.2)
|
43
|
+
timers (~> 1.1.0)
|
44
|
+
climate_control (0.0.3)
|
45
|
+
activesupport (>= 3.0)
|
46
|
+
cocaine (0.5.5)
|
47
|
+
climate_control (>= 0.0.3, < 1.0)
|
48
|
+
connection_pool (2.1.0)
|
49
|
+
delayed_job (4.0.6)
|
50
|
+
activesupport (>= 3.0, < 5.0)
|
51
|
+
delayed_job_active_record (4.0.3)
|
52
|
+
activerecord (>= 3.0, < 5.0)
|
53
|
+
delayed_job (>= 3.0, < 4.1)
|
54
|
+
diff-lcs (1.2.5)
|
55
|
+
erubis (2.7.0)
|
56
|
+
hike (1.2.3)
|
57
|
+
i18n (0.7.0)
|
58
|
+
json (1.8.1)
|
59
|
+
mail (2.6.3)
|
60
|
+
mime-types (>= 1.16, < 3)
|
61
|
+
metaclass (0.0.4)
|
62
|
+
mime-types (2.4.3)
|
63
|
+
minitest (5.5.0)
|
64
|
+
mocha (1.1.0)
|
65
|
+
metaclass (~> 0.0.1)
|
66
|
+
mono_logger (1.1.0)
|
67
|
+
multi_json (1.10.1)
|
68
|
+
paperclip (4.2.1)
|
69
|
+
activemodel (>= 3.0.0)
|
70
|
+
activesupport (>= 3.0.0)
|
71
|
+
cocaine (~> 0.5.3)
|
72
|
+
mime-types
|
73
|
+
rack (1.5.2)
|
74
|
+
rack-protection (1.5.3)
|
75
|
+
rack
|
76
|
+
rack-test (0.6.2)
|
77
|
+
rack (>= 1.0)
|
78
|
+
rails (4.1.8)
|
79
|
+
actionmailer (= 4.1.8)
|
80
|
+
actionpack (= 4.1.8)
|
81
|
+
actionview (= 4.1.8)
|
82
|
+
activemodel (= 4.1.8)
|
83
|
+
activerecord (= 4.1.8)
|
84
|
+
activesupport (= 4.1.8)
|
85
|
+
bundler (>= 1.3.0, < 2.0)
|
86
|
+
railties (= 4.1.8)
|
87
|
+
sprockets-rails (~> 2.0)
|
88
|
+
railties (4.1.8)
|
89
|
+
actionpack (= 4.1.8)
|
90
|
+
activesupport (= 4.1.8)
|
91
|
+
rake (>= 0.8.7)
|
92
|
+
thor (>= 0.18.1, < 2.0)
|
93
|
+
rake (10.4.2)
|
94
|
+
redis (3.2.0)
|
95
|
+
redis-namespace (1.5.1)
|
96
|
+
redis (~> 3.0, >= 3.0.4)
|
97
|
+
resque (1.25.2)
|
98
|
+
mono_logger (~> 1.0)
|
99
|
+
multi_json (~> 1.0)
|
100
|
+
redis-namespace (~> 1.3)
|
101
|
+
sinatra (>= 0.9.2)
|
102
|
+
vegas (~> 0.1.2)
|
103
|
+
rspec (2.99.0)
|
104
|
+
rspec-core (~> 2.99.0)
|
105
|
+
rspec-expectations (~> 2.99.0)
|
106
|
+
rspec-mocks (~> 2.99.0)
|
107
|
+
rspec-core (2.99.2)
|
108
|
+
rspec-expectations (2.99.2)
|
109
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
110
|
+
rspec-mocks (2.99.2)
|
111
|
+
sidekiq (2.17.8)
|
112
|
+
celluloid (= 0.15.2)
|
113
|
+
connection_pool (~> 2.0)
|
114
|
+
json
|
115
|
+
redis (~> 3.1)
|
116
|
+
redis-namespace (~> 1.3)
|
117
|
+
sinatra (1.4.5)
|
118
|
+
rack (~> 1.4)
|
119
|
+
rack-protection (~> 1.4)
|
120
|
+
tilt (~> 1.3, >= 1.3.4)
|
121
|
+
sprockets (2.12.3)
|
122
|
+
hike (~> 1.2)
|
123
|
+
multi_json (~> 1.0)
|
124
|
+
rack (~> 1.0)
|
125
|
+
tilt (~> 1.1, != 1.3.0)
|
126
|
+
sprockets-rails (2.2.2)
|
127
|
+
actionpack (>= 3.0)
|
128
|
+
activesupport (>= 3.0)
|
129
|
+
sprockets (>= 2.8, < 4.0)
|
130
|
+
sqlite3 (1.3.10)
|
131
|
+
thor (0.19.1)
|
132
|
+
thread_safe (0.3.4)
|
133
|
+
tilt (1.4.1)
|
134
|
+
timers (1.1.0)
|
135
|
+
tzinfo (1.2.2)
|
136
|
+
thread_safe (~> 0.1)
|
137
|
+
vegas (0.1.11)
|
138
|
+
rack (>= 1.0.0)
|
139
|
+
|
140
|
+
PLATFORMS
|
141
|
+
ruby
|
142
|
+
|
143
|
+
DEPENDENCIES
|
144
|
+
appraisal
|
145
|
+
bundler
|
146
|
+
delayed_job
|
147
|
+
delayed_job_active_record
|
148
|
+
delayed_paperclip!
|
149
|
+
mocha
|
150
|
+
rails (~> 4.1.0)
|
151
|
+
railties
|
152
|
+
rake
|
153
|
+
resque
|
154
|
+
rspec (< 3.0)
|
155
|
+
sidekiq (< 3.0)
|
156
|
+
sqlite3
|
@@ -0,0 +1,181 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
delayed_paperclip (2.8.0)
|
5
|
+
paperclip (>= 3.3)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (4.2.0)
|
11
|
+
actionpack (= 4.2.0)
|
12
|
+
actionview (= 4.2.0)
|
13
|
+
activejob (= 4.2.0)
|
14
|
+
mail (~> 2.5, >= 2.5.4)
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
+
actionpack (4.2.0)
|
17
|
+
actionview (= 4.2.0)
|
18
|
+
activesupport (= 4.2.0)
|
19
|
+
rack (~> 1.6.0)
|
20
|
+
rack-test (~> 0.6.2)
|
21
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
22
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
23
|
+
actionview (4.2.0)
|
24
|
+
activesupport (= 4.2.0)
|
25
|
+
builder (~> 3.1)
|
26
|
+
erubis (~> 2.7.0)
|
27
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
28
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
29
|
+
activejob (4.2.0)
|
30
|
+
activesupport (= 4.2.0)
|
31
|
+
globalid (>= 0.3.0)
|
32
|
+
activemodel (4.2.0)
|
33
|
+
activesupport (= 4.2.0)
|
34
|
+
builder (~> 3.1)
|
35
|
+
activerecord (4.2.0)
|
36
|
+
activemodel (= 4.2.0)
|
37
|
+
activesupport (= 4.2.0)
|
38
|
+
arel (~> 6.0)
|
39
|
+
activesupport (4.2.0)
|
40
|
+
i18n (~> 0.7)
|
41
|
+
json (~> 1.7, >= 1.7.7)
|
42
|
+
minitest (~> 5.1)
|
43
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
44
|
+
tzinfo (~> 1.1)
|
45
|
+
appraisal (1.0.2)
|
46
|
+
bundler
|
47
|
+
rake
|
48
|
+
thor (>= 0.14.0)
|
49
|
+
arel (6.0.0)
|
50
|
+
builder (3.2.2)
|
51
|
+
celluloid (0.15.2)
|
52
|
+
timers (~> 1.1.0)
|
53
|
+
climate_control (0.0.3)
|
54
|
+
activesupport (>= 3.0)
|
55
|
+
cocaine (0.5.5)
|
56
|
+
climate_control (>= 0.0.3, < 1.0)
|
57
|
+
connection_pool (2.1.0)
|
58
|
+
delayed_job (4.0.6)
|
59
|
+
activesupport (>= 3.0, < 5.0)
|
60
|
+
delayed_job_active_record (4.0.3)
|
61
|
+
activerecord (>= 3.0, < 5.0)
|
62
|
+
delayed_job (>= 3.0, < 4.1)
|
63
|
+
diff-lcs (1.2.5)
|
64
|
+
erubis (2.7.0)
|
65
|
+
globalid (0.3.0)
|
66
|
+
activesupport (>= 4.1.0)
|
67
|
+
hike (1.2.3)
|
68
|
+
i18n (0.7.0)
|
69
|
+
json (1.8.1)
|
70
|
+
loofah (2.0.1)
|
71
|
+
nokogiri (>= 1.5.9)
|
72
|
+
mail (2.6.3)
|
73
|
+
mime-types (>= 1.16, < 3)
|
74
|
+
metaclass (0.0.4)
|
75
|
+
mime-types (2.4.3)
|
76
|
+
mini_portile (0.6.1)
|
77
|
+
minitest (5.5.0)
|
78
|
+
mocha (1.1.0)
|
79
|
+
metaclass (~> 0.0.1)
|
80
|
+
mono_logger (1.1.0)
|
81
|
+
multi_json (1.10.1)
|
82
|
+
nokogiri (1.6.5)
|
83
|
+
mini_portile (~> 0.6.0)
|
84
|
+
paperclip (4.2.1)
|
85
|
+
activemodel (>= 3.0.0)
|
86
|
+
activesupport (>= 3.0.0)
|
87
|
+
cocaine (~> 0.5.3)
|
88
|
+
mime-types
|
89
|
+
rack (1.6.0)
|
90
|
+
rack-protection (1.5.3)
|
91
|
+
rack
|
92
|
+
rack-test (0.6.2)
|
93
|
+
rack (>= 1.0)
|
94
|
+
rails (4.2.0)
|
95
|
+
actionmailer (= 4.2.0)
|
96
|
+
actionpack (= 4.2.0)
|
97
|
+
actionview (= 4.2.0)
|
98
|
+
activejob (= 4.2.0)
|
99
|
+
activemodel (= 4.2.0)
|
100
|
+
activerecord (= 4.2.0)
|
101
|
+
activesupport (= 4.2.0)
|
102
|
+
bundler (>= 1.3.0, < 2.0)
|
103
|
+
railties (= 4.2.0)
|
104
|
+
sprockets-rails
|
105
|
+
rails-deprecated_sanitizer (1.0.3)
|
106
|
+
activesupport (>= 4.2.0.alpha)
|
107
|
+
rails-dom-testing (1.0.5)
|
108
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
109
|
+
nokogiri (~> 1.6.0)
|
110
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
111
|
+
rails-html-sanitizer (1.0.1)
|
112
|
+
loofah (~> 2.0)
|
113
|
+
railties (4.2.0)
|
114
|
+
actionpack (= 4.2.0)
|
115
|
+
activesupport (= 4.2.0)
|
116
|
+
rake (>= 0.8.7)
|
117
|
+
thor (>= 0.18.1, < 2.0)
|
118
|
+
rake (10.4.2)
|
119
|
+
redis (3.2.0)
|
120
|
+
redis-namespace (1.5.1)
|
121
|
+
redis (~> 3.0, >= 3.0.4)
|
122
|
+
resque (1.25.2)
|
123
|
+
mono_logger (~> 1.0)
|
124
|
+
multi_json (~> 1.0)
|
125
|
+
redis-namespace (~> 1.3)
|
126
|
+
sinatra (>= 0.9.2)
|
127
|
+
vegas (~> 0.1.2)
|
128
|
+
rspec (2.99.0)
|
129
|
+
rspec-core (~> 2.99.0)
|
130
|
+
rspec-expectations (~> 2.99.0)
|
131
|
+
rspec-mocks (~> 2.99.0)
|
132
|
+
rspec-core (2.99.2)
|
133
|
+
rspec-expectations (2.99.2)
|
134
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
135
|
+
rspec-mocks (2.99.2)
|
136
|
+
sidekiq (2.17.8)
|
137
|
+
celluloid (= 0.15.2)
|
138
|
+
connection_pool (~> 2.0)
|
139
|
+
json
|
140
|
+
redis (~> 3.1)
|
141
|
+
redis-namespace (~> 1.3)
|
142
|
+
sinatra (1.4.5)
|
143
|
+
rack (~> 1.4)
|
144
|
+
rack-protection (~> 1.4)
|
145
|
+
tilt (~> 1.3, >= 1.3.4)
|
146
|
+
sprockets (2.12.3)
|
147
|
+
hike (~> 1.2)
|
148
|
+
multi_json (~> 1.0)
|
149
|
+
rack (~> 1.0)
|
150
|
+
tilt (~> 1.1, != 1.3.0)
|
151
|
+
sprockets-rails (2.2.2)
|
152
|
+
actionpack (>= 3.0)
|
153
|
+
activesupport (>= 3.0)
|
154
|
+
sprockets (>= 2.8, < 4.0)
|
155
|
+
sqlite3 (1.3.10)
|
156
|
+
thor (0.19.1)
|
157
|
+
thread_safe (0.3.4)
|
158
|
+
tilt (1.4.1)
|
159
|
+
timers (1.1.0)
|
160
|
+
tzinfo (1.2.2)
|
161
|
+
thread_safe (~> 0.1)
|
162
|
+
vegas (0.1.11)
|
163
|
+
rack (>= 1.0.0)
|
164
|
+
|
165
|
+
PLATFORMS
|
166
|
+
ruby
|
167
|
+
|
168
|
+
DEPENDENCIES
|
169
|
+
appraisal
|
170
|
+
bundler
|
171
|
+
delayed_job
|
172
|
+
delayed_job_active_record
|
173
|
+
delayed_paperclip!
|
174
|
+
mocha
|
175
|
+
rails (~> 4.2.0)
|
176
|
+
railties
|
177
|
+
rake
|
178
|
+
resque
|
179
|
+
rspec (< 3.0)
|
180
|
+
sidekiq (< 3.0)
|
181
|
+
sqlite3
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module DelayedPaperclip
|
2
|
+
module Jobs
|
3
|
+
class ActiveJob < ActiveJob::Base
|
4
|
+
queue_as :paperclip
|
5
|
+
|
6
|
+
def self.enqueue_delayed_paperclip(instance_klass, instance_id, attachment_name)
|
7
|
+
# ActiveJob currently does not support symbol arguments
|
8
|
+
self.perform_later(instance_klass, instance_id, attachment_name.to_s)
|
9
|
+
end
|
10
|
+
|
11
|
+
def perform(instance_klass, instance_id, attachment_name)
|
12
|
+
DelayedPaperclip.process_job(instance_klass, instance_id, attachment_name.to_sym)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -9,7 +9,7 @@ module DelayedPaperclip
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def for_with_processed(style_name, options)
|
12
|
-
most_appropriate_url = most_appropriate_url(style_name)
|
12
|
+
most_appropriate_url = @attachment.processing_style?(style_name) ? most_appropriate_url(style_name) : most_appropriate_url_without_processed
|
13
13
|
|
14
14
|
escape_url_as_needed(
|
15
15
|
timestamp_as_needed(
|
data/lib/delayed_paperclip.rb
CHANGED
@@ -16,6 +16,7 @@ module DelayedPaperclip
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def detect_background_task
|
19
|
+
return DelayedPaperclip::Jobs::ActiveJob if defined? ::ActiveJob::Base
|
19
20
|
return DelayedPaperclip::Jobs::DelayedJob if defined? ::Delayed::Job
|
20
21
|
return DelayedPaperclip::Jobs::Resque if defined? ::Resque
|
21
22
|
return DelayedPaperclip::Jobs::Sidekiq if defined? ::Sidekiq
|
@@ -11,7 +11,11 @@ describe DelayedPaperclip::UrlGenerator do
|
|
11
11
|
let(:dummy_options) { {} }
|
12
12
|
|
13
13
|
describe "for_with_processed" do
|
14
|
-
|
14
|
+
before do
|
15
|
+
attachment.stubs(:original_filename).returns "12k.png"
|
16
|
+
end
|
17
|
+
|
18
|
+
context "with split processing" do
|
15
19
|
# everything in this hash is passed to delayed_paperclip, expect for the
|
16
20
|
# paperclip stuff
|
17
21
|
let(:dummy_options) { {
|
@@ -26,8 +30,32 @@ describe DelayedPaperclip::UrlGenerator do
|
|
26
30
|
only_process: [:background]
|
27
31
|
}}
|
28
32
|
|
29
|
-
|
30
|
-
|
33
|
+
context "processing" do
|
34
|
+
before do
|
35
|
+
attachment.stubs(:processing?).returns true
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns the default_url when the style is still being processed" do
|
39
|
+
expect(attachment.url(:background)).to eql "/images/background/missing.png"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns the attachment url when the style is not set for background processing" do
|
43
|
+
expect(attachment.url(:online)).to eql "/system/dummies/images/000/000/001/online/12k.png"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "not processing" do
|
48
|
+
before do
|
49
|
+
attachment.stubs(:processing?).returns false
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns the attachment url even when the style is set for background processing" do
|
53
|
+
expect(attachment.url(:background)).to eql "/system/dummies/images/000/000/001/background/12k.png"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns the generated url when the style is not set for background processing" do
|
57
|
+
expect(attachment.url(:online)).to eql "/system/dummies/images/000/000/001/online/12k.png"
|
58
|
+
end
|
31
59
|
end
|
32
60
|
end
|
33
61
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "ActiveJob inline" do
|
4
|
+
|
5
|
+
if defined? ActiveJob
|
6
|
+
before :all do
|
7
|
+
DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::ActiveJob
|
8
|
+
ActiveJob::Base.logger = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:dummy) { Dummy.new(:image => File.open("#{ROOT}/spec/fixtures/12k.png")) }
|
12
|
+
|
13
|
+
describe "perform job" do
|
14
|
+
before :each do
|
15
|
+
DelayedPaperclip.options[:url_with_processing] = true
|
16
|
+
reset_dummy
|
17
|
+
end
|
18
|
+
|
19
|
+
it "performs a job" do
|
20
|
+
dummy.image = File.open("#{ROOT}/spec/fixtures/12k.png")
|
21
|
+
Paperclip::Attachment.any_instance.expects(:reprocess!)
|
22
|
+
dummy.save!
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'resque'
|
3
|
+
|
4
|
+
if defined? ActiveJob
|
5
|
+
describe "Active Job with Resque backend" do
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::ActiveJob
|
9
|
+
ActiveJob::Base.logger = nil
|
10
|
+
ActiveJob::Base.queue_adapter = :resque
|
11
|
+
Resque.remove_queue(:paperclip)
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:dummy) { Dummy.new(:image => File.open("#{ROOT}/spec/fixtures/12k.png")) }
|
15
|
+
|
16
|
+
describe "integration tests" do
|
17
|
+
include_examples "base usage"
|
18
|
+
end
|
19
|
+
|
20
|
+
def process_jobs
|
21
|
+
worker = Resque::Worker.new(:paperclip)
|
22
|
+
worker.process
|
23
|
+
end
|
24
|
+
|
25
|
+
def jobs_count
|
26
|
+
|
27
|
+
Resque.size(:paperclip)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'sidekiq/api'
|
3
|
+
|
4
|
+
describe "ActiveJob with Sidekiq backend" do
|
5
|
+
|
6
|
+
if defined? ActiveJob
|
7
|
+
before :all do
|
8
|
+
DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::ActiveJob
|
9
|
+
ActiveJob::Base.logger = nil
|
10
|
+
ActiveJob::Base.queue_adapter = :sidekiq
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:dummy) { Dummy.new(:image => File.open("#{ROOT}/spec/fixtures/12k.png")) }
|
14
|
+
|
15
|
+
describe "integration tests" do
|
16
|
+
include_examples "base usage"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def process_jobs
|
21
|
+
Sidekiq::Queue.new(:paperclip).each do |job|
|
22
|
+
worker = job.klass.constantize.new
|
23
|
+
args = job.args
|
24
|
+
begin
|
25
|
+
worker.perform(*args)
|
26
|
+
rescue # Assume sidekiq handle exception properly
|
27
|
+
end
|
28
|
+
job.delete
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def jobs_count
|
33
|
+
Sidekiq::Queue.new(:paperclip).size
|
34
|
+
end
|
35
|
+
end
|
@@ -49,7 +49,7 @@ describe "Delayed Job" do
|
|
49
49
|
table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
|
50
50
|
table.string :locked_by # Who is working on this object (if locked)
|
51
51
|
table.string :queue
|
52
|
-
table.timestamps
|
52
|
+
table.timestamps null: true
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,6 +7,10 @@ require 'active_support'
|
|
7
7
|
require 'active_support/core_ext'
|
8
8
|
require 'rspec'
|
9
9
|
require 'mocha/api'
|
10
|
+
begin
|
11
|
+
require 'active_job'
|
12
|
+
rescue LoadError
|
13
|
+
end
|
10
14
|
|
11
15
|
begin
|
12
16
|
require 'pry'
|
@@ -20,6 +24,11 @@ Paperclip::Railtie.insert
|
|
20
24
|
require 'delayed_paperclip/railtie'
|
21
25
|
DelayedPaperclip::Railtie.insert
|
22
26
|
|
27
|
+
# silence deprecation warnings in rails 4.2
|
28
|
+
if ActiveRecord::Base.respond_to?(:raise_in_transactional_callbacks=)
|
29
|
+
ActiveRecord::Base.raise_in_transactional_callbacks = true
|
30
|
+
end
|
31
|
+
|
23
32
|
# Connect to sqlite
|
24
33
|
ActiveRecord::Base.establish_connection(
|
25
34
|
"adapter" => "sqlite3",
|
data/test/test_helper.rb
CHANGED
@@ -1,5 +1,18 @@
|
|
1
|
+
###
|
2
|
+
# DEPRECATED, Don't Use
|
3
|
+
###
|
4
|
+
|
1
5
|
require 'rubygems'
|
2
|
-
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'test/unit'
|
9
|
+
rescue
|
10
|
+
# we are probably Rails 4.2, so no Test::Unit here
|
11
|
+
# move along...
|
12
|
+
puts "No Test::Unit available. Skipping..."
|
13
|
+
exit(0)
|
14
|
+
end
|
15
|
+
|
3
16
|
require 'mocha/setup'
|
4
17
|
require 'active_record'
|
5
18
|
require 'active_record/version'
|