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
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
11 additions
and
12 deletions
+11
-12
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
+4
-5
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
...
@@ -44,7 +44,7 @@ end
# documentation for Paperclip::ClassMethods for more useful information.
# documentation for Paperclip::ClassMethods for more useful information.
module
Paperclip
module
Paperclip
VERSION
=
"2.
2.9.2
"
VERSION
=
"2.
3.0
"
class
<<
self
class
<<
self
# Provides configurability to Paperclip. There are a number of options available, such as:
# 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
module
Paperclip
# The Attachment class manages the files for a given attachment. It saves
# The Attachment class manages the files for a given attachment. It saves
# when the model saves, deletes when the model is destroyed, and processes
# when the model saves, deletes when the model is destroyed, and processes
...
@@ -76,7 +77,7 @@ module Paperclip
...
@@ -76,7 +77,7 @@ module Paperclip
return
nil
if
uploaded_file
.
nil?
return
nil
if
uploaded_file
.
nil?
@queued_for_write
[
:original
]
=
uploaded_file
.
to_tempfile
@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
(
:content_type
,
uploaded_file
.
content_type
.
to_s
.
strip
)
instance_write
(
:file_size
,
uploaded_file
.
size
.
to_i
)
instance_write
(
:file_size
,
uploaded_file
.
size
.
to_i
)
instance_write
(
:updated_at
,
Time
.
now
)
instance_write
(
:updated_at
,
Time
.
now
)
...
...
lib/paperclip/matchers/have_attached_file_matcher.rb
View file @
b3f26a69
...
@@ -30,7 +30,7 @@ module Paperclip
...
@@ -30,7 +30,7 @@ module Paperclip
protected
protected
def
responds?
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
}
="
)
&&
methods
.
include?
(
"
#{
@attachment_name
}
="
)
&&
methods
.
include?
(
"
#{
@attachment_name
}
?"
)
methods
.
include?
(
"
#{
@attachment_name
}
?"
)
...
...
paperclip.gemspec
View file @
b3f26a69
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
Gem
::
Specification
.
new
do
|
s
|
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
%q{paperclip}
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
.
required_rubygems_version
=
Gem
::
Requirement
.
new
(
">= 0"
)
if
s
.
respond_to?
:required_rubygems_version
=
s
.
authors
=
[
"Jon Yurek"
]
s
.
authors
=
[
"Jon Yurek"
]
...
...
test/attachment_test.rb
View file @
b3f26a69
# encoding: utf-8
require
'test/helper'
require
'test/helper'
class
Dummy
class
Dummy
...
@@ -498,9 +499,7 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -498,9 +499,7 @@ class AttachmentTest < Test::Unit::TestCase
rebuild_model
rebuild_model
@instance
=
Dummy
.
new
@instance
=
Dummy
.
new
@attachment
=
Paperclip
::
Attachment
.
new
(
:avatar
,
@instance
)
@attachment
=
Paperclip
::
Attachment
.
new
(
:avatar
,
@instance
)
@file
=
File
.
new
(
File
.
join
(
File
.
dirname
(
__FILE__
),
@file
=
File
.
new
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"fixtures"
,
"5k.png"
),
'rb'
)
"fixtures"
,
"5k.png"
),
'rb'
)
end
end
teardown
do
teardown
do
...
@@ -561,12 +560,12 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -561,12 +560,12 @@ class AttachmentTest < Test::Unit::TestCase
end
end
should
"return the proper path when filename has a single .'s"
do
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
end
should
"return the proper path when filename has multiple .'s"
do
should
"return the proper path when filename has multiple .'s"
do
@attachment
.
stubs
(
:instance_read
).
with
(
:file_name
).
returns
(
"5k.old.png"
)
@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
assert_equal
File
.
expand_path
(
"./test/../tmp/avatars/dummies/original/
#{
@instance
.
id
}
/5k.old.png"
),
File
.
expand_path
(
@attachment
.
path
)
end
end
context
"when expecting three styles"
do
context
"when expecting three styles"
do
...
...
test/geometry_test.rb
View file @
b3f26a69
...
@@ -77,7 +77,7 @@ class GeometryTest < Test::Unit::TestCase
...
@@ -77,7 +77,7 @@ class GeometryTest < Test::Unit::TestCase
should
"make sure the modifier gets passed during transformation_to"
do
should
"make sure the modifier gets passed during transformation_to"
do
assert
@src
=
Paperclip
::
Geometry
.
parse
(
"123x456"
)
assert
@src
=
Paperclip
::
Geometry
.
parse
(
"123x456"
)
assert
@dst
=
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
end
should
"generate correct ImageMagick formatting string for W-formatted string"
do
should
"generate correct ImageMagick formatting string for W-formatted string"
do
...
...
test/helper.rb
View file @
b3f26a69
require
'rubygems'
require
'rubygems'
require
'test/unit'
require
'test/unit'
gem
'thoughtbot-shoulda'
,
">= 2.9.0"
require
'shoulda'
require
'shoulda'
require
'mocha'
require
'mocha'
require
'tempfile'
require
'tempfile'
...
@@ -40,7 +39,7 @@ def reset_class class_name
...
@@ -40,7 +39,7 @@ def reset_class class_name
end
end
def
reset_table
table_name
,
&
block
def
reset_table
table_name
,
&
block
block
||=
lambda
{
true
}
block
||=
lambda
{
|
table
|
true
}
ActiveRecord
::
Base
.
connection
.
create_table
:dummies
,
{
:force
=>
true
},
&
block
ActiveRecord
::
Base
.
connection
.
create_table
:dummies
,
{
:force
=>
true
},
&
block
end
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