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
93073d5f
Commit
93073d5f
authored
May 10, 2009
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed ENV['RAILS_ENV'] to plain RAILS_ENV
parent
f47a4b5a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
10 deletions
+13
-10
lib/paperclip/storage.rb
+1
-1
test/helper.rb
+0
-2
test/storage_test.rb
+12
-7
No files found.
lib/paperclip/storage.rb
View file @
93073d5f
...
@@ -173,7 +173,7 @@ module Paperclip
...
@@ -173,7 +173,7 @@ module Paperclip
def
parse_credentials
creds
def
parse_credentials
creds
creds
=
find_credentials
(
creds
).
stringify_keys
creds
=
find_credentials
(
creds
).
stringify_keys
(
creds
[
ENV
[
'RAILS_ENV'
]
]
||
creds
).
symbolize_keys
(
creds
[
RAILS_ENV
]
||
creds
).
symbolize_keys
end
end
def
exists?
(
style
=
default_style
)
def
exists?
(
style
=
default_style
)
...
...
test/helper.rb
View file @
93073d5f
...
@@ -26,8 +26,6 @@ require File.join(ROOT, 'lib', 'paperclip.rb')
...
@@ -26,8 +26,6 @@ require File.join(ROOT, 'lib', 'paperclip.rb')
require
'shoulda_macros/paperclip'
require
'shoulda_macros/paperclip'
ENV
[
'RAILS_ENV'
]
||=
'test'
FIXTURES_DIR
=
File
.
join
(
File
.
dirname
(
__FILE__
),
"fixtures"
)
FIXTURES_DIR
=
File
.
join
(
File
.
dirname
(
__FILE__
),
"fixtures"
)
config
=
YAML
::
load
(
IO
.
read
(
File
.
dirname
(
__FILE__
)
+
'/database.yml'
))
config
=
YAML
::
load
(
IO
.
read
(
File
.
dirname
(
__FILE__
)
+
'/database.yml'
))
ActiveRecord
::
Base
.
logger
=
Logger
.
new
(
File
.
dirname
(
__FILE__
)
+
"/debug.log"
)
ActiveRecord
::
Base
.
logger
=
Logger
.
new
(
File
.
dirname
(
__FILE__
)
+
"/debug.log"
)
...
...
test/storage_test.rb
View file @
93073d5f
...
@@ -10,29 +10,29 @@ class StorageTest < Test::Unit::TestCase
...
@@ -10,29 +10,29 @@ class StorageTest < Test::Unit::TestCase
@dummy
=
Dummy
.
new
@dummy
=
Dummy
.
new
@avatar
=
@dummy
.
avatar
@avatar
=
@dummy
.
avatar
@current_env
=
ENV
[
'RAILS_ENV'
]
@current_env
=
RAILS_ENV
end
end
teardown
do
teardown
do
ENV
[
'RAILS_ENV'
]
=
@current_env
Object
.
const_set
(
"RAILS_ENV"
,
@current_env
)
end
end
should
"get the correct credentials when RAILS_ENV is production"
do
should
"get the correct credentials when RAILS_ENV is production"
do
ENV
[
'RAILS_ENV'
]
=
'production'
Object
.
const_set
(
'RAILS_ENV'
,
"production"
)
assert_equal
({
:key
=>
"12345"
},
assert_equal
({
:key
=>
"12345"
},
@avatar
.
parse_credentials
(
'production'
=>
{
:key
=>
'12345'
},
@avatar
.
parse_credentials
(
'production'
=>
{
:key
=>
'12345'
},
:development
=>
{
:key
=>
"54321"
}))
:development
=>
{
:key
=>
"54321"
}))
end
end
should
"get the correct credentials when RAILS_ENV is development"
do
should
"get the correct credentials when RAILS_ENV is development"
do
ENV
[
'RAILS_ENV'
]
=
'development'
Object
.
const_set
(
'RAILS_ENV'
,
"development"
)
assert_equal
({
:key
=>
"54321"
},
assert_equal
({
:key
=>
"54321"
},
@avatar
.
parse_credentials
(
'production'
=>
{
:key
=>
'12345'
},
@avatar
.
parse_credentials
(
'production'
=>
{
:key
=>
'12345'
},
:development
=>
{
:key
=>
"54321"
}))
:development
=>
{
:key
=>
"54321"
}))
end
end
should
"return the argument if the key does not exist"
do
should
"return the argument if the key does not exist"
do
ENV
[
'RAILS_ENV'
]
=
"not really an env"
Object
.
const_set
(
'RAILS_ENV'
,
"not really an env"
)
assert_equal
({
:test
=>
"12345"
},
@avatar
.
parse_credentials
(
:test
=>
"12345"
))
assert_equal
({
:test
=>
"12345"
},
@avatar
.
parse_credentials
(
:test
=>
"12345"
))
end
end
end
end
...
@@ -94,13 +94,18 @@ class StorageTest < Test::Unit::TestCase
...
@@ -94,13 +94,18 @@ class StorageTest < Test::Unit::TestCase
:development
=>
{
:bucket
=>
"dev_bucket"
}
:development
=>
{
:bucket
=>
"dev_bucket"
}
}
}
@dummy
=
Dummy
.
new
@dummy
=
Dummy
.
new
@old_env
=
RAILS_ENV
end
end
should
"get the right bucket in production"
,
:before
=>
lambda
{
ENV
.
expects
(
:[]
).
returns
(
'production'
)
}
do
teardown
{
Object
.
const_set
(
"RAILS_ENV"
,
@old_env
)
}
should
"get the right bucket in production"
do
Object
.
const_set
(
"RAILS_ENV"
,
"production"
)
assert_equal
"prod_bucket"
,
@dummy
.
avatar
.
bucket_name
assert_equal
"prod_bucket"
,
@dummy
.
avatar
.
bucket_name
end
end
should
"get the right bucket in development"
,
:before
=>
lambda
{
ENV
.
expects
(
:[]
).
returns
(
'development'
)
}
do
should
"get the right bucket in development"
do
Object
.
const_set
(
"RAILS_ENV"
,
"development"
)
assert_equal
"dev_bucket"
,
@dummy
.
avatar
.
bucket_name
assert_equal
"dev_bucket"
,
@dummy
.
avatar
.
bucket_name
end
end
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