Commit b4ff2c57 by Prem Sichanugrist

Do not show warning if :class exists in the interpolation URL

This fixes #660
parent 3e209072
...@@ -193,7 +193,7 @@ module Paperclip ...@@ -193,7 +193,7 @@ module Paperclip
def check_for_url_clash(name,url,klass) def check_for_url_clash(name,url,klass)
@names_url ||= {} @names_url ||= {}
default_url = url || Attachment.default_options[:url] default_url = url || Attachment.default_options[:url]
if @names_url[name] && @names_url[name][:url] == default_url && @names_url[name][:class] != klass if @names_url[name] && @names_url[name][:url] == default_url && @names_url[name][:class] != klass && @names_url[name][:url] !~ /:class/
log("Duplicate URL for #{name} with #{default_url}. This will clash with attachment defined in #{@names_url[name][:class]} class") log("Duplicate URL for #{name} with #{default_url}. This will clash with attachment defined in #{@names_url[name][:class]} class")
end end
@names_url[name] = {:url => default_url, :class => klass} @names_url[name] = {:url => default_url, :class => klass}
......
...@@ -86,6 +86,16 @@ class PaperclipTest < Test::Unit::TestCase ...@@ -86,6 +86,16 @@ class PaperclipTest < Test::Unit::TestCase
has_attached_file :blah has_attached_file :blah
end end
end end
should "not generate warning if attachment is redifined with the same url string but has :class in it" do
Paperclip.expects(:log).never
Dummy.class_eval do
has_attached_file :blah, :url => "/system/:class/:attachment/:id/:style/:filename"
end
Dummy2.class_eval do
has_attached_file :blah, :url => "/system/:class/:attachment/:id/:style/:filename"
end
end
end end
context "An ActiveRecord model with an 'avatar' attachment" do context "An ActiveRecord model with an 'avatar' attachment" do
......
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