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
2a9e71a2
Commit
2a9e71a2
authored
May 12, 2015
by
Stefano B
Committed by
Jon Yurek
Aug 27, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow sublcasses to override definitions
parent
9e97a530
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
1 deletions
+30
-1
lib/paperclip/attachment_registry.rb
+1
-1
spec/paperclip/attachment_registry_spec.rb
+28
-0
spec/spec_helper.rb
+1
-0
No files found.
lib/paperclip/attachment_registry.rb
View file @
2a9e71a2
...
...
@@ -51,7 +51,7 @@ module Paperclip
end
def
definitions_for
(
klass
)
klass
.
ancestors
.
each_with_object
({})
do
|
ancestor
,
inherited_definitions
|
klass
.
ancestors
.
reverse
.
each_with_object
({})
do
|
ancestor
,
inherited_definitions
|
inherited_definitions
.
deep_merge!
@attachments
[
ancestor
]
end
end
...
...
spec/paperclip/attachment_registry_spec.rb
View file @
2a9e71a2
...
...
@@ -111,6 +111,34 @@ describe 'Attachment Registry' do
assert_equal
expected_definitions
,
definitions
end
it
'allows subclasses to override attachment defitions'
do
foo_definitions
=
{
avatar:
{
yo:
"greeting"
}
}
bar_definitions
=
{
avatar:
{
yo:
"hello"
}
}
expected_definitions
=
{
avatar:
{
yo:
"hello"
}
}
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
(
bar
)
assert_equal
expected_definitions
,
definitions
end
end
context
'.clear'
do
...
...
spec/spec_helper.rb
View file @
2a9e71a2
...
...
@@ -7,6 +7,7 @@ require 'active_support/core_ext'
require
'mocha/api'
require
'bourne'
require
'ostruct'
require
'pathname'
ROOT
=
Pathname
(
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
'..'
)))
...
...
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