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
9bcb5c81
Commit
9bcb5c81
authored
Mar 01, 2013
by
Mike Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the check for path collision out
parent
24dc7b25
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
2 deletions
+24
-2
lib/paperclip.rb
+0
-1
lib/paperclip/has_attached_file.rb
+5
-0
test/has_attached_file_test.rb
+19
-1
No files found.
lib/paperclip.rb
View file @
9bcb5c81
...
...
@@ -177,7 +177,6 @@ module Paperclip
HasAttachedFile
.
define_on
(
self
,
name
,
options
)
options
=
Paperclip
::
AttachmentOptions
.
new
(
options
)
Paperclip
.
check_for_path_clash
(
name
,
options
[
:path
],
self
.
name
)
Paperclip
::
Tasks
::
Attachments
.
add
(
self
,
name
,
options
)
...
...
lib/paperclip/has_attached_file.rb
View file @
9bcb5c81
...
...
@@ -15,6 +15,7 @@ module Paperclip
define_getter
define_setter
define_query
check_for_path_clash
end
private
...
...
@@ -62,5 +63,9 @@ module Paperclip
send
(
name
).
file?
end
end
def
check_for_path_clash
Paperclip
.
check_for_path_clash
(
@name
,
@options
[
:path
],
@klass
.
name
)
end
end
end
test/has_attached_file_test.rb
View file @
9bcb5c81
...
...
@@ -18,6 +18,10 @@ class HasAttachedFileTest < Test::Unit::TestCase
should
'flush errors as part of validations'
do
assert_adding_attachment
(
'avatar'
).
defines_validation
end
should
'check for a path collision'
do
assert_adding_attachment
(
'avatar'
).
checks_for_path_collision
end
end
private
...
...
@@ -54,10 +58,24 @@ class HasAttachedFileTest < Test::Unit::TestCase
end
end
def
checks_for_path_collision
a_class
=
stub_class
Paperclip
.
stubs
(
:check_for_path_clash
)
Paperclip
::
HasAttachedFile
.
define_on
(
a_class
,
@attachment_name
,
{})
assert_received
(
Paperclip
,
:check_for_path_clash
)
do
|
expect
|
expect
.
with
(
@attachment_name
,
nil
,
a_class
.
name
)
end
end
private
def
stub_class
stub
(
'class'
,
validates_each:
nil
,
define_method:
nil
)
stub
(
'class'
,
validates_each:
nil
,
define_method:
nil
,
name:
'Billy'
)
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