Commit a1281bee by Prem Sichanugrist

Revert "[#940] Raise error when style defined & not in path"

Reverting this for now. This commit would better be in a minor release,
since it break everyone's application. Going to reopen the ticket and
mark it to be merged in next minor release.

This reverts commit b7b2b843.
parent 6a0124b9
...@@ -77,7 +77,6 @@ module Paperclip ...@@ -77,7 +77,6 @@ module Paperclip
@source_file_options = options[:source_file_options] @source_file_options = options[:source_file_options]
@whiny = options[:whiny] @whiny = options[:whiny]
initialize_path
initialize_storage initialize_storage
end end
...@@ -359,17 +358,6 @@ module Paperclip ...@@ -359,17 +358,6 @@ module Paperclip
file.nil? || (file.respond_to?(:original_filename) && file.respond_to?(:content_type)) file.nil? || (file.respond_to?(:original_filename) && file.respond_to?(:content_type))
end end
def initialize_path
if style_not_in_custom_path?
raise(Paperclip::Errors::StyleTokenNotFound)
end
end
def style_not_in_custom_path?
@options[:path] != Paperclip::Attachment.default_options[:path] &&
@options[:styles].present? && !@options[:path].include?(':style')
end
def initialize_storage #:nodoc: def initialize_storage #:nodoc:
storage_class_name = @options[:storage].to_s.downcase.camelize storage_class_name = @options[:storage].to_s.downcase.camelize
begin begin
......
...@@ -9,11 +9,6 @@ module Paperclip ...@@ -9,11 +9,6 @@ module Paperclip
class StorageMethodNotFound < Paperclip::Error class StorageMethodNotFound < Paperclip::Error
end end
# Will be thrown when there are custom styles and those styles aren't
# included in the path
class StyleTokenNotFound < Paperclip::Error
end
# Will be thrown when a command or executable is not found. # Will be thrown when a command or executable is not found.
class CommandNotFoundError < Paperclip::Error class CommandNotFoundError < Paperclip::Error
end end
......
...@@ -309,7 +309,7 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -309,7 +309,7 @@ class AttachmentTest < Test::Unit::TestCase
context "An attachment with a default style and an extension interpolation" do context "An attachment with a default style and an extension interpolation" do
setup do setup do
@attachment = attachment :path => ":style_:basename.:extension", @attachment = attachment :path => ":basename.:extension",
:styles => { :default => ["100x100", :png] }, :styles => { :default => ["100x100", :png] },
:default_style => :default :default_style => :default
@file = StringIO.new("...") @file = StringIO.new("...")
...@@ -317,7 +317,7 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -317,7 +317,7 @@ class AttachmentTest < Test::Unit::TestCase
end end
should "return the right extension for the path" do should "return the right extension for the path" do
@attachment.assign(@file) @attachment.assign(@file)
assert_equal "default_file.png", @attachment.path assert_equal "file.png", @attachment.path
end end
end end
......
...@@ -243,7 +243,7 @@ class S3Test < Test::Unit::TestCase ...@@ -243,7 +243,7 @@ class S3Test < Test::Unit::TestCase
rebuild_model :styles => { :large => ['500x500#', :jpg] }, rebuild_model :styles => { :large => ['500x500#', :jpg] },
:storage => :s3, :storage => :s3,
:bucket => "bucket", :bucket => "bucket",
:path => ":attachment/:style/:basename.:extension", :path => ":attachment/:basename.:extension",
:s3_credentials => { :s3_credentials => {
'access_key_id' => "12345", 'access_key_id' => "12345",
'secret_access_key' => "54321" 'secret_access_key' => "54321"
......
...@@ -5,7 +5,7 @@ class StyleTest < Test::Unit::TestCase ...@@ -5,7 +5,7 @@ class StyleTest < Test::Unit::TestCase
context "A style rule" do context "A style rule" do
setup do setup do
@attachment = attachment :path => ":basename_:style.:extension", @attachment = attachment :path => ":basename.:extension",
:styles => { :foo => {:geometry => "100x100#", :format => :png} }, :styles => { :foo => {:geometry => "100x100#", :format => :png} },
:whiny => true :whiny => true
@style = @attachment.styles[:foo] @style = @attachment.styles[:foo]
...@@ -33,18 +33,9 @@ class StyleTest < Test::Unit::TestCase ...@@ -33,18 +33,9 @@ class StyleTest < Test::Unit::TestCase
end end
end end
context "A path not containing a style rule" do
should "generate a warning when a :style token isn't found" do
assert_raises(Paperclip::Errors::StyleTokenNotFound) do
@attachment = attachment :path => ":basename_:extension",
:styles => { :foo => {:geometry => "100x100#", :format => :png} }
end
end
end
context "A style rule with properties supplied as procs" do context "A style rule with properties supplied as procs" do
setup do setup do
@attachment = attachment :path => ":style_:basename.:extension", @attachment = attachment :path => ":basename.:extension",
:whiny_thumbnails => true, :whiny_thumbnails => true,
:processors => lambda {|a| [:test]}, :processors => lambda {|a| [:test]},
:styles => { :styles => {
...@@ -73,7 +64,7 @@ class StyleTest < Test::Unit::TestCase ...@@ -73,7 +64,7 @@ class StyleTest < Test::Unit::TestCase
styles[:aslist] = ["100x100", :png] styles[:aslist] = ["100x100", :png]
styles[:ashash] = {:geometry => "100x100", :format => :png} styles[:ashash] = {:geometry => "100x100", :format => :png}
styles[:asstring] = "100x100" styles[:asstring] = "100x100"
@attachment = attachment :path => ":style_:basename.:extension", @attachment = attachment :path => ":basename.:extension",
:styles => styles :styles => styles
end end
should "have the right number of styles" do should "have the right number of styles" do
...@@ -106,7 +97,7 @@ class StyleTest < Test::Unit::TestCase ...@@ -106,7 +97,7 @@ class StyleTest < Test::Unit::TestCase
context "An attachment with :convert_options" do context "An attachment with :convert_options" do
setup do setup do
@attachment = attachment :path => ":style_:basename.:extension", @attachment = attachment :path => ":basename.:extension",
:styles => {:thumb => "100x100", :large => "400x400"}, :styles => {:thumb => "100x100", :large => "400x400"},
:convert_options => {:all => "-do_stuff", :thumb => "-thumbnailize"} :convert_options => {:all => "-do_stuff", :thumb => "-thumbnailize"}
@style = @attachment.styles[:thumb] @style = @attachment.styles[:thumb]
...@@ -126,7 +117,7 @@ class StyleTest < Test::Unit::TestCase ...@@ -126,7 +117,7 @@ class StyleTest < Test::Unit::TestCase
context "An attachment with :source_file_options" do context "An attachment with :source_file_options" do
setup do setup do
@attachment = attachment :path => ":style_:basename.:extension", @attachment = attachment :path => ":basename.:extension",
:styles => {:thumb => "100x100", :large => "400x400"}, :styles => {:thumb => "100x100", :large => "400x400"},
:source_file_options => {:all => "-density 400", :thumb => "-depth 8"} :source_file_options => {:all => "-density 400", :thumb => "-depth 8"}
@style = @attachment.styles[:thumb] @style = @attachment.styles[:thumb]
...@@ -146,7 +137,7 @@ class StyleTest < Test::Unit::TestCase ...@@ -146,7 +137,7 @@ class StyleTest < Test::Unit::TestCase
context "A style rule with its own :processors" do context "A style rule with its own :processors" do
setup do setup do
@attachment = attachment :path => ":style_:basename.:extension", @attachment = attachment :path => ":basename.:extension",
:styles => { :styles => {
:foo => { :foo => {
:geometry => "100x100#", :geometry => "100x100#",
...@@ -171,7 +162,7 @@ class StyleTest < Test::Unit::TestCase ...@@ -171,7 +162,7 @@ class StyleTest < Test::Unit::TestCase
context "A style rule with :processors supplied as procs" do context "A style rule with :processors supplied as procs" do
setup do setup do
@attachment = attachment :path => ":style_:basename.:extension", @attachment = attachment :path => ":basename.:extension",
:styles => { :styles => {
:foo => { :foo => {
:geometry => "100x100#", :geometry => "100x100#",
...@@ -193,7 +184,7 @@ class StyleTest < Test::Unit::TestCase ...@@ -193,7 +184,7 @@ class StyleTest < Test::Unit::TestCase
context "An attachment with :convert_options and :source_file_options in :styles" do context "An attachment with :convert_options and :source_file_options in :styles" do
setup do setup do
@attachment = attachment :path => ":style_:basename.:extension", @attachment = attachment :path => ":basename.:extension",
:styles => { :styles => {
:thumb => "100x100", :thumb => "100x100",
:large => {:geometry => "400x400", :large => {:geometry => "400x400",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment