Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
b3f26a69
Commit
b3f26a69
authored
Jul 31, 2009
by
Jon Yurek
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git@github.com:thoughtbot/paperclip
parents
ac86bb9d
e430afe4
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
17 deletions
+16
-17
lib/paperclip.rb
+1
-1
lib/paperclip/attachment.rb
+2
-1
lib/paperclip/matchers/have_attached_file_matcher.rb
+1
-1
paperclip.gemspec
+1
-1
test/attachment_test.rb
+9
-10
test/geometry_test.rb
+1
-1
test/helper.rb
+1
-2
No files found.
lib/paperclip.rb
View file @
b3f26a69
...
...
@@ -44,7 +44,7 @@ end
# documentation for Paperclip::ClassMethods for more useful information.
module
Paperclip
VERSION
=
"2.
2.9.2
"
VERSION
=
"2.
3.0
"
class
<<
self
# Provides configurability to Paperclip. There are a number of options available, such as:
...
...
lib/paperclip/attachment.rb
View file @
b3f26a69
# encoding: utf-8
module
Paperclip
# The Attachment class manages the files for a given attachment. It saves
# when the model saves, deletes when the model is destroyed, and processes
...
...
@@ -76,7 +77,7 @@ module Paperclip
return
nil
if
uploaded_file
.
nil?
@queued_for_write
[
:original
]
=
uploaded_file
.
to_tempfile
instance_write
(
:file_name
,
uploaded_file
.
original_filename
.
strip
.
gsub
(
/[^
\w\d\.\-
]+/
,
'_'
))
instance_write
(
:file_name
,
uploaded_file
.
original_filename
.
strip
.
gsub
(
/[^
A-Za-z\d\.\-_
]+/
,
'_'
))
instance_write
(
:content_type
,
uploaded_file
.
content_type
.
to_s
.
strip
)
instance_write
(
:file_size
,
uploaded_file
.
size
.
to_i
)
instance_write
(
:updated_at
,
Time
.
now
)
...
...
lib/paperclip/matchers/have_attached_file_matcher.rb
View file @
b3f26a69
...
...
@@ -30,7 +30,7 @@ module Paperclip
protected
def
responds?
methods
=
@subject
.
instance_methods
methods
=
@subject
.
instance_methods
.
map
(
&
:to_s
)
methods
.
include?
(
"
#{
@attachment_name
}
"
)
&&
methods
.
include?
(
"
#{
@attachment_name
}
="
)
&&
methods
.
include?
(
"
#{
@attachment_name
}
?"
)
...
...
paperclip.gemspec
View file @
b3f26a69
...
...
@@ -2,7 +2,7 @@
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
%q{paperclip}
s
.
version
=
"2.
2.9.2
"
s
.
version
=
"2.
3.0
"
s
.
required_rubygems_version
=
Gem
::
Requirement
.
new
(
">= 0"
)
if
s
.
respond_to?
:required_rubygems_version
=
s
.
authors
=
[
"Jon Yurek"
]
...
...
test/attachment_test.rb
View file @
b3f26a69
# encoding: utf-8
require
'test/helper'
class
Dummy
...
...
@@ -498,12 +499,10 @@ class AttachmentTest < Test::Unit::TestCase
rebuild_model
@instance
=
Dummy
.
new
@attachment
=
Paperclip
::
Attachment
.
new
(
:avatar
,
@instance
)
@file
=
File
.
new
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"fixtures"
,
"5k.png"
),
'rb'
)
@file
=
File
.
new
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"fixtures"
,
"5k.png"
),
'rb'
)
end
teardown
do
teardown
do
@file
.
close
Paperclip
::
Attachment
.
default_options
.
merge!
(
@old_defaults
)
end
...
...
@@ -520,13 +519,13 @@ class AttachmentTest < Test::Unit::TestCase
assert_equal
"/avatars/original/missing.png"
,
@attachment
.
url
assert_equal
"/avatars/blah/missing.png"
,
@attachment
.
url
(
:blah
)
end
should
"return nil as path when no file assigned"
do
assert
@attachment
.
to_file
.
nil?
assert_equal
nil
,
@attachment
.
path
assert_equal
nil
,
@attachment
.
path
(
:blah
)
end
context
"with a file assigned in the database"
do
setup
do
@attachment
.
stubs
(
:instance_read
).
with
(
:file_name
).
returns
(
"5k.png"
)
...
...
@@ -545,7 +544,7 @@ class AttachmentTest < Test::Unit::TestCase
should
"make sure the updated_at mtime is in the url if it is defined"
do
assert_match
%r{
#{
Time
.
now
.
to_i
}
$}
,
@attachment
.
url
(
:blah
)
end
should
"make sure the updated_at mtime is NOT in the url if false is passed to the url method"
do
assert_no_match
%r{
#{
Time
.
now
.
to_i
}
$}
,
@attachment
.
url
(
:blah
,
false
)
end
...
...
@@ -561,12 +560,12 @@ class AttachmentTest < Test::Unit::TestCase
end
should
"return the proper path when filename has a single .'s"
do
assert_equal
"./test/../tmp/avatars/dummies/original/
#{
@instance
.
id
}
/5k.png"
,
@attachment
.
path
assert_equal
File
.
expand_path
(
"./test/../tmp/avatars/dummies/original/
#{
@instance
.
id
}
/5k.png"
),
File
.
expand_path
(
@attachment
.
path
)
end
should
"return the proper path when filename has multiple .'s"
do
@attachment
.
stubs
(
:instance_read
).
with
(
:file_name
).
returns
(
"5k.old.png"
)
assert_equal
"./test/../tmp/avatars/dummies/original/
#{
@instance
.
id
}
/5k.old.png"
,
@attachment
.
path
@attachment
.
stubs
(
:instance_read
).
with
(
:file_name
).
returns
(
"5k.old.png"
)
assert_equal
File
.
expand_path
(
"./test/../tmp/avatars/dummies/original/
#{
@instance
.
id
}
/5k.old.png"
),
File
.
expand_path
(
@attachment
.
path
)
end
context
"when expecting three styles"
do
...
...
test/geometry_test.rb
View file @
b3f26a69
...
...
@@ -77,7 +77,7 @@ class GeometryTest < Test::Unit::TestCase
should
"make sure the modifier gets passed during transformation_to"
do
assert
@src
=
Paperclip
::
Geometry
.
parse
(
"123x456"
)
assert
@dst
=
Paperclip
::
Geometry
.
parse
(
"123x456>"
)
assert_equal
"123x456>"
,
@src
.
transformation_to
(
@dst
).
to_s
assert_equal
[
"123x456>"
,
nil
],
@src
.
transformation_to
(
@dst
)
end
should
"generate correct ImageMagick formatting string for W-formatted string"
do
...
...
test/helper.rb
View file @
b3f26a69
require
'rubygems'
require
'test/unit'
gem
'thoughtbot-shoulda'
,
">= 2.9.0"
require
'shoulda'
require
'mocha'
require
'tempfile'
...
...
@@ -40,7 +39,7 @@ def reset_class class_name
end
def
reset_table
table_name
,
&
block
block
||=
lambda
{
true
}
block
||=
lambda
{
|
table
|
true
}
ActiveRecord
::
Base
.
connection
.
create_table
:dummies
,
{
:force
=>
true
},
&
block
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment