Commit f0cd9ea4 by Jon Yurek

Changed interpolations to run longer-named ones first, preventing collisions.

parent 87bd86cc
...@@ -198,13 +198,13 @@ module Paperclip ...@@ -198,13 +198,13 @@ module Paperclip
end end
def interpolate pattern, style = default_style #:nodoc: def interpolate pattern, style = default_style #:nodoc:
pattern = pattern.dup interpolations = self.class.interpolations.sort{|a,b| a.first.to_s <=> b.first.to_s }
self.class.interpolations.each do |tag, l| interpolations.reverse.inject( pattern.dup ) do |result, interpolation|
pattern.gsub!(/:\b#{tag}\b/) do |match| tag, blk = interpolation
l.call( self, style ) result.gsub(/:#{tag}/) do |match|
blk.call( self, style )
end end
end end
pattern
end end
def queue_existing_for_delete #:nodoc: def queue_existing_for_delete #:nodoc:
......
...@@ -82,7 +82,7 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -82,7 +82,7 @@ class AttachmentTest < Test::Unit::TestCase
end end
should "make sure that they are interpolated correctly" do should "make sure that they are interpolated correctly" do
assert_equal "1024.omg/1024-bbq/:idwhat/000/001/024.wtf", @dummy.avatar.path assert_equal "1024.omg/1024-bbq/1024what/000/001/024.wtf", @dummy.avatar.path
end end
end end
......
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