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
92e88fc3
Commit
92e88fc3
authored
Nov 21, 2012
by
Pavel Pravosud
Committed by
Jon Yurek
Nov 30, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a feature to evaluate lambdas for fog_file properties
parent
446a4cdb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
4 deletions
+34
-4
lib/paperclip/storage/fog.rb
+10
-1
test/storage/fog_test.rb
+24
-3
No files found.
lib/paperclip/storage/fog.rb
View file @
92e88fc3
...
@@ -66,7 +66,16 @@ module Paperclip
...
@@ -66,7 +66,16 @@ module Paperclip
end
end
def
fog_file
def
fog_file
@fog_file
||=
@options
[
:fog_file
]
||
{}
@fog_file
||=
begin
value
=
@options
[
:fog_file
]
if
!
value
{}
elsif
value
.
respond_to?
(
:call
)
value
.
call
(
self
)
else
value
end
end
end
end
def
fog_public
(
style
=
default_style
)
def
fog_public
(
style
=
default_style
)
...
...
test/storage/fog_test.rb
View file @
92e88fc3
...
@@ -66,7 +66,7 @@ class FogTest < Test::Unit::TestCase
...
@@ -66,7 +66,7 @@ class FogTest < Test::Unit::TestCase
@dummy
.
avatar
.
path
@dummy
.
avatar
.
path
end
end
end
end
context
"with no path or url given and using defaults"
do
context
"with no path or url given and using defaults"
do
setup
do
setup
do
rebuild_model
:styles
=>
{
:medium
=>
"300x300>"
,
:thumb
=>
"100x100>"
},
rebuild_model
:styles
=>
{
:medium
=>
"300x300>"
,
:thumb
=>
"100x100>"
},
...
@@ -82,14 +82,35 @@ class FogTest < Test::Unit::TestCase
...
@@ -82,14 +82,35 @@ class FogTest < Test::Unit::TestCase
@dummy
.
id
=
1
@dummy
.
id
=
1
@dummy
.
avatar
=
@file
@dummy
.
avatar
=
@file
end
end
teardown
{
@file
.
close
}
teardown
{
@file
.
close
}
should
"have correct path and url from interpolated defaults"
do
should
"have correct path and url from interpolated defaults"
do
assert_equal
"dummies/avatars/000/000/001/original/5k.png"
,
@dummy
.
avatar
.
path
assert_equal
"dummies/avatars/000/000/001/original/5k.png"
,
@dummy
.
avatar
.
path
end
end
end
end
context
"with file params provided as lambda"
do
setup
do
fog_file
=
lambda
{
|
a
|
{
:custom_header
=>
a
.
instance
.
custom_method
}}
klass
=
rebuild_model
:storage
=>
:fog
,
:fog_file
=>
fog_file
klass
.
class_eval
do
def
custom_method
'foobar'
end
end
@dummy
=
Dummy
.
new
end
should
"be able to evaluate correct values for file headers"
do
assert_equal
@dummy
.
avatar
.
send
(
:fog_file
),
{
:custom_header
=>
'foobar'
}
end
end
setup
do
setup
do
@fog_directory
=
'papercliptests'
@fog_directory
=
'papercliptests'
...
...
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