Commit 59e52b70 by Mike Burns

Merge branch 'stest' of https://github.com/asanghi/paperclip

parents 4d843c9c e15648c6
...@@ -67,7 +67,7 @@ module Paperclip ...@@ -67,7 +67,7 @@ module Paperclip
def styles def styles
if @styles.respond_to?(:call) || !@normalized_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| (@styles.respond_to?(:call) ? @styles.call(self) : @styles).each do |name, args|
@normalized_styles[name] = Paperclip::Style.new(name, args.dup, self) @normalized_styles[name] = Paperclip::Style.new(name, args.dup, self)
end end
...@@ -275,7 +275,7 @@ module Paperclip ...@@ -275,7 +275,7 @@ module Paperclip
def file? def file?
!original_filename.blank? !original_filename.blank?
end end
alias :present? :file? alias :present? :file?
# Writes the attachment-specific attribute on the instance. For example, # Writes the attachment-specific attribute on the instance. For example,
......
...@@ -62,12 +62,12 @@ class StyleTest < Test::Unit::TestCase ...@@ -62,12 +62,12 @@ class StyleTest < Test::Unit::TestCase
context "An attachment with style rules in various forms" do context "An attachment with style rules in various forms" do
setup 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", @attachment = attachment :path => ":basename.:extension",
:styles => { :styles => styles
:aslist => ["100x100", :png],
:ashash => {:geometry => "100x100", :format => :png},
:asstring => "100x100"
}
end end
should "have the right number of styles" do should "have the right number of styles" do
assert_kind_of Hash, @attachment.styles assert_kind_of Hash, @attachment.styles
...@@ -92,6 +92,9 @@ class StyleTest < Test::Unit::TestCase ...@@ -92,6 +92,9 @@ class StyleTest < Test::Unit::TestCase
assert_nil @attachment.styles[:asstring].format assert_nil @attachment.styles[:asstring].format
end end
should "retain order" do
assert_equal [:aslist, :ashash, :asstring], @attachment.styles.keys
end
end end
context "An attachment with :convert_options" do context "An attachment with :convert_options" do
...@@ -138,7 +141,7 @@ class StyleTest < Test::Unit::TestCase ...@@ -138,7 +141,7 @@ class StyleTest < Test::Unit::TestCase
end end
end end
context "A style rule with :processors supplied as procs" do context "A style rule with :processors supplied as procs" do
setup do setup do
@attachment = attachment :path => ":basename.:extension", @attachment = attachment :path => ":basename.:extension",
......
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