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

Commit

Permalink
Merge pull request #125 from aripollak/non-delayed-attachment-matcher
Browse files Browse the repository at this point in the history
Fix setting post_processing to false without delay
  • Loading branch information
ScotterC committed Dec 24, 2014
2 parents 0252dde + 11573ec commit 223a265
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
7 changes: 3 additions & 4 deletions lib/delayed_paperclip/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def self.included(base)
module InstanceMethods

def delayed_options
@options[:delayed]
options[:delayed]
end

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

def split_processing?
options[:only_process] &&
options[:only_process] !=
options[:delayed][:only_process]
options[:only_process] && delayed_options &&
options[:only_process] != delayed_options[:only_process]
end

def processing?
Expand Down
19 changes: 14 additions & 5 deletions spec/delayed_paperclip/attachment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,18 @@
dummy.image.stubs(:delay_processing?).returns true
dummy.image.post_processing_with_delay.should be_false
end

context "on a non-delayed image" do
let(:dummy_options) { { with_processed: false } }

it "is false if delay_processing? is true" do
dummy.image.stubs(:delay_processing?).returns true
dummy.image.post_processing_with_delay.should be_false
end
end
end

describe "delay_processing?" do
describe "#delay_processing?" do
it "returns delayed_options existence if post_processing_with_delay is nil" do
dummy.image.post_processing_with_delay = nil
dummy.image.delay_processing?.should be_true
Expand All @@ -47,7 +56,7 @@
end
end

describe "processing?" do
describe "#processing?" do
it "delegates to the dummy instance" do
dummy.expects(:image_processing?)
dummy.image.processing?
Expand All @@ -62,7 +71,7 @@
end
end

describe "processing_stye?" do
describe "#processing_style?" do
let(:style) { :background }
let(:processing_style?) { dummy.image.processing_style?(style) }

Expand Down Expand Up @@ -107,7 +116,7 @@
end
end

describe "delayed_only_process" do
describe "#delayed_only_process" do
context "without only_process options" do
it "returns []" do
expect(dummy.image.delayed_only_process).to eq []
Expand Down Expand Up @@ -135,7 +144,7 @@
end
end

describe "process_delayed!" do
describe "#process_delayed!" do
it "sets job_is_processing to true" do
dummy.image.expects(:job_is_processing=).with(true).once
dummy.image.expects(:job_is_processing=).with(false).once
Expand Down

0 comments on commit 223a265

Please sign in to comment.