source: subversion/sites/rails_port_branches/api06/test/unit/diary_entry_test.rb @ 14305

Last change on this file since 14305 was 14305, checked in by zere, 10 years ago

Fixed unit tests and fixture loading for postgres. The foreign keys were playing havoc with the tests when only some fixtures were loaded.

File size: 1.0 KB
Line 
1require File.dirname(__FILE__) + '/../test_helper'
2
3class DiaryEntryTest < Test::Unit::TestCase
4  api_fixtures
5  fixtures :diary_entries
6 
7  def test_diary_entry_count
8    assert_equal 2, DiaryEntry.count
9  end
10 
11  def test_diary_entry_validations
12    diary_entry_valid({})
13    diary_entry_valid({:title => ''}, false)
14    diary_entry_valid({:title => 'a'*255})
15    diary_entry_valid({:title => 'a'*256}, false)
16    diary_entry_valid({:body => ''}, false)
17    diary_entry_valid({:latitude => 90})
18    diary_entry_valid({:latitude => 90.00001}, false)
19    diary_entry_valid({:latitude => -90})
20    diary_entry_valid({:latitude => -90.00001}, false)
21    diary_entry_valid({:longitude => 180})
22    diary_entry_valid({:longitude => 180.00001}, false)
23    diary_entry_valid({:longitude => -180})
24    diary_entry_valid({:longitude => -180.00001}, false)
25  end
26 
27  def diary_entry_valid(attrs, result = true)
28    entry = diary_entries(:normal_user_entry_1).clone
29    entry.attributes = attrs
30    assert_equal result, entry.valid?
31  end
32 
33end
Note: See TracBrowser for help on using the repository browser.