Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
Merge pull request jstorimer#79 from ScotterC/merging-in-62
Browse files Browse the repository at this point in the history
Merges in jstorimer#62
  • Loading branch information
ScotterC committed Feb 19, 2014
2 parents c4e6b32 + 359b442 commit a923f57
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 12 deletions.
1 change: 1 addition & 0 deletions delayed_paperclip.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'appraisal'
s.add_development_dependency 'rake'
s.add_development_dependency 'bundler'
s.add_development_dependency 'railties'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails3_1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ DEPENDENCIES
delayed_paperclip!
mocha
rails (~> 3.1.12)
railties
rake
resque
rspec
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails3_2.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ DEPENDENCIES
delayed_paperclip!
mocha
rails (~> 3.2.17)
railties
rake
resque
rspec
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails4.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ DEPENDENCIES
delayed_paperclip!
mocha
rails (~> 4.0.3)
railties
rake
resque
rspec
Expand Down
4 changes: 3 additions & 1 deletion lib/delayed_paperclip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ def process_in_background(name, options = {})
paperclip_definitions[name][:delayed] = {}

# Set Defaults
only_process_default = paperclip_definitions[name][:only_process]
only_process_default ||= []
{
:priority => 0,
:only_process => paperclip_definitions[name][:only_process],
:only_process => only_process_default,
:url_with_processing => DelayedPaperclip.options[:url_with_processing],
:processing_image_url => options[:processing_image_url],
:queue => nil
Expand Down
8 changes: 4 additions & 4 deletions lib/delayed_paperclip/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.included(base)
module InstanceMethods

def delayed_options
@instance.class.paperclip_definitions[@name][:delayed] unless @instance.class.paperclip_definitions[@name].nil?
@options[:delayed]
end

# Attr accessor in Paperclip
Expand All @@ -36,9 +36,9 @@ def delay_processing?
end

def split_processing?
@instance.class.paperclip_definitions[@name][:only_process] &&
@instance.class.paperclip_definitions[@name][:only_process] !=
delayed_options[:only_process]
options[:only_process] &&
options[:only_process] !=
options[:delayed][:only_process]
end

def processing?
Expand Down
2 changes: 1 addition & 1 deletion spec/delayed_paperclip/attachment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
it "returns the specific options for delayed paperclip" do
dummy.image.delayed_options.should == {
:priority => 0,
:only_process => nil,
:only_process => [],
:url_with_processing => true,
:processing_image_url => nil,
:queue => nil
Expand Down
4 changes: 2 additions & 2 deletions spec/delayed_paperclip/class_methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Dummy.paperclip_definitions.should == { :image => {
:delayed => {
:priority => 0,
:only_process => nil,
:only_process => [],
:url_with_processing => true,
:processing_image_url => nil,
:queue => nil}
Expand All @@ -35,7 +35,7 @@
Dummy.paperclip_definitions.should == { :image => {
:delayed => {
:priority => 0,
:only_process => nil,
:only_process => [],
:url_with_processing => true,
:processing_image_url => "/processing/url",
:queue => nil}
Expand Down
2 changes: 1 addition & 1 deletion spec/delayed_paperclip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
it "returns paperclip options regardless of version" do
Dummy.paperclip_definitions.should == {:image => { :styles => { :thumbnail => "25x25" },
:delayed => { :priority => 0,
:only_process => nil,
:only_process => [],
:url_with_processing => true,
:processing_image_url => nil,
:queue => nil}
Expand Down
10 changes: 9 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))

require 'rails'
require 'active_record'
require 'active_record/version'
require 'active_support'
require 'active_support/core_ext'
require 'rspec'
require 'mocha/api'

begin
require 'pry'
rescue LoadError
# Pry is not available, just ignore.
end

require 'paperclip/railtie'
Paperclip::Railtie.insert

Expand Down
7 changes: 6 additions & 1 deletion test/base_delayed_paperclip_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,16 @@ def test_delayed_paperclip_functioning_with_paperclip_only_process_option
dummy.save!
process_jobs
end

def test_delayed_paperclip_functioning_with_only_process_and_paperclip_only_process_option
reset_class "Dummy", :with_processed => true, :only_process => [:small], :paperclip => { :only_process => [:thumbnail] }

Paperclip::Attachment.any_instance.expects(:post_process).with(:thumbnail)
Paperclip::Attachment.any_instance.expects(:post_process).with(:small).never

Paperclip::Attachment.any_instance.expects(:reprocess!).with(:small)
Paperclip::Attachment.any_instance.expects(:reprocess!).with(:thumbnail).never

dummy = Dummy.new(:image => File.open("#{RAILS_ROOT}/test/fixtures/12k.png"))
dummy.save!
process_jobs
Expand Down
11 changes: 10 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
require 'test/unit'
require 'mocha/setup'
require 'active_record'
require 'active_record/version'
require 'active_support'
require 'active_support/core_ext'
require 'logger'
require 'sqlite3'
require 'paperclip/railtie'

begin
require 'pry'
rescue LoadError
# Pry is not available, just ignore.
end

require 'paperclip/railtie'
Paperclip::Railtie.insert

ROOT = File.join(File.dirname(__FILE__), '..')
Expand Down

0 comments on commit a923f57

Please sign in to comment.