Class: ValidationTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- ValidationTest
- Defined in:
- lib/test/validation_test.rb
Instance Method Summary collapse
- #test_should_invalidate_big_files ⇒ Object
- #test_should_invalidate_small_files ⇒ Object
- #test_should_require_filename ⇒ Object
- #test_should_validate_content_type ⇒ Object
Instance Method Details
#test_should_invalidate_big_files ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/test/validation_test.rb', line 4 def test_should_invalidate_big_files @attachment = SmallAttachment.new assert !@attachment.valid? assert @attachment.errors.on(:size) @attachment.size = 2000 assert !@attachment.valid? assert @attachment.errors.on(:size), @attachment.errors..to_sentence @attachment.size = 1000 assert !@attachment.valid? assert_nil @attachment.errors.on(:size) end |
#test_should_invalidate_small_files ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/test/validation_test.rb', line 18 def test_should_invalidate_small_files @attachment = BigAttachment.new assert !@attachment.valid? assert @attachment.errors.on(:size) @attachment.size = 2000 assert !@attachment.valid? assert @attachment.errors.on(:size), @attachment.errors..to_sentence @attachment.size = 1.megabyte assert !@attachment.valid? assert_nil @attachment.errors.on(:size) end |
#test_should_require_filename ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/test/validation_test.rb', line 46 def test_should_require_filename @attachment = Attachment.new assert !@attachment.valid? assert @attachment.errors.on(:filename) @attachment.filename = 'foo' assert !@attachment.valid? assert_nil @attachment.errors.on(:filename) end |
#test_should_validate_content_type ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/test/validation_test.rb', line 32 def test_should_validate_content_type @attachment = PdfAttachment.new assert !@attachment.valid? assert @attachment.errors.on(:content_type) @attachment.content_type = 'foo' assert !@attachment.valid? assert @attachment.errors.on(:content_type) @attachment.content_type = 'pdf' assert !@attachment.valid? assert_nil @attachment.errors.on(:content_type) end |