Skip to content
This repository was archived by the owner on Oct 5, 2018. It is now read-only.

Commit a923f57

Browse files
author
Scott Carleton
committed
Merge pull request #79 from ScotterC/merging-in-62
Merges in #62
2 parents c4e6b32 + 359b442 commit a923f57

12 files changed

+40
-12
lines changed

delayed_paperclip.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
2323
s.add_development_dependency 'appraisal'
2424
s.add_development_dependency 'rake'
2525
s.add_development_dependency 'bundler'
26+
s.add_development_dependency 'railties'
2627

2728
s.files = `git ls-files`.split("\n")
2829
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")

gemfiles/rails3_1.gemfile.lock

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ DEPENDENCIES
155155
delayed_paperclip!
156156
mocha
157157
rails (~> 3.1.12)
158+
railties
158159
rake
159160
resque
160161
rspec

gemfiles/rails3_2.gemfile.lock

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ DEPENDENCIES
153153
delayed_paperclip!
154154
mocha
155155
rails (~> 3.2.17)
156+
railties
156157
rake
157158
resque
158159
rspec

gemfiles/rails4.gemfile.lock

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ DEPENDENCIES
149149
delayed_paperclip!
150150
mocha
151151
rails (~> 4.0.3)
152+
railties
152153
rake
153154
resque
154155
rspec

lib/delayed_paperclip.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ def process_in_background(name, options = {})
5151
paperclip_definitions[name][:delayed] = {}
5252

5353
# Set Defaults
54+
only_process_default = paperclip_definitions[name][:only_process]
55+
only_process_default ||= []
5456
{
5557
:priority => 0,
56-
:only_process => paperclip_definitions[name][:only_process],
58+
:only_process => only_process_default,
5759
:url_with_processing => DelayedPaperclip.options[:url_with_processing],
5860
:processing_image_url => options[:processing_image_url],
5961
:queue => nil

lib/delayed_paperclip/attachment.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def self.included(base)
1313
module InstanceMethods
1414

1515
def delayed_options
16-
@instance.class.paperclip_definitions[@name][:delayed] unless @instance.class.paperclip_definitions[@name].nil?
16+
@options[:delayed]
1717
end
1818

1919
# Attr accessor in Paperclip
@@ -36,9 +36,9 @@ def delay_processing?
3636
end
3737

3838
def split_processing?
39-
@instance.class.paperclip_definitions[@name][:only_process] &&
40-
@instance.class.paperclip_definitions[@name][:only_process] !=
41-
delayed_options[:only_process]
39+
options[:only_process] &&
40+
options[:only_process] !=
41+
options[:delayed][:only_process]
4242
end
4343

4444
def processing?

spec/delayed_paperclip/attachment_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
it "returns the specific options for delayed paperclip" do
1616
dummy.image.delayed_options.should == {
1717
:priority => 0,
18-
:only_process => nil,
18+
:only_process => [],
1919
:url_with_processing => true,
2020
:processing_image_url => nil,
2121
:queue => nil

spec/delayed_paperclip/class_methods_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Dummy.paperclip_definitions.should == { :image => {
1919
:delayed => {
2020
:priority => 0,
21-
:only_process => nil,
21+
:only_process => [],
2222
:url_with_processing => true,
2323
:processing_image_url => nil,
2424
:queue => nil}
@@ -35,7 +35,7 @@
3535
Dummy.paperclip_definitions.should == { :image => {
3636
:delayed => {
3737
:priority => 0,
38-
:only_process => nil,
38+
:only_process => [],
3939
:url_with_processing => true,
4040
:processing_image_url => "/processing/url",
4141
:queue => nil}

spec/delayed_paperclip_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
it "returns paperclip options regardless of version" do
4848
Dummy.paperclip_definitions.should == {:image => { :styles => { :thumbnail => "25x25" },
4949
:delayed => { :priority => 0,
50-
:only_process => nil,
50+
:only_process => [],
5151
:url_with_processing => true,
5252
:processing_image_url => nil,
5353
:queue => nil}

spec/spec_helper.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
$LOAD_PATH.unshift(File.dirname(__FILE__))
22
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
33

4-
require 'rails'
54
require 'active_record'
5+
require 'active_record/version'
6+
require 'active_support'
7+
require 'active_support/core_ext'
68
require 'rspec'
79
require 'mocha/api'
810

11+
begin
12+
require 'pry'
13+
rescue LoadError
14+
# Pry is not available, just ignore.
15+
end
16+
917
require 'paperclip/railtie'
1018
Paperclip::Railtie.insert
1119

test/base_delayed_paperclip_test.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,16 @@ def test_delayed_paperclip_functioning_with_paperclip_only_process_option
185185
dummy.save!
186186
process_jobs
187187
end
188-
188+
189189
def test_delayed_paperclip_functioning_with_only_process_and_paperclip_only_process_option
190190
reset_class "Dummy", :with_processed => true, :only_process => [:small], :paperclip => { :only_process => [:thumbnail] }
191+
191192
Paperclip::Attachment.any_instance.expects(:post_process).with(:thumbnail)
193+
Paperclip::Attachment.any_instance.expects(:post_process).with(:small).never
194+
192195
Paperclip::Attachment.any_instance.expects(:reprocess!).with(:small)
196+
Paperclip::Attachment.any_instance.expects(:reprocess!).with(:thumbnail).never
197+
193198
dummy = Dummy.new(:image => File.open("#{RAILS_ROOT}/test/fixtures/12k.png"))
194199
dummy.save!
195200
process_jobs

test/test_helper.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22
require 'test/unit'
33
require 'mocha/setup'
44
require 'active_record'
5+
require 'active_record/version'
6+
require 'active_support'
7+
require 'active_support/core_ext'
58
require 'logger'
69
require 'sqlite3'
7-
require 'paperclip/railtie'
810

11+
begin
12+
require 'pry'
13+
rescue LoadError
14+
# Pry is not available, just ignore.
15+
end
16+
17+
require 'paperclip/railtie'
918
Paperclip::Railtie.insert
1019

1120
ROOT = File.join(File.dirname(__FILE__), '..')

0 commit comments

Comments
 (0)