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
b89044fe
Commit
b89044fe
authored
Feb 06, 2012
by
beachbc
Committed by
Prem Sichanugrist
Mar 02, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for passing S3 credentials as a proc.
Fixes #738
parent
72ed6a8e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletions
+17
-1
lib/paperclip/storage/s3.rb
+2
-1
test/storage/s3_test.rb
+15
-0
No files found.
lib/paperclip/storage/s3.rb
View file @
b89044fe
...
...
@@ -234,6 +234,7 @@ module Paperclip
end
def
parse_credentials
creds
creds
=
creds
.
respond_to?
(
'call'
)
?
creds
.
call
(
self
)
:
creds
creds
=
find_credentials
(
creds
).
stringify_keys
env
=
Object
.
const_defined?
(
:Rails
)
?
Rails
.
env
:
nil
(
creds
[
env
]
||
creds
).
symbolize_keys
...
...
@@ -333,7 +334,7 @@ module Paperclip
when
Hash
creds
else
raise
ArgumentError
,
"Credentials are not a path, file, or hash."
raise
ArgumentError
,
"Credentials are not a path, file,
proc,
or hash."
end
end
private
:find_credentials
...
...
test/storage/s3_test.rb
View file @
b89044fe
...
...
@@ -618,6 +618,21 @@ class S3Test < Test::Unit::TestCase
end
end
context
"An attachment with S3 storage and S3 credentials defined as a Proc"
do
setup
do
rebuild_model
:storage
=>
:s3
,
:bucket
=>
{
:not
=>
:important
},
:s3_credentials
=>
lambda
{
|
attachment
|
Hash
[
'access_key_id'
=>
"access
#{
attachment
.
instance
.
other
}
"
,
'secret_access_key'
=>
"secret
#{
attachment
.
instance
.
other
}
"
]
}
end
should
"get the right credentials"
do
assert
"access1234"
,
Dummy
.
new
(
:other
=>
'1234'
).
avatar
.
s3_credentials
[
:access_key_id
]
assert
"secret1234"
,
Dummy
.
new
(
:other
=>
'1234'
).
avatar
.
s3_credentials
[
:secret_access_key
]
end
end
context
"An attachment with S3 storage and specific s3 headers set"
do
setup
do
rebuild_model
:storage
=>
:s3
,
...
...
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