diff --git a/lib/carrierwave/uploader/versions.rb b/lib/carrierwave/uploader/versions.rb index b817e3e18..cacac8018 100644 --- a/lib/carrierwave/uploader/versions.rb +++ b/lib/carrierwave/uploader/versions.rb @@ -27,6 +27,17 @@ def build(superclass) @klass.processors = [] @klass.version_options = @options @klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1 + # Define the enable_processing method for versions so they get the + # value from the parent class unless explicitly overwritten + def self.enable_processing(value=nil) + self.enable_processing = value if value + if defined?(@enable_processing) && !@enable_processing.nil? + @enable_processing + else + superclass.enable_processing + end + end + # Regardless of what is set in the parent uploader, do not enforce the # move_to_cache config option on versions because it moves the original # file to the version's target file. diff --git a/spec/uploader/versions_spec.rb b/spec/uploader/versions_spec.rb index 1c77c8549..34f2a723c 100644 --- a/spec/uploader/versions_spec.rb +++ b/spec/uploader/versions_spec.rb @@ -111,6 +111,13 @@ def store_dir expect(@uploader.thumb.enable_processing).to be_truthy end + it "should use the enable processing value of the parent after reading its own value" do + @uploader_class.version :thumb + @uploader.cache!(File.open(file_path('test.jpg'))) + @uploader_class.enable_processing = false + expect(@uploader.thumb.class.enable_processing).to be_falsey + end + it "should reopen the same class when called multiple times" do @uploader_class.version :thumb do def self.monkey