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
87426153
Commit
87426153
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_credentials
parent
2b562a9b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletions
+22
-1
lib/paperclip/storage/fog.rb
+3
-1
test/storage/fog_test.rb
+19
-0
No files found.
lib/paperclip/storage/fog.rb
View file @
87426153
...
@@ -163,8 +163,10 @@ module Paperclip
...
@@ -163,8 +163,10 @@ module Paperclip
YAML
::
load
(
ERB
.
new
(
File
.
read
(
creds
)).
result
)
YAML
::
load
(
ERB
.
new
(
File
.
read
(
creds
)).
result
)
when
Hash
when
Hash
creds
creds
when
Proc
creds
.
call
(
self
)
else
else
raise
ArgumentError
,
"Credentials are not a path, file,
or hash
."
raise
ArgumentError
,
"Credentials are not a path, file,
hash or proc
."
end
end
end
end
...
...
test/storage/fog_test.rb
View file @
87426153
...
@@ -249,6 +249,25 @@ class FogTest < Test::Unit::TestCase
...
@@ -249,6 +249,25 @@ class FogTest < Test::Unit::TestCase
assert_match
/http:\/\/dynamicfoghost\.com/
,
@dummy
.
avatar
.
url
assert_match
/http:\/\/dynamicfoghost\.com/
,
@dummy
.
avatar
.
url
end
end
end
end
context
"with a proc for the fog_credentials evaluating a model method"
do
setup
do
@dynamic_fog_credentials
=
{
:provider
=>
'AWS'
,
:aws_access_key_id
=>
'DYNAMIC_ID'
,
:aws_secret_access_key
=>
'DYNAMIC_SECRET'
}
rebuild_model
(
@options
.
merge
(
:fog_credentials
=>
lambda
{
|
attachment
|
attachment
.
instance
.
fog_credentials
}))
@dummy
=
Dummy
.
new
@dummy
.
stubs
(
:fog_credentials
).
returns
(
@dynamic_fog_credentials
)
@dummy
.
avatar
=
@file
@dummy
.
save
end
should
"provide a public url"
do
assert_equal
@dummy
.
avatar
.
fog_credentials
,
@dynamic_fog_credentials
end
end
end
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