This repository has been archived by the owner on Oct 5, 2018. It is now read-only.
forked from jstorimer/delayed_paperclip
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from katafrakt/active_job
support for active job
- Loading branch information
Showing
20 changed files
with
334 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,8 @@ end | |
|
||
appraise "rails4" do | ||
gem "rails", "~> 4.0.3" | ||
end | ||
|
||
appraise "rails4_2" do | ||
gem "rails", "~> 4.2.0.beta2" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ source "http://rubygems.org" | |
|
||
gem "rails", "~> 3.1.12" | ||
|
||
gemspec :path=>"../" | ||
gemspec :path => "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,6 +158,6 @@ DEPENDENCIES | |
railties | ||
rake | ||
resque | ||
rspec | ||
sidekiq | ||
rspec (< 3.0) | ||
sidekiq (< 3.0) | ||
sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ source "http://rubygems.org" | |
|
||
gem "rails", "~> 3.2.17" | ||
|
||
gemspec :path=>"../" | ||
gemspec :path => "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,6 +156,6 @@ DEPENDENCIES | |
railties | ||
rake | ||
resque | ||
rspec | ||
sidekiq | ||
rspec (< 3.0) | ||
sidekiq (< 3.0) | ||
sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ source "http://rubygems.org" | |
|
||
gem "rails", "~> 4.0.3" | ||
|
||
gemspec :path=>"../" | ||
gemspec :path => "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,6 +152,6 @@ DEPENDENCIES | |
railties | ||
rake | ||
resque | ||
rspec | ||
sidekiq | ||
rspec (< 3.0) | ||
sidekiq (< 3.0) | ||
sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "http://rubygems.org" | ||
|
||
gem "rails", "~> 4.2.0.beta2" | ||
|
||
gemspec :path => "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
PATH | ||
remote: ../ | ||
specs: | ||
delayed_paperclip (2.8.0) | ||
paperclip (>= 3.3) | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
actionmailer (4.2.0.beta2) | ||
actionpack (= 4.2.0.beta2) | ||
actionview (= 4.2.0.beta2) | ||
activejob (= 4.2.0.beta2) | ||
mail (~> 2.5, >= 2.5.4) | ||
rails-dom-testing (~> 1.0, >= 1.0.3) | ||
actionpack (4.2.0.beta2) | ||
actionview (= 4.2.0.beta2) | ||
activesupport (= 4.2.0.beta2) | ||
rack (~> 1.6.0.beta) | ||
rack-test (~> 0.6.2) | ||
rails-dom-testing (~> 1.0, >= 1.0.3) | ||
rails-html-sanitizer (~> 1.0, >= 1.0.1) | ||
actionview (4.2.0.beta2) | ||
activesupport (= 4.2.0.beta2) | ||
builder (~> 3.1) | ||
erubis (~> 2.7.0) | ||
rails-dom-testing (~> 1.0, >= 1.0.3) | ||
rails-html-sanitizer (~> 1.0, >= 1.0.1) | ||
activejob (4.2.0.beta2) | ||
activesupport (= 4.2.0.beta2) | ||
globalid (>= 0.3.0) | ||
activemodel (4.2.0.beta2) | ||
activesupport (= 4.2.0.beta2) | ||
builder (~> 3.1) | ||
activerecord (4.2.0.beta2) | ||
activemodel (= 4.2.0.beta2) | ||
activesupport (= 4.2.0.beta2) | ||
arel (>= 6.0.0.beta1, < 6.1) | ||
activesupport (4.2.0.beta2) | ||
i18n (>= 0.7.0.beta1, < 0.8) | ||
json (~> 1.7, >= 1.7.7) | ||
minitest (~> 5.1) | ||
thread_safe (~> 0.1) | ||
tzinfo (~> 1.1) | ||
appraisal (1.0.2) | ||
bundler | ||
rake | ||
thor (>= 0.14.0) | ||
arel (6.0.0.beta1) | ||
builder (3.2.2) | ||
celluloid (0.15.2) | ||
timers (~> 1.1.0) | ||
climate_control (0.0.3) | ||
activesupport (>= 3.0) | ||
cocaine (0.5.4) | ||
climate_control (>= 0.0.3, < 1.0) | ||
connection_pool (2.0.0) | ||
delayed_job (4.0.4) | ||
activesupport (>= 3.0, < 4.2) | ||
delayed_job_active_record (4.0.2) | ||
activerecord (>= 3.0, < 4.2) | ||
delayed_job (>= 3.0, < 4.1) | ||
diff-lcs (1.2.5) | ||
erubis (2.7.0) | ||
globalid (0.3.0) | ||
activesupport (>= 4.1.0) | ||
hike (1.2.3) | ||
i18n (0.7.0.beta1) | ||
json (1.8.1) | ||
loofah (2.0.1) | ||
nokogiri (>= 1.5.9) | ||
mail (2.6.1) | ||
mime-types (>= 1.16, < 3) | ||
metaclass (0.0.4) | ||
mime-types (2.3) | ||
mini_portile (0.6.0) | ||
minitest (5.4.2) | ||
mocha (1.1.0) | ||
metaclass (~> 0.0.1) | ||
mono_logger (1.1.0) | ||
multi_json (1.10.1) | ||
nokogiri (1.6.3.1) | ||
mini_portile (= 0.6.0) | ||
paperclip (4.2.0) | ||
activemodel (>= 3.0.0) | ||
activesupport (>= 3.0.0) | ||
cocaine (~> 0.5.3) | ||
mime-types | ||
rack (1.6.0.beta) | ||
rack-protection (1.5.3) | ||
rack | ||
rack-test (0.6.2) | ||
rack (>= 1.0) | ||
rails (4.2.0.beta2) | ||
actionmailer (= 4.2.0.beta2) | ||
actionpack (= 4.2.0.beta2) | ||
actionview (= 4.2.0.beta2) | ||
activejob (= 4.2.0.beta2) | ||
activemodel (= 4.2.0.beta2) | ||
activerecord (= 4.2.0.beta2) | ||
activesupport (= 4.2.0.beta2) | ||
bundler (>= 1.3.0, < 2.0) | ||
railties (= 4.2.0.beta2) | ||
sprockets-rails (~> 3.0.0.beta1) | ||
rails-deprecated_sanitizer (1.0.3) | ||
activesupport (>= 4.2.0.alpha) | ||
rails-dom-testing (1.0.3) | ||
activesupport | ||
nokogiri (~> 1.6.0) | ||
rails-deprecated_sanitizer (>= 1.0.1) | ||
rails-html-sanitizer (1.0.1) | ||
loofah (~> 2.0) | ||
railties (4.2.0.beta2) | ||
actionpack (= 4.2.0.beta2) | ||
activesupport (= 4.2.0.beta2) | ||
rake (>= 0.8.7) | ||
thor (>= 0.18.1, < 2.0) | ||
rake (10.3.2) | ||
redis (3.1.0) | ||
redis-namespace (1.5.1) | ||
redis (~> 3.0, >= 3.0.4) | ||
resque (1.25.2) | ||
mono_logger (~> 1.0) | ||
multi_json (~> 1.0) | ||
redis-namespace (~> 1.3) | ||
sinatra (>= 0.9.2) | ||
vegas (~> 0.1.2) | ||
rspec (2.14.1) | ||
rspec-core (~> 2.14.0) | ||
rspec-expectations (~> 2.14.0) | ||
rspec-mocks (~> 2.14.0) | ||
rspec-core (2.14.8) | ||
rspec-expectations (2.14.5) | ||
diff-lcs (>= 1.1.3, < 2.0) | ||
rspec-mocks (2.14.6) | ||
sidekiq (2.17.8) | ||
celluloid (= 0.15.2) | ||
connection_pool (~> 2.0) | ||
json | ||
redis (~> 3.1) | ||
redis-namespace (~> 1.3) | ||
sinatra (1.4.5) | ||
rack (~> 1.4) | ||
rack-protection (~> 1.4) | ||
tilt (~> 1.3, >= 1.3.4) | ||
sprockets (2.12.2) | ||
hike (~> 1.2) | ||
multi_json (~> 1.0) | ||
rack (~> 1.0) | ||
tilt (~> 1.1, != 1.3.0) | ||
sprockets-rails (3.0.0.beta1) | ||
actionpack (>= 4.0) | ||
activesupport (>= 4.0) | ||
sprockets (~> 2.8) | ||
sqlite3 (1.3.9) | ||
thor (0.19.1) | ||
thread_safe (0.3.4) | ||
tilt (1.4.1) | ||
timers (1.1.0) | ||
tzinfo (1.2.2) | ||
thread_safe (~> 0.1) | ||
vegas (0.1.11) | ||
rack (>= 1.0.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
appraisal | ||
bundler | ||
delayed_job | ||
delayed_job_active_record | ||
delayed_paperclip! | ||
mocha | ||
rails (~> 4.2.0.beta2) | ||
railties | ||
rake | ||
resque | ||
rspec (< 3.0) | ||
sidekiq (< 3.0) | ||
sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module DelayedPaperclip | ||
module Jobs | ||
class ActiveJob < ActiveJob::Base | ||
queue_as :paperclip | ||
|
||
def self.enqueue_delayed_paperclip(instance_klass, instance_id, attachment_name) | ||
# ActiveJob currently does not support symbol arguments | ||
self.perform_later(instance_klass, instance_id, attachment_name.to_s) | ||
end | ||
|
||
def perform(instance_klass, instance_id, attachment_name) | ||
DelayedPaperclip.process_job(instance_klass, instance_id, attachment_name.to_sym) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'spec_helper' | ||
|
||
describe "ActiveJob inline" do | ||
|
||
if defined? ActiveJob | ||
before :all do | ||
DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::ActiveJob | ||
ActiveJob::Base.logger = nil | ||
end | ||
|
||
let(:dummy) { Dummy.new(:image => File.open("#{ROOT}/spec/fixtures/12k.png")) } | ||
|
||
describe "perform job" do | ||
before :each do | ||
DelayedPaperclip.options[:url_with_processing] = true | ||
reset_dummy | ||
end | ||
|
||
it "performs a job" do | ||
dummy.image = File.open("#{ROOT}/spec/fixtures/12k.png") | ||
Paperclip::Attachment.any_instance.expects(:reprocess!) | ||
dummy.save! | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'spec_helper' | ||
require 'resque' | ||
|
||
if defined? ActiveJob | ||
describe "Active Job with Resque backend" do | ||
|
||
before :all do | ||
DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::ActiveJob | ||
ActiveJob::Base.logger = nil | ||
ActiveJob::Base.queue_adapter = :resque | ||
Resque.remove_queue(:paperclip) | ||
end | ||
|
||
let(:dummy) { Dummy.new(:image => File.open("#{ROOT}/spec/fixtures/12k.png")) } | ||
|
||
describe "integration tests" do | ||
include_examples "base usage" | ||
end | ||
|
||
def process_jobs | ||
worker = Resque::Worker.new(:paperclip) | ||
worker.process | ||
end | ||
|
||
def jobs_count | ||
|
||
Resque.size(:paperclip) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'spec_helper' | ||
require 'sidekiq/api' | ||
|
||
describe "ActiveJob with Sidekiq backend" do | ||
|
||
if defined? ActiveJob | ||
before :all do | ||
DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::ActiveJob | ||
ActiveJob::Base.logger = nil | ||
ActiveJob::Base.queue_adapter = :sidekiq | ||
end | ||
|
||
let(:dummy) { Dummy.new(:image => File.open("#{ROOT}/spec/fixtures/12k.png")) } | ||
|
||
describe "integration tests" do | ||
include_examples "base usage" | ||
end | ||
end | ||
|
||
def process_jobs | ||
Sidekiq::Queue.new(:paperclip).each do |job| | ||
worker = job.klass.constantize.new | ||
args = job.args | ||
begin | ||
worker.perform(*args) | ||
rescue # Assume sidekiq handle exception properly | ||
end | ||
job.delete | ||
end | ||
end | ||
|
||
def jobs_count | ||
Sidekiq::Queue.new(:paperclip).size | ||
end | ||
end |
Oops, something went wrong.