Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Remove attachment path clash checker #1192

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/paperclip.rb
Expand Up @@ -182,7 +182,6 @@ def has_attached_file(name, options = {})

attachment_definitions[name] = Paperclip::AttachmentOptions.new(options)
Paperclip.classes_with_attachments << self.name
Paperclip.check_for_path_clash(name,attachment_definitions[name][:path],self.name)

after_save :save_attached_files
before_destroy :prepare_for_destroy
Expand Down
9 changes: 0 additions & 9 deletions lib/paperclip/helpers.rb
Expand Up @@ -49,15 +49,6 @@ def class_for(class_name)
end
end

def check_for_path_clash(name,path,klass)
@names_path ||= {}
default_path = path || Attachment.default_options[:path]
if @names_path[name] && @names_path[name][:path] == default_path && @names_path[name][:class] != klass && @names_path[name][:path] !~ /:class/
log("Duplicate path for #{name} with #{default_path}. This will clash with attachment defined in #{@names_path[name][:class]} class")
end
@names_path[name] = {:path => default_path, :class => klass}
end

def reset_duplicate_clash_check!
@names_url = nil
end
Expand Down
39 changes: 0 additions & 39 deletions test/paperclip_test.rb
Expand Up @@ -107,45 +107,6 @@ class ::Four; end
end
end

context "Attachments with clashing URLs should raise error" do
setup do
class Dummy2 < ActiveRecord::Base
include Paperclip::Glue
end
end

should "generate warning if attachment is redefined with the same path string" do
expected_log_msg = "Duplicate path for blah with /system/:id/:style/:filename. This will clash with attachment defined in Dummy class"
Paperclip.expects(:log).with(expected_log_msg)
Dummy.class_eval do
has_attached_file :blah, :path => '/system/:id/:style/:filename'
end
Dummy2.class_eval do
has_attached_file :blah, :path => '/system/:id/:style/:filename'
end
end

should "not generate warning if attachment is redefined with the same path string but has :class in it" do
Paperclip.expects(:log).never
Dummy.class_eval do
has_attached_file :blah, :path => "/system/:class/:attachment/:id/:style/:filename"
end
Dummy2.class_eval do
has_attached_file :blah, :path => "/system/:class/:attachment/:id/:style/:filename"
end
end

should "not generate warning if attachment is defined with the same URL string" do
Paperclip.expects(:log).never
Dummy.class_eval do
has_attached_file :blah, :path => "/system/:class/:attachment/:id/:style/:filename", :url => ":s3_alias_url"
end
Dummy2.class_eval do
has_attached_file :blah, :path => "/system/:class/:attachment/:id/:style/:filename", :url => ":s3_alias_url"
end
end
end

context "An ActiveRecord model with an 'avatar' attachment" do
setup do
rebuild_model :path => "tmp/:class/omg/:style.:extension"
Expand Down