Permalink
Browse files

Formatting and anchoring the extension gsub to the end

  • Loading branch information...
1 parent 7d29d06 commit 94eb2916da5ed6e1d1bf548e47466e665e879e1b @jyurek jyurek committed Nov 5, 2008
Showing with 6 additions and 7 deletions.
  1. +6 −6 lib/paperclip/attachment.rb
  2. +0 −1 test/attachment_test.rb
@@ -74,11 +74,11 @@ def assign uploaded_file
return nil if uploaded_file.nil?
logger.info("[paperclip] Writing attributes for #{name}")
- @queued_for_write[:original] = uploaded_file.to_tempfile
- instance_write(:file_name, uploaded_file.original_filename.strip.gsub(/[^\w\d\.\-]+/, '_'))
- instance_write(:content_type, uploaded_file.content_type.strip)
- instance_write(:file_size, uploaded_file.size.to_i)
- instance_write(:updated_at, Time.now)
+ @queued_for_write[:original] = uploaded_file.to_tempfile
+ instance_write(:file_name, uploaded_file.original_filename.strip.gsub(/[^\w\d\.\-]+/, '_'))
+ instance_write(:content_type, uploaded_file.content_type.strip)
+ instance_write(:file_size, uploaded_file.size.to_i)
+ instance_write(:updated_at, Time.now)
@dirty = true
@@ -169,7 +169,7 @@ def self.interpolations
attachment.instance.class.name.underscore.pluralize
end,
:basename => lambda do |attachment,style|
- attachment.original_filename.gsub(File.extname(attachment.original_filename), "")
+ attachment.original_filename.gsub(/#{File.extname(attachment.original_filename)}$/, "")
end,
:extension => lambda do |attachment,style|
((style = attachment.styles[style]) && style.last) ||
View
@@ -174,7 +174,6 @@ class AttachmentTest < Test::Unit::TestCase
should "strip whitespace from content_type field" do
assert_equal "image/png", @dummy.avatar.instance.avatar_content_type
end
-
end
context "Attachment with strange letters" do

0 comments on commit 94eb291

Please sign in to comment.