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

Return attachment URL for a style not marked to be processed in background #108

Merged
merged 1 commit into from
Dec 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/delayed_paperclip/url_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.included(base)
end

def for_with_processed(style_name, options)
most_appropriate_url = most_appropriate_url(style_name)
most_appropriate_url = @attachment.processing_style?(style_name) ? most_appropriate_url(style_name) : most_appropriate_url_without_processed

escape_url_as_needed(
timestamp_as_needed(
Expand Down
34 changes: 31 additions & 3 deletions spec/delayed_paperclip/url_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
let(:dummy_options) { {} }

describe "for_with_processed" do
context "with split pcoessing" do
before do
attachment.stubs(:original_filename).returns "12k.png"
end

context "with split processing" do
# everything in this hash is passed to delayed_paperclip, expect for the
# paperclip stuff
let(:dummy_options) { {
Expand All @@ -26,8 +30,32 @@
only_process: [:background]
}}

it "returns the default_url when the style is still being processed" do
expect(attachment.url(:background)).to eql "/images/background/missing.png"
context "processing" do
before do
attachment.stubs(:processing?).returns true
end

it "returns the default_url when the style is still being processed" do
expect(attachment.url(:background)).to eql "/images/background/missing.png"
end

it "returns the attachment url when the style is not set for background processing" do
expect(attachment.url(:online)).to eql "/system/dummies/images/000/000/001/online/12k.png"
end
end

context "not processing" do
before do
attachment.stubs(:processing?).returns false
end

it "returns the attachment url even when the style is set for background processing" do
expect(attachment.url(:background)).to eql "/system/dummies/images/000/000/001/background/12k.png"
end

it "returns the generated url when the style is not set for background processing" do
expect(attachment.url(:online)).to eql "/system/dummies/images/000/000/001/online/12k.png"
end
end
end
end
Expand Down