Created
July 22, 2010 07:01
-
-
Save jefflab/485675 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From e9fb83adf031610f7ed27bd2cd79a1230bc9ba6f Mon Sep 17 00:00:00 2001 | |
From: jefflab <jefflabarge@gmail.com> | |
Date: Wed, 21 Jul 2010 23:50:34 -0700 | |
Subject: [PATCH] don't destroy arguments in style constructor | |
--- | |
lib/paperclip/style.rb | 8 ++++---- | |
test/style_test.rb | 14 ++++++++++++++ | |
2 files changed, 18 insertions(+), 4 deletions(-) | |
diff --git a/lib/paperclip/style.rb b/lib/paperclip/style.rb | |
index 480efd8..e8f90bb 100644 | |
--- a/lib/paperclip/style.rb | |
+++ b/lib/paperclip/style.rb | |
@@ -15,10 +15,10 @@ module Paperclip | |
@name = name | |
@attachment = attachment | |
if definition.is_a? Hash | |
- @geometry = definition.delete(:geometry) | |
- @format = definition.delete(:format) | |
- @processors = definition.delete(:processors) | |
- @other_args = definition | |
+ @other_args = definition.dup | |
+ @geometry = @other_args.delete(:geometry) | |
+ @format = @other_args.delete(:format) | |
+ @processors = @other_args.delete(:processors) | |
else | |
@geometry, @format = [definition, nil].flatten[0..1] | |
@other_args = {} | |
diff --git a/test/style_test.rb b/test/style_test.rb | |
index 11e5d97..5d6b498 100644 | |
--- a/test/style_test.rb | |
+++ b/test/style_test.rb | |
@@ -32,6 +32,20 @@ class StyleTest < Test::Unit::TestCase | |
assert_equal "100x100#", @style[:geometry] | |
end | |
end | |
+ | |
+ context "Creating a style" do | |
+ setup do | |
+ @styles_args = { :foo => {:geometry => "100x100#", :format => :png} } | |
+ @attachment = attachment :path => ":basename.:extension", | |
+ :styles => @styles_args | |
+ @style = @attachment.styles[:foo] | |
+ end | |
+ | |
+ should "not destroy its arguments" do | |
+ assert_equal "100x100#", @styles_args[:foo][:geometry] | |
+ assert_equal :png, @styles_args[:foo][:format] | |
+ end | |
+ end | |
context "A style rule with properties supplied as procs" do | |
setup do | |
-- | |
1.7.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment