Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Merge branch 'stest' of https://github.com/asanghi/paperclip
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-burns committed Jun 30, 2011
2 parents 4d843c9 + e15648c commit 59e52b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/paperclip/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def initialize name, instance, options = {}

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
Expand Down Expand Up @@ -275,7 +275,7 @@ def reprocess!(*style_args)
def file?
!original_filename.blank?
end

alias :present? :file?

# Writes the attachment-specific attribute on the instance. For example,
Expand Down
15 changes: 9 additions & 6 deletions test/style_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -138,7 +141,7 @@ class StyleTest < Test::Unit::TestCase
end

end

context "A style rule with :processors supplied as procs" do
setup do
@attachment = attachment :path => ":basename.:extension",
Expand Down

0 comments on commit 59e52b7

Please sign in to comment.