Permalink
Browse files

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

This fixes #660
  • Loading branch information...
1 parent 3e20907 commit b4ff2c5777df6ac3b0942dc645cfde2d1ace62c8 @sikachu sikachu committed Dec 12, 2011
Showing with 11 additions and 1 deletion.
  1. +1 −1 lib/paperclip.rb
  2. +10 −0 test/paperclip_test.rb
View
@@ -193,7 +193,7 @@ def class_for(class_name)
def check_for_url_clash(name,url,klass)
@names_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")
end
@names_url[name] = {:url => default_url, :class => klass}
@@ -86,6 +86,16 @@ class Dummy2 < ActiveRecord::Base
has_attached_file :blah
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
context "An ActiveRecord model with an 'avatar' attachment" do

0 comments on commit b4ff2c5

Please sign in to comment.