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
1d621d81
Commit
1d621d81
authored
Jan 30, 2015
by
Agustin Cavilliotti
Committed by
Jon Yurek
Feb 06, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the ability to deep_merge! Attachment definitions instead of just merging them
parent
a6972db7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
lib/paperclip/attachment_registry.rb
+1
-1
spec/paperclip/attachment_registry_spec.rb
+23
-4
No files found.
lib/paperclip/attachment_registry.rb
View file @
1d621d81
...
...
@@ -52,7 +52,7 @@ module Paperclip
def
definitions_for
(
klass
)
klass
.
ancestors
.
each_with_object
({})
do
|
ancestor
,
inherited_definitions
|
inherited_definitions
.
merge!
@attachments
[
ancestor
]
inherited_definitions
.
deep_
merge!
@attachments
[
ancestor
]
end
end
end
...
...
spec/paperclip/attachment_registry_spec.rb
View file @
1d621d81
...
...
@@ -64,11 +64,30 @@ describe 'Attachment Registry' do
it
"produces defintions for subclasses"
do
expected_definitions
=
{
avatar:
{
yo:
'greeting'
}
}
Foo
=
Class
.
new
Bar
=
Class
.
new
(
Foo
)
Paperclip
::
AttachmentRegistry
.
register
(
Foo
,
:avatar
,
expected_definitions
[
:avatar
])
foo
=
Class
.
new
bar
=
Class
.
new
(
foo
)
Paperclip
::
AttachmentRegistry
.
register
(
foo
,
:avatar
,
expected_definitions
[
:avatar
])
definitions
=
Paperclip
::
AttachmentRegistry
.
definitions_for
(
bar
)
assert_equal
expected_definitions
,
definitions
end
it
"produces defintions for subclasses but deep merging them"
do
foo_definitions
=
{
avatar:
{
yo:
'greeting'
}
}
bar_definitions
=
{
avatar:
{
ciao:
'greeting'
}
}
expected_definitions
=
{
avatar:
{
yo:
'greeting'
,
ciao:
'greeting'
}
}
foo
=
Class
.
new
bar
=
Class
.
new
(
foo
)
Paperclip
::
AttachmentRegistry
.
register
(
foo
,
:avatar
,
foo_definitions
[
:avatar
])
Paperclip
::
AttachmentRegistry
.
register
(
bar
,
:avatar
,
bar_definitions
[
:avatar
])
definitions
=
Paperclip
::
AttachmentRegistry
.
definitions_for
(
B
ar
)
definitions
=
Paperclip
::
AttachmentRegistry
.
definitions_for
(
b
ar
)
assert_equal
expected_definitions
,
definitions
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