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
75a5dbcc
Commit
75a5dbcc
authored
Nov 04, 2011
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#expiring_url doesn't cause an error if the attachment is unset
parent
b2d04080
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
lib/paperclip/storage/s3.rb
+1
-1
test/storage/s3_live_test.rb
+19
-3
No files found.
lib/paperclip/storage/s3.rb
View file @
75a5dbcc
...
...
@@ -113,7 +113,7 @@ module Paperclip
end
def
expiring_url
(
time
=
3600
,
style_name
=
default_style
)
s3_object
.
url_for
(
path
(
style_name
),
bucket_name
,
:expires_in
=>
time
,
:use_ssl
=>
(
s3_protocol
(
style_name
)
==
'https'
))
path
.
nil?
?
nil
:
s3_object
.
url_for
(
path
(
style_name
),
bucket_name
,
:expires_in
=>
time
,
:use_ssl
=>
(
s3_protocol
(
style_name
)
==
'https'
))
end
def
s3_credentials
...
...
test/storage/s3_live_test.rb
View file @
75a5dbcc
...
...
@@ -3,6 +3,22 @@ require 'aws/s3'
unless
ENV
[
"S3_TEST_BUCKET"
].
blank?
class
S3LiveTest
<
Test
::
Unit
::
TestCase
context
"Generating an expiring url on a nonexistant attachment"
do
setup
do
rebuild_model
:styles
=>
{
:thumb
=>
"100x100"
,
:square
=>
"32x32#"
},
:storage
=>
:s3
,
:bucket
=>
ENV
[
"S3_TEST_BUCKET"
],
:path
=>
":class/:attachment/:id/:style.:extension"
,
:s3_credentials
=>
File
.
new
(
File
.
join
(
File
.
dirname
(
__FILE__
),
".."
,
"fixtures"
,
"s3.yml"
))
@dummy
=
Dummy
.
new
end
should
"return nil"
do
assert_nil
@dummy
.
avatar
.
expiring_url
end
end
context
"Using S3 for real, an attachment with S3 storage"
do
setup
do
rebuild_model
:styles
=>
{
:thumb
=>
"100x100"
,
:square
=>
"32x32#"
},
...
...
@@ -54,9 +70,9 @@ unless ENV["S3_TEST_BUCKET"].blank?
context
"An attachment that uses S3 for storage and has spaces in file name"
do
setup
do
rebuild_model
:styles
=>
{
:thumb
=>
"100x100"
,
:square
=>
"32x32#"
},
:storage
=>
:s3
,
:bucket
=>
ENV
[
"S3_TEST_BUCKET"
],
:s3_credentials
=>
File
.
new
(
File
.
join
(
File
.
dirname
(
__FILE__
),
".."
,
"fixtures
"
,
"s3.yml"
))
:storage
=>
:s3
,
:bucket
=>
ENV
[
"S3_TEST_BUCKET"
],
:s3_credentials
=>
File
.
new
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"..
"
,
"s3.yml"
))
Dummy
.
delete_all
@dummy
=
Dummy
.
new
...
...
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