Commit e15648c6 by Aditya Sanghi

Adding tests for #414 . Ordered Styles, but only if you provide them in order.

parent e703662f
......@@ -65,7 +65,7 @@ module Paperclip
def styles
if @styles.respond_to?(:call) || !@normalized_styles
@normalized_styles = {}
@normalized_styles = ActiveSupport::OrderedHash.new
(@styles.respond_to?(:call) ? @styles.call(self) : @styles).each do |name, args|
@normalized_styles[name] = Paperclip::Style.new(name, args.dup, self)
end
......
......@@ -62,12 +62,12 @@ class StyleTest < Test::Unit::TestCase
context "An attachment with style rules in various forms" do
setup do
styles = ActiveSupport::OrderedHash.new
styles[:aslist] = ["100x100", :png]
styles[:ashash] = {:geometry => "100x100", :format => :png}
styles[:asstring] = "100x100"
@attachment = attachment :path => ":basename.:extension",
:styles => {
:aslist => ["100x100", :png],
:ashash => {:geometry => "100x100", :format => :png},
:asstring => "100x100"
}
:styles => styles
end
should "have the right number of styles" do
assert_kind_of Hash, @attachment.styles
......@@ -92,6 +92,9 @@ class StyleTest < Test::Unit::TestCase
assert_nil @attachment.styles[:asstring].format
end
should "retain order" do
assert_equal [:aslist, :ashash, :asstring], @attachment.styles.keys
end
end
context "An attachment with :convert_options" do
......
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