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
ce2f389a
Commit
ce2f389a
authored
Sep 12, 2008
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ability for S3 bucket to be in the config file, environmentally scoped.
parent
457c0cd5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
4 deletions
+23
-4
lib/paperclip/storage.rb
+1
-1
test/attachment_test.rb
+2
-2
test/storage_test.rb
+19
-0
test/thumbnail_test.rb
+1
-1
No files found.
lib/paperclip/storage.rb
View file @
ce2f389a
...
...
@@ -105,8 +105,8 @@ module Paperclip
def
self
.
extended
base
require
'right_aws'
base
.
instance_eval
do
@bucket
=
@options
[
:bucket
]
@s3_credentials
=
parse_credentials
(
@options
[
:s3_credentials
])
@bucket
=
@options
[
:bucket
]
||
@s3_credentials
[
:bucket
]
@s3_options
=
@options
[
:s3_options
]
||
{}
@s3_permissions
=
@options
[
:s3_permissions
]
||
'public-read'
@s3_protocol
=
@options
[
:s3_protocol
]
||
(
@s3_permissions
==
'public-read'
?
'http'
:
'https'
)
...
...
test/attachment_test.rb
View file @
ce2f389a
...
...
@@ -156,7 +156,7 @@ class AttachmentTest < Test::Unit::TestCase
@not_file
.
expects
(
:to_tempfile
).
returns
(
self
)
@not_file
.
expects
(
:original_filename
).
returns
(
"filename.png
\r\n
"
)
@not_file
.
expects
(
:content_type
).
returns
(
"image/png
\r\n
"
)
@not_file
.
expects
(
:size
).
returns
(
10
)
@not_file
.
expects
(
:size
).
returns
(
10
)
.
times
(
2
)
@dummy
=
Dummy
.
new
@attachment
=
@dummy
.
avatar
...
...
@@ -186,7 +186,7 @@ class AttachmentTest < Test::Unit::TestCase
@not_file
.
expects
(
:to_tempfile
).
returns
(
self
)
@not_file
.
expects
(
:original_filename
).
returns
(
"sheep_say_bæ.png
\r\n
"
)
@not_file
.
expects
(
:content_type
).
returns
(
"image/png
\r\n
"
)
@not_file
.
expects
(
:size
).
returns
(
10
)
@not_file
.
expects
(
:size
).
returns
(
10
)
.
times
(
2
)
@dummy
=
Dummy
.
new
@attachment
=
@dummy
.
avatar
...
...
test/storage_test.rb
View file @
ce2f389a
...
...
@@ -42,6 +42,25 @@ class StorageTest < Test::Unit::TestCase
end
end
context
"Parsing S3 credentials with a bucket in them"
do
setup
do
rebuild_model
:storage
=>
:s3
,
:s3_credentials
=>
{
:production
=>
{
:bucket
=>
"prod_bucket"
},
:development
=>
{
:bucket
=>
"dev_bucket"
}
}
@dummy
=
Dummy
.
new
end
should
"get the right bucket in production"
,
:before
=>
lambda
{
ENV
.
expects
(
:[]
).
returns
(
'production'
)
}
do
assert_equal
"prod_bucket"
,
@dummy
.
avatar
.
bucket_name
end
should
"get the right bucket in development"
,
:before
=>
lambda
{
ENV
.
expects
(
:[]
).
returns
(
'development'
)
}
do
assert_equal
"dev_bucket"
,
@dummy
.
avatar
.
bucket_name
end
end
context
"An attachment with S3 storage"
do
setup
do
rebuild_model
:storage
=>
:s3
,
...
...
test/thumbnail_test.rb
View file @
ce2f389a
...
...
@@ -119,7 +119,7 @@ class ThumbnailTest < Test::Unit::TestCase
should
"send the right command to convert when sent #make"
do
@thumb
.
expects
(
:system
).
with
do
|
arg
|
arg
.
match
%r{convert
\s
+"
#{
File
.
expand_path
(
@thumb
.
file
.
path
)
}
"
\s
+-scale
\s
+
\"
x50
\"\s
+-crop
\s
+
\"
100x50
\+
114
\+
0
\
"\s
+
\+
repage
\s
+-strip
\s
+-depth
\s
+8
\s
+".*?"}
arg
.
match
%r{convert
\s
+"
#{
File
.
expand_path
(
@thumb
.
file
.
path
)
}
\[
0
\]
"
\s
+-resize
\s
+"x50"
\s
+-crop
\s
+"100x50
\+
114
\+
0
"
\s
+
\+
repage
\s
+-strip
\s
+-depth
\s
+8
\s
+".*?"}
end
@thumb
.
make
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