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
d591a648
Commit
d591a648
authored
Aug 26, 2011
by
Mike Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the formatting.
parent
5ec9a737
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
lib/paperclip/storage/fog.rb
+5
-5
test/fog_test.rb
+6
-7
No files found.
lib/paperclip/storage/fog.rb
View file @
d591a648
...
...
@@ -119,16 +119,16 @@ module Paperclip
directory
.
files
.
new
(
:key
=>
path
(
style
)).
public_url
end
end
def
parse_credentials
creds
def
parse_credentials
(
creds
)
creds
=
find_credentials
(
creds
).
stringify_keys
env
=
Object
.
const_defined?
(
:Rails
)
?
Rails
.
env
:
nil
(
creds
[
env
]
||
creds
).
symbolize_keys
end
private
def
find_credentials
creds
def
find_credentials
(
creds
)
case
creds
when
File
YAML
::
load
(
ERB
.
new
(
File
.
read
(
creds
.
path
)).
result
)
...
...
@@ -140,7 +140,7 @@ module Paperclip
raise
ArgumentError
,
"Credentials are not a path, file, or hash."
end
end
def
connection
@connection
||=
::
Fog
::
Storage
.
new
(
@fog_credentials
)
end
...
...
test/fog_test.rb
View file @
d591a648
...
...
@@ -5,7 +5,7 @@ Fog.mock!
class
FogTest
<
Test
::
Unit
::
TestCase
context
""
do
context
"with credentials provided in a path string"
do
setup
do
rebuild_model
:styles
=>
{
:medium
=>
"300x300>"
,
:thumb
=>
"100x100>"
},
...
...
@@ -21,7 +21,7 @@ class FogTest < Test::Unit::TestCase
assert_equal
@dummy
.
avatar
.
instance_variable_get
(
"@fog_credentials"
)[
:provider
],
'AWS'
end
end
context
"with credentials provided in a File object"
do
setup
do
rebuild_model
:styles
=>
{
:medium
=>
"300x300>"
,
:thumb
=>
"100x100>"
},
...
...
@@ -37,8 +37,7 @@ class FogTest < Test::Unit::TestCase
assert_equal
@dummy
.
avatar
.
instance_variable_get
(
"@fog_credentials"
)[
:provider
],
'AWS'
end
end
context
"with default values for path and url"
do
setup
do
rebuild_model
:styles
=>
{
:medium
=>
"300x300>"
,
:thumb
=>
"100x100>"
},
...
...
@@ -59,7 +58,7 @@ class FogTest < Test::Unit::TestCase
@dummy
.
avatar
.
path
end
end
setup
do
@fog_directory
=
'papercliptests'
...
...
@@ -165,7 +164,7 @@ class FogTest < Test::Unit::TestCase
assert
@dummy
.
avatar
.
url
=~
/^http:\/\/img[0123]\.example\.com\/avatars\/stringio\.txt\?\d*$/
end
end
context
"with fog_public set to false"
do
setup
do
rebuild_model
(
@options
.
merge
(
:fog_public
=>
false
))
...
...
@@ -173,7 +172,7 @@ class FogTest < Test::Unit::TestCase
@dummy
.
avatar
=
StringIO
.
new
(
'.'
)
@dummy
.
save
end
should
'set the @fog_public instance variable to false'
do
assert_equal
false
,
@dummy
.
avatar
.
instance_variable_get
(
'@fog_public'
)
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