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
84d2d087
Commit
84d2d087
authored
Mar 16, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused tests
parent
fe706c69
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
150 deletions
+0
-150
test/paperclip_test.rb
+0
-150
No files found.
test/paperclip_test.rb
View file @
84d2d087
...
@@ -191,161 +191,11 @@ class PaperclipTest < Test::Unit::TestCase
...
@@ -191,161 +191,11 @@ class PaperclipTest < Test::Unit::TestCase
end
end
end
end
context
"a validation with an if guard clause"
do
context
"as a lambda"
do
setup
do
Dummy
.
send
(
:"validates_attachment_presence"
,
:avatar
,
:if
=>
lambda
{
|
i
|
i
.
foo
})
@dummy
=
Dummy
.
new
@dummy
.
stubs
(
:avatar_file_name
).
returns
(
nil
)
end
should
"attempt validation if the guard returns true"
do
@dummy
.
expects
(
:foo
).
returns
(
true
)
assert
!
@dummy
.
valid?
end
should
"not attempt validation if the guard returns false"
do
@dummy
.
expects
(
:foo
).
returns
(
false
)
assert
@dummy
.
valid?
end
end
context
"as a method name"
do
setup
do
Dummy
.
send
(
:"validates_attachment_presence"
,
:avatar
,
:if
=>
:foo
)
@dummy
=
Dummy
.
new
@dummy
.
stubs
(
:avatar_file_name
).
returns
(
nil
)
end
should
"attempt validation if the guard returns true"
do
@dummy
.
expects
(
:foo
).
returns
(
true
)
assert
!
@dummy
.
valid?
end
should
"not attempt validation if the guard returns false"
do
@dummy
.
expects
(
:foo
).
returns
(
false
)
assert
@dummy
.
valid?
end
end
end
context
"a validation with an unless guard clause"
do
context
"as a lambda"
do
setup
do
Dummy
.
send
(
:"validates_attachment_presence"
,
:avatar
,
:unless
=>
lambda
{
|
i
|
i
.
foo
})
@dummy
=
Dummy
.
new
@dummy
.
stubs
(
:avatar_file_name
).
returns
(
nil
)
end
should
"attempt validation if the guard returns true"
do
@dummy
.
expects
(
:foo
).
returns
(
false
)
assert
!
@dummy
.
valid?
end
should
"not attempt validation if the guard returns false"
do
@dummy
.
expects
(
:foo
).
returns
(
true
)
assert
@dummy
.
valid?
end
end
context
"as a method name"
do
setup
do
Dummy
.
send
(
:"validates_attachment_presence"
,
:avatar
,
:unless
=>
:foo
)
@dummy
=
Dummy
.
new
@dummy
.
stubs
(
:avatar_file_name
).
returns
(
nil
)
end
should
"attempt validation if the guard returns true"
do
@dummy
.
expects
(
:foo
).
returns
(
false
)
assert
!
@dummy
.
valid?
end
should
"not attempt validation if the guard returns false"
do
@dummy
.
expects
(
:foo
).
returns
(
true
)
assert
@dummy
.
valid?
end
end
end
should
"not have Attachment in the ActiveRecord::Base namespace"
do
should
"not have Attachment in the ActiveRecord::Base namespace"
do
assert_raises
(
NameError
)
do
assert_raises
(
NameError
)
do
ActiveRecord
::
Base
::
Attachment
ActiveRecord
::
Base
::
Attachment
end
end
end
end
def
self
.
should_validate
validation
,
options
,
valid_file
,
invalid_file
context
"with
#{
validation
}
validation and
#{
options
.
inspect
}
options"
do
setup
do
rebuild_class
Dummy
.
send
(
:"validates_attachment_
#{
validation
}
"
,
:avatar
,
options
)
@dummy
=
Dummy
.
new
end
context
"and assigning nil"
do
setup
do
@dummy
.
avatar
=
nil
@dummy
.
valid?
end
if
validation
==
:presence
should
"have an error on the attachment"
do
assert
@dummy
.
errors
[
:avatar
]
assert
@dummy
.
errors
[
:avatar_file_name
]
end
else
should
"not have an error on the attachment"
do
assert
@dummy
.
errors
.
blank?
,
@dummy
.
errors
.
full_messages
.
join
(
", "
)
end
end
end
context
"and assigned a valid file"
do
setup
do
@dummy
.
avatar
=
valid_file
@dummy
.
valid?
end
should
"not have an error"
do
assert_equal
0
,
@dummy
.
errors
.
size
,
@dummy
.
errors
.
full_messages
.
join
(
", "
)
end
end
context
"and assigned an invalid file"
do
setup
do
@dummy
.
avatar
=
invalid_file
@dummy
.
valid?
end
should
"have an error"
do
assert
@dummy
.
errors
.
size
>
0
end
end
end
end
[[
:presence
,
{},
"5k.png"
,
nil
],
[
:size
,
{
:in
=>
1
..
10240
},
"5k.png"
,
"12k.png"
],
[
:size
,
{
:less_than
=>
10240
},
"5k.png"
,
"12k.png"
],
[
:size
,
{
:greater_than
=>
8096
},
"12k.png"
,
"5k.png"
],
[
:content_type
,
{
:content_type
=>
"image/png"
},
"5k.png"
,
"text.txt"
],
[
:content_type
,
{
:content_type
=>
"text/plain"
},
"text.txt"
,
"5k.png"
],
[
:content_type
,
{
:content_type
=>
%r{image/.*}
},
"5k.png"
,
"text.txt"
]].
each
do
|
args
|
validation
,
options
,
valid_file
,
invalid_file
=
args
valid_file
&&=
File
.
open
(
File
.
join
(
FIXTURES_DIR
,
valid_file
),
"rb"
)
invalid_file
&&=
File
.
open
(
File
.
join
(
FIXTURES_DIR
,
invalid_file
),
"rb"
)
should_validate
validation
,
options
,
valid_file
,
invalid_file
end
context
"with size validation and less_than 10240 option"
do
context
"and assigned an invalid file"
do
setup
do
Dummy
.
send
(
:"validates_attachment_size"
,
:avatar
,
:less_than
=>
10240
)
@dummy
=
Dummy
.
new
@dummy
.
avatar
&&=
File
.
open
(
File
.
join
(
FIXTURES_DIR
,
"12k.png"
),
"rb"
)
@dummy
.
valid?
end
should
"have a file size min/max error message"
do
assert_includes
@dummy
.
errors
[
:avatar_file_size
],
"must be less than 10240 Bytes"
end
end
end
end
end
context
"configuring a custom processor"
do
context
"configuring a custom processor"
do
...
...
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