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
32548249
Commit
32548249
authored
Mar 01, 2013
by
George Brocklehurst
Committed by
Mike Burns
Jun 14, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Tasks registration to HasAttachedFile.
parent
232cacb7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
lib/paperclip.rb
+0
-2
lib/paperclip/has_attached_file.rb
+5
-0
test/has_attached_file_test.rb
+15
-0
No files found.
lib/paperclip.rb
View file @
32548249
...
...
@@ -175,8 +175,6 @@ module Paperclip
def
has_attached_file
(
name
,
options
=
{})
HasAttachedFile
.
define_on
(
self
,
name
,
options
)
Paperclip
::
Tasks
::
Attachments
.
add
(
self
,
name
,
options
)
after_save
{
send
(
name
).
send
(
:save
)
}
before_destroy
{
send
(
name
).
send
(
:queue_all_for_delete
)
}
after_destroy
{
send
(
name
).
send
(
:flush_deletes
)
}
...
...
lib/paperclip/has_attached_file.rb
View file @
32548249
...
...
@@ -16,6 +16,7 @@ module Paperclip
define_setter
define_query
check_for_path_clash
register_with_rake_tasks
end
private
...
...
@@ -67,5 +68,9 @@ module Paperclip
def
check_for_path_clash
Paperclip
.
check_for_path_clash
(
@name
,
@options
[
:path
],
@klass
.
name
)
end
def
register_with_rake_tasks
Paperclip
::
Tasks
::
Attachments
.
add
(
@klass
,
@name
,
@options
)
end
end
end
test/has_attached_file_test.rb
View file @
32548249
...
...
@@ -22,6 +22,10 @@ class HasAttachedFileTest < Test::Unit::TestCase
should
'check for a path collision'
do
assert_adding_attachment
(
'avatar'
).
checks_for_path_collision
end
should
'register the attachment with Paperclip::Tasks'
do
assert_adding_attachment
(
'avatar'
).
registers_with_tasks
end
end
private
...
...
@@ -69,6 +73,17 @@ class HasAttachedFileTest < Test::Unit::TestCase
end
end
def
registers_with_tasks
a_class
=
stub_class
Paperclip
::
Tasks
::
Attachments
.
stubs
(
:add
)
Paperclip
::
HasAttachedFile
.
define_on
(
a_class
,
@attachment_name
,
{
size:
1
})
assert_received
(
Paperclip
::
Tasks
::
Attachments
,
:add
)
do
|
expect
|
expect
.
with
(
a_class
,
@attachment_name
,
{
size:
1
})
end
end
private
def
stub_class
...
...
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