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
01d2fdac
Commit
01d2fdac
authored
May 04, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Symbolize all the style keys
This will prevent a pitfall as sometime the style's name can be a string.
parent
84a01174
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
2 deletions
+42
-2
lib/paperclip/attachment.rb
+3
-1
test/integration_test.rb
+39
-1
No files found.
lib/paperclip/attachment.rb
View file @
01d2fdac
...
...
@@ -90,6 +90,7 @@ module Paperclip
ensure_required_accessors!
file
=
Paperclip
.
io_adapters
.
for
(
uploaded_file
)
@options
[
:only_process
].
map!
(
&
:to_sym
)
self
.
clear
(
*
@options
[
:only_process
])
return
nil
if
file
.
nil?
...
...
@@ -164,7 +165,7 @@ module Paperclip
if
styling_option
.
respond_to?
(
:call
)
||
!
@normalized_styles
@normalized_styles
=
ActiveSupport
::
OrderedHash
.
new
(
styling_option
.
respond_to?
(
:call
)
?
styling_option
.
call
(
self
)
:
styling_option
).
each
do
|
name
,
args
|
@normalized_styles
[
name
]
=
Paperclip
::
Style
.
new
(
name
,
args
.
dup
,
self
)
@normalized_styles
[
name
.
to_sym
]
=
Paperclip
::
Style
.
new
(
name
.
to_sym
,
args
.
dup
,
self
)
end
end
@normalized_styles
...
...
@@ -375,6 +376,7 @@ module Paperclip
def
post_process
(
*
style_args
)
#:nodoc:
return
if
@queued_for_write
[
:original
].
nil?
instance
.
run_paperclip_callbacks
(
:post_process
)
do
instance
.
run_paperclip_callbacks
(
:"
#{
name
}
_post_process"
)
do
post_process_styles
(
*
style_args
)
...
...
test/integration_test.rb
View file @
01d2fdac
...
...
@@ -439,11 +439,50 @@ class IntegrationTest < Test::Unit::TestCase
@dummy
.
avatar
=
@file
end
teardown
{
@file
.
close
}
should
"should not error when saving"
do
@dummy
.
save!
end
end
context
"A model with an attachment with hash in file name"
do
setup
do
@settings
=
{
:styles
=>
{
:thumb
=>
"50x50#"
},
:path
=>
":rails_root/public/system/:attachment/:id_partition/:style/:hash.:extension"
,
:url
=>
"/system/:attachment/:id_partition/:style/:hash.:extension"
,
:hash_secret
=>
"somesecret"
}
rebuild_model
@settings
@file
=
File
.
new
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"fixtures"
,
"5k.png"
),
'rb'
)
@dummy
=
Dummy
.
create!
:avatar
=>
@file
end
teardown
do
@file
.
close
end
should
"be accessible"
do
assert
File
.
exists?
(
@dummy
.
avatar
.
path
(
:original
))
assert
File
.
exists?
(
@dummy
.
avatar
.
path
(
:thumb
))
end
context
"when new style is added"
do
setup
do
@dummy
.
avatar
.
options
[
:styles
][
:mini
]
=
"25x25#"
@dummy
.
avatar
.
instance_variable_set
:@normalized_styles
,
nil
@dummy
.
avatar
.
reprocess!
'mini'
end
should
"make all the styles accessible"
do
assert
File
.
exists?
(
@dummy
.
avatar
.
path
(
:original
))
assert
File
.
exists?
(
@dummy
.
avatar
.
path
(
:thumb
))
assert
File
.
exists?
(
@dummy
.
avatar
.
path
(
:mini
))
end
end
end
if
ENV
[
'S3_TEST_BUCKET'
]
def
s3_files_for
attachment
[
:thumb
,
:medium
,
:large
,
:original
].
inject
({})
do
|
files
,
style
|
...
...
@@ -604,4 +643,3 @@ class IntegrationTest < Test::Unit::TestCase
end
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