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
7ff4120e
Commit
7ff4120e
authored
Apr 12, 2011
by
Franco Catena
Committed by
Jon Yurek
Apr 20, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not cache dynamic attachment styles
parent
3b170824
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletions
+19
-1
lib/paperclip/attachment.rb
+1
-1
test/attachment_test.rb
+18
-0
No files found.
lib/paperclip/attachment.rb
View file @
7ff4120e
...
...
@@ -64,7 +64,7 @@ module Paperclip
end
def
styles
unless
@normalized_styles
if
@styles
.
respond_to?
(
:call
)
||
!
@normalized_styles
@normalized_styles
=
{}
(
@styles
.
respond_to?
(
:call
)
?
@styles
.
call
(
self
)
:
@styles
).
each
do
|
name
,
args
|
@normalized_styles
[
name
]
=
Paperclip
::
Style
.
new
(
name
,
args
.
dup
,
self
)
...
...
test/attachment_test.rb
View file @
7ff4120e
...
...
@@ -288,6 +288,24 @@ class AttachmentTest < Test::Unit::TestCase
end
end
context
"An attachment with conditional :styles that is a proc"
do
setup
do
rebuild_model
:styles
=>
lambda
{
|
attachment
|
attachment
.
instance
.
other
==
'a'
?
{:
thumb
=>
"50x50#"
}
:
{
:large
=>
"400x400"
}
}
@dummy
=
Dummy
.
new
(
:other
=>
'a'
)
end
should
"have the correct styles for the assigned instance values"
do
assert_equal
"50x50#"
,
@dummy
.
avatar
.
styles
[
:thumb
][
:geometry
]
assert_nil
@dummy
.
avatar
.
styles
[
:large
]
@dummy
.
other
=
'b'
assert_equal
"400x400"
,
@dummy
.
avatar
.
styles
[
:large
][
:geometry
]
assert_nil
@dummy
.
avatar
.
styles
[
:thumb
]
end
end
context
"An attachment with :url that is a proc"
do
setup
do
rebuild_model
:url
=>
lambda
{
|
attachment
|
"path/
#{
attachment
.
instance
.
other
}
.:extension"
}
...
...
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