This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
validates_attachment
method to model
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require './test/helper' | ||
|
||
class ValidatorsTest < Test::Unit::TestCase | ||
def setup | ||
rebuild_model | ||
end | ||
|
||
context "using the helper" do | ||
setup do | ||
Dummy.validates_attachment :avatar, :presence => true, :content_type => { :content_type => "image/jpg" }, :size => { :in => 0..10.kilobytes } | ||
end | ||
|
||
should "add the attachment_presence validator to the class" do | ||
assert Dummy.validators_on(:avatar).any?{ |validator| validator.kind == :attachment_presence } | ||
end | ||
|
||
should "add the attachment_content_type validator to the class" do | ||
assert Dummy.validators_on(:avatar).any?{ |validator| validator.kind == :attachment_content_type } | ||
end | ||
|
||
should "add the attachment_size validator to the class" do | ||
assert Dummy.validators_on(:avatar).any?{ |validator| validator.kind == :attachment_size } | ||
end | ||
end | ||
end |