Ticket #1395: diary_validations.2.patch

File diary_validations.2.patch, 1.0 KB (added by Thomas Wood, 11 years ago)

revis

  • test/unit/diary_entry_test.rb

     
    88    assert_equal 2, DiaryEntry.count
    99  end
    1010 
     11  def test_diary_entry_validations
     12    diary_entry_valid({}, true)
     13    diary_entry_valid({:title => ''})
     14    diary_entry_valid({:title => 'a'*256})
     15    diary_entry_valid({:body => ''})
     16    diary_entry_valid({:latitude => 90}, true)
     17    diary_entry_valid({:latitude => 90.1})
     18    diary_entry_valid({:latitude => -90}, true)
     19    diary_entry_valid({:latitude => -90.1})
     20    diary_entry_valid({:longitude => 180}, true)
     21    diary_entry_valid({:longitude => 180.1})
     22    diary_entry_valid({:longitude => -180}, true)
     23    diary_entry_valid({:longitude => -180.1})
     24  end
     25 
     26  def diary_entry_valid(attrs, result = false)
     27    entry = diary_entries(:normal_user_entry_1).clone
     28    entry.attributes = attrs
     29    assert_equal result, entry.valid?
     30  end
     31 
    1132end