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
9e73929c
Commit
9e73929c
authored
Feb 07, 2009
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the content_type macro itself
parent
28242594
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
29 deletions
+3
-29
shoulda_macros/paperclip.rb
+3
-29
No files found.
shoulda_macros/paperclip.rb
View file @
9e73929c
...
...
@@ -37,35 +37,9 @@ module Paperclip
klass
=
self
.
name
.
gsub
(
/Test$/
,
''
).
constantize
valid
=
[
options
[
:valid
]].
flatten
invalid
=
[
options
[
:invalid
]].
flatten
context
"Class
#{
klass
.
name
}
validating content_types on
#{
name
}
"
do
valid
.
each
do
|
type
|
context
"being assigned a file with a content_type of
#{
type
}
"
do
setup
do
@file
=
StringIO
.
new
(
"."
)
class
<<
@file
;
attr_accessor
:content_type
;
end
@file
.
content_type
=
type
@attachment
=
klass
.
new
.
send
(
name
)
@attachment
.
assign
(
@file
)
end
should
"not have a :content_type validation error"
do
assert
!
@attachment
.
errors
[
:content_type
]
end
end
end
invalid
.
each
do
|
type
|
context
"being assigned a file with a content_type of
#{
type
}
"
do
setup
do
@file
=
StringIO
.
new
(
"."
)
class
<<
@file
;
attr_accessor
:content_type
;
end
@file
.
content_type
=
type
@attachment
=
klass
.
new
.
send
(
name
)
@attachment
.
assign
(
@file
)
end
should
"have a :content_type validation error"
do
assert
@attachment
.
errors
[
:content_type
]
end
end
end
matcher
=
validate_attachment_presence
(
name
).
allows
(
valid
).
rejects
(
invalid
)
should
matcher
.
description
do
assert_accepts
(
matcher
,
klass
)
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