Skip to content

Instantly share code, notes, and snippets.

@qrush
Created June 5, 2009 19:34
Show Gist options
  • Save qrush/124457 to your computer and use it in GitHub Desktop.
Save qrush/124457 to your computer and use it in GitHub Desktop.
-- Failing test case
context "Default style and styles coercing image mime type to be something
different than original" do
setup do
rebuild_model :styles => {:thumb=> ["100x100#", :jpg],
:small => ["150x150>", :jpg],
:medium => ["300x300>", :jpg],
:large => ["500x500>", :jpg]
},
:default_style => :large
@dummy = Dummy.new
@file = File.new(File.join(File.dirname(__FILE__),
"fixtures",
"5k.png"), 'rb')
@dummy.avatar = @file
end
teardown { @file.close }
context 'when saved' do
setup do
@dummy.save
end
should 'have the correct path containing correct file mime type' do
assert_match(/\/system\/avatars\/1\/large\/5k.jpg/, @dummy.avatar.url)
end
should 'have the correct url containing correct file mime type' do
assert_match(/\/system\/avatars\/1\/large\/5k.jpg/, @dummy.avatar.path)
end
end
end
--Fix
attachment.rb
line 121
#changed style from default of nil to include the default style
def path style = default_style #:nodoc:
original_filename.nil? ? nil : interpolate(@path, style)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment