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
4f9ffb85
Commit
4f9ffb85
authored
Aug 09, 2009
by
Damian Janowski
Committed by
Jon Yurek
Aug 10, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the build more friendly.
(cherry picked from commit f58f73210621261c214136eb7514be459032ee0f)
parent
a6095d0c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
10 deletions
+32
-10
lib/paperclip/storage.rb
+7
-1
test/helper.rb
+10
-1
test/interpolations_test.rb
+1
-1
test/storage_test.rb
+14
-7
No files found.
lib/paperclip/storage.rb
View file @
4f9ffb85
...
...
@@ -127,7 +127,13 @@ module Paperclip
# separate parts of your file name.
module
S3
def
self
.
extended
base
require
'aws/s3'
begin
require
'aws/s3'
rescue
LoadError
=>
e
e
.
message
<<
" (You may need to install the aws-s3 gem)"
raise
e
end
base
.
instance_eval
do
@s3_credentials
=
parse_credentials
(
@options
[
:s3_credentials
])
@bucket
=
@options
[
:bucket
]
||
@s3_credentials
[
:bucket
]
...
...
test/helper.rb
View file @
4f9ffb85
require
'rubygems'
require
'test/unit'
require
'shoulda'
require
'mocha'
require
'tempfile'
gem
'jferris-mocha'
,
'0.9.5.0.1241126838'
require
'mocha'
gem
'sqlite3-ruby'
require
'active_record'
...
...
@@ -97,3 +99,10 @@ end
def
attachment
options
Paperclip
::
Attachment
.
new
(
:avatar
,
FakeModel
.
new
,
options
)
end
def
silence_warnings
old_verbose
,
$VERBOSE
=
$VERBOSE
,
nil
yield
ensure
$VERBOSE
=
old_verbose
end
test/interpolations_test.rb
View file @
4f9ffb85
...
...
@@ -7,7 +7,7 @@ class InterpolationsTest < Test::Unit::TestCase
assert
!
methods
.
include?
(
:[]=
)
assert
!
methods
.
include?
(
:all
)
methods
.
each
do
|
m
|
assert
Paperclip
::
Interpolations
.
respond_to?
m
assert
Paperclip
::
Interpolations
.
respond_to?
(
m
)
end
end
...
...
test/storage_test.rb
View file @
4f9ffb85
require
'test/helper'
require
'aws/s3'
class
StorageTest
<
Test
::
Unit
::
TestCase
def
rails_env
(
env
)
silence_warnings
do
Object
.
const_set
(
:RAILS_ENV
,
env
)
end
end
context
"Parsing S3 credentials"
do
setup
do
AWS
::
S3
::
Base
.
stubs
(
:establish_connection!
)
...
...
@@ -15,25 +22,25 @@ class StorageTest < Test::Unit::TestCase
end
teardown
do
Object
.
const_set
(
"RAILS_ENV"
,
@current_env
)
rails_env
(
@current_env
)
end
should
"get the correct credentials when RAILS_ENV is production"
do
Object
.
const_set
(
'RAILS_ENV'
,
"production"
)
rails_env
(
"production"
)
assert_equal
({
:key
=>
"12345"
},
@avatar
.
parse_credentials
(
'production'
=>
{
:key
=>
'12345'
},
:development
=>
{
:key
=>
"54321"
}))
end
should
"get the correct credentials when RAILS_ENV is development"
do
Object
.
const_set
(
'RAILS_ENV'
,
"development"
)
rails_env
(
"development"
)
assert_equal
({
:key
=>
"54321"
},
@avatar
.
parse_credentials
(
'production'
=>
{
:key
=>
'12345'
},
:development
=>
{
:key
=>
"54321"
}))
end
should
"return the argument if the key does not exist"
do
Object
.
const_set
(
'RAILS_ENV'
,
"not really an env"
)
rails_env
(
"not really an env"
)
assert_equal
({
:test
=>
"12345"
},
@avatar
.
parse_credentials
(
:test
=>
"12345"
))
end
end
...
...
@@ -102,15 +109,15 @@ class StorageTest < Test::Unit::TestCase
@old_env
=
RAILS_ENV
end
teardown
{
Object
.
const_set
(
"RAILS_ENV"
,
@old_env
)
}
teardown
{
rails_env
(
@old_env
)
}
should
"get the right bucket in production"
do
Object
.
const_set
(
"RAILS_ENV"
,
"production"
)
rails_env
(
"production"
)
assert_equal
"prod_bucket"
,
@dummy
.
avatar
.
bucket_name
end
should
"get the right bucket in development"
do
Object
.
const_set
(
"RAILS_ENV"
,
"development"
)
rails_env
(
"development"
)
assert_equal
"dev_bucket"
,
@dummy
.
avatar
.
bucket_name
end
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