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
2b562a9b
Commit
2b562a9b
authored
Jan 19, 2012
by
Benjamin Hüttinger
Committed by
Benjamin Hüttinger
Jan 20, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow proc for fog_host
parent
e049ec53
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
+22
-3
lib/paperclip/storage/fog.rb
+6
-1
test/storage/fog_test.rb
+16
-2
No files found.
lib/paperclip/storage/fog.rb
View file @
2b562a9b
...
...
@@ -126,7 +126,12 @@ module Paperclip
def
public_url
(
style
=
default_style
)
if
@options
[
:fog_host
]
host
=
(
@options
[
:fog_host
]
=~
/%d/
)
?
@options
[:
fog_host
]
%
(
path
(
style
).
hash
%
4
)
:
@options
[
:fog_host
]
host
=
if
@options
[
:fog_host
].
is_a?
(
Proc
)
@options
[
:fog_host
].
call
(
self
)
else
(
@options
[
:fog_host
]
=~
/%d/
)
?
@options
[:
fog_host
]
%
(
path
(
style
).
hash
%
4
)
:
@options
[
:fog_host
]
end
"
#{
host
}
/
#{
path
(
style
)
}
"
else
if
fog_credentials
[
:provider
]
==
'AWS'
...
...
test/storage/fog_test.rb
View file @
2b562a9b
...
...
@@ -229,11 +229,25 @@ class FogTest < Test::Unit::TestCase
@dummy
.
avatar
=
@file
@dummy
.
save
end
should
"have created the bucket"
do
assert
@connection
.
directories
.
get
(
@dynamic_fog_directory
).
inspect
end
end
context
"with a proc for the fog_host evaluating a model method"
do
setup
do
rebuild_model
(
@options
.
merge
(
:fog_host
=>
lambda
{
|
attachment
|
attachment
.
instance
.
fog_host
}))
@dummy
=
Dummy
.
new
@dummy
.
stubs
(
:fog_host
).
returns
(
'http://dynamicfoghost.com'
)
@dummy
.
avatar
=
@file
@dummy
.
save
end
should
"provide a public url"
do
assert_match
/http:\/\/dynamicfoghost\.com/
,
@dummy
.
avatar
.
url
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