Commit 2610cc32 by Jon Yurek

HasAttachedFile respects global settings

Normally, all of the settings would be set on `Attachment`, and they
were `deep_merge`d fine. However, if you set the global

    config.paperclip_defaults = { :validate_media_type => false }

then the `HasAttachedFile` class wouldn't pick up on it, because it only
uses things that are defined in the class. This change makes it so that
the default options are merged in to the ones that `HasAttachedFile`
uses when it sets up the attachment.

Fixes #1857
parent 30406c61
......@@ -12,17 +12,20 @@ Feature: Rails integration
Scenario: Configure defaults for all attachments through Railtie
Given I add this snippet to config/application.rb:
"""
config.paperclip_defaults = {:url => "/paperclip/custom/:attachment/:style/:filename"}
config.paperclip_defaults = {
:url => "/paperclip/custom/:attachment/:style/:filename",
:validate_media_type => false
}
"""
And I attach :attachment
And I start the rails application
When I go to the new user page
And I fill in "Name" with "something"
And I attach the file "spec/support/fixtures/5k.png" to "Attachment"
And I attach the file "spec/support/fixtures/animated.unknown" to "Attachment"
And I press "Submit"
Then I should see "Name: something"
And I should see an image with a path of "/paperclip/custom/attachments/original/5k.png"
And the file at "/paperclip/custom/attachments/original/5k.png" should be the same as "spec/support/fixtures/5k.png"
And I should see an image with a path of "/paperclip/custom/attachments/original/animated.unknown"
And the file at "/paperclip/custom/attachments/original/animated.unknown" should be the same as "spec/support/fixtures/animated.unknown"
Scenario: Add custom processors
Given I add a "test" processor in "lib/paperclip"
......
......@@ -7,7 +7,7 @@ module Paperclip
def initialize(klass, name, options)
@klass = klass
@name = name
@options = options
@options = Paperclip::Attachment.default_options.deep_merge(options)
end
def define
......
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