Ticket #1395: diary_validations.patch

File diary_validations.patch, 843 bytes (added by Thomas Wood, 10 years ago)

and validations for the above (& more)

  • test/unit/diary_entry_test.rb

     
    88    assert_equal 2, DiaryEntry.count
    99  end
    1010 
     11  def test_diary_entry_validations
     12    assert !diary_entry_valid({:title => ''})
     13    assert !diary_entry_valid({:body => ''})
     14    assert !diary_entry_valid({:title => ''})#string longer than 255 chars)
     15    assert !diary_entry_valid({:latitude => 100})
     16    assert !diary_entry_valid({:latitude => -100})
     17    assert !diary_entry_valid({:longitude => 200})
     18    assert !diary_entry_valid({:longitude => -200})
     19  end
     20 
     21  def diary_entry_valid(attrs)
     22    entry = diary_entries(:normal_user_entry_1)
     23    entry.attributes = (attrs)
     24    entry.valid?
     25  end
     26 
    1127end