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
675dd9a3
Commit
675dd9a3
authored
Feb 03, 2012
by
Luke Griffiths
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AttachmentOptions now inherits from Hash
parent
5f8140d1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
14 deletions
+16
-14
lib/paperclip/attachment_options.rb
+5
-14
test/attachment_options_test.rb
+11
-0
No files found.
lib/paperclip/attachment_options.rb
View file @
675dd9a3
module
Paperclip
module
Paperclip
class
AttachmentOptions
class
AttachmentOptions
<
Hash
def
initialize
(
options
)
def
initialize
(
options
)
@options
=
{
:validations
=>
[]}.
merge
(
options
)
options
=
{
:validations
=>
[]}.
merge
(
options
)
end
options
.
each
do
|
k
,
v
|
self
.
[
]
=
(
k
,
v
)
def
[]
(
key
)
end
@options
[
key
]
end
def
[]=
(
key
,
value
)
@options
[
key
]
=
value
end
def
to_hash
@options
end
end
end
end
end
end
test/attachment_options_test.rb
View file @
675dd9a3
...
@@ -5,6 +5,11 @@ class AttachmentOptionsTest < Test::Unit::TestCase
...
@@ -5,6 +5,11 @@ class AttachmentOptionsTest < Test::Unit::TestCase
Paperclip
::
AttachmentOptions
Paperclip
::
AttachmentOptions
end
end
should
"be a Hash"
do
attachment_options
=
Paperclip
::
AttachmentOptions
.
new
({})
assert
attachment_options
.
is_a?
(
Hash
),
"attachment_options is not a Hash"
end
should
"add a default empty validations"
do
should
"add a default empty validations"
do
options
=
{
:arbi
=>
:trary
}
options
=
{
:arbi
=>
:trary
}
expected
=
{
:validations
=>
[]}.
merge
(
options
)
expected
=
{
:validations
=>
[]}.
merge
(
options
)
...
@@ -12,6 +17,12 @@ class AttachmentOptionsTest < Test::Unit::TestCase
...
@@ -12,6 +17,12 @@ class AttachmentOptionsTest < Test::Unit::TestCase
assert_equal
expected
,
actual
assert_equal
expected
,
actual
end
end
should
"not override validations if passed to initializer"
do
options
=
{
:validations
=>
"something"
}
attachment_options
=
Paperclip
::
AttachmentOptions
.
new
(
options
)
assert_equal
"something"
,
attachment_options
[
:validations
]
end
should
"respond to []"
do
should
"respond to []"
do
Paperclip
::
AttachmentOptions
.
new
({})[
:foo
]
Paperclip
::
AttachmentOptions
.
new
({})[
:foo
]
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