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
cb7ad7bd
Commit
cb7ad7bd
authored
Aug 02, 2012
by
Val
Committed by
Jon Yurek
Aug 17, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added per-style public setting with tests
parent
ee0fe89a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
5 deletions
+43
-5
lib/paperclip/storage/fog.rb
+13
-5
test/storage/fog_test.rb
+30
-0
No files found.
lib/paperclip/storage/fog.rb
View file @
cb7ad7bd
...
@@ -69,9 +69,16 @@ module Paperclip
...
@@ -69,9 +69,16 @@ module Paperclip
@fog_file
||=
@options
[
:fog_file
]
||
{}
@fog_file
||=
@options
[
:fog_file
]
||
{}
end
end
def
fog_public
def
fog_public
(
style
=
default_style
)
return
@fog_public
if
defined?
(
@fog_public
)
if
defined?
(
@options
[
:fog_public
])
@fog_public
=
defined?
(
@options
[
:fog_public
])
?
@options
[:
fog_public
]
:
true
if
defined?
(
@options
[
:fog_public
][
style
])
return
@options
[
:fog_public
][
style
]
else
return
@options
[
:fog_public
]
end
else
return
true
end
end
end
def
flush_writes
def
flush_writes
...
@@ -82,7 +89,7 @@ module Paperclip
...
@@ -82,7 +89,7 @@ module Paperclip
directory
.
files
.
create
(
fog_file
.
merge
(
directory
.
files
.
create
(
fog_file
.
merge
(
:body
=>
file
,
:body
=>
file
,
:key
=>
path
(
style
),
:key
=>
path
(
style
),
:public
=>
fog_public
,
:public
=>
fog_public
(
style
)
,
:content_type
=>
file
.
content_type
:content_type
=>
file
.
content_type
))
))
rescue
Excon
::
Errors
::
NotFound
rescue
Excon
::
Errors
::
NotFound
...
@@ -197,4 +204,4 @@ module Paperclip
...
@@ -197,4 +204,4 @@ module Paperclip
end
end
end
end
end
end
end
end
\ No newline at end of file
test/storage/fog_test.rb
View file @
cb7ad7bd
...
@@ -232,6 +232,36 @@ class FogTest < Test::Unit::TestCase
...
@@ -232,6 +232,36 @@ class FogTest < Test::Unit::TestCase
end
end
end
end
context
"with styles set and fog_public set to false"
do
setup
do
rebuild_model
(
@options
.
merge
(
:fog_public
=>
false
,
:styles
=>
{
:medium
=>
"300x300>"
,
:thumb
=>
"100x100>"
}))
@file
=
File
.
new
(
fixture_file
(
'5k.png'
),
'rb'
)
@dummy
=
Dummy
.
new
@dummy
.
avatar
=
@file
@dummy
.
save
end
should
'set the @fog_public for a perticular style to false'
do
assert_equal
false
,
@dummy
.
avatar
.
instance_variable_get
(
'@options'
)[
:fog_public
]
assert_equal
false
,
@dummy
.
avatar
.
fog_public
(
:thumb
)
end
end
context
"with styles set and fog_public set per-style"
do
setup
do
rebuild_model
(
@options
.
merge
(
:fog_public
=>
{
:medium
=>
false
,
:thumb
=>
true
},
:styles
=>
{
:medium
=>
"300x300>"
,
:thumb
=>
"100x100>"
}))
@file
=
File
.
new
(
fixture_file
(
'5k.png'
),
'rb'
)
@dummy
=
Dummy
.
new
@dummy
.
avatar
=
@file
@dummy
.
save
end
should
'set the fog_public for a perticular style to correct value'
do
assert_equal
false
,
@dummy
.
avatar
.
fog_public
(
:medium
)
assert_equal
true
,
@dummy
.
avatar
.
fog_public
(
:thumb
)
end
end
context
"with a valid bucket name for a subdomain"
do
context
"with a valid bucket name for a subdomain"
do
should
"provide an url in subdomain style"
do
should
"provide an url in subdomain style"
do
assert_match
@dummy
.
avatar
.
url
,
/^https:\/\/papercliptests.s3.amazonaws.com\/avatars\/5k.png/
assert_match
@dummy
.
avatar
.
url
,
/^https:\/\/papercliptests.s3.amazonaws.com\/avatars\/5k.png/
...
...
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