3 class NoteTest < ActiveSupport::TestCase
 
   5     ok = %w[open closed hidden]
 
   6     bad = %w[expropriated fubared]
 
  11       assert note.valid?, "#{status} is invalid, when it should be"
 
  17       assert_not note.valid?, "#{status} is valid when it shouldn't be"
 
  23     assert_equal "open", note.status
 
  24     assert_nil note.closed_at
 
  26     assert_equal "closed", note.status
 
  27     assert_not_nil note.closed_at
 
  31     note = create(:note, :status => "closed", :closed_at => Time.now)
 
  32     assert_equal "closed", note.status
 
  33     assert_not_nil note.closed_at
 
  35     assert_equal "open", note.status
 
  36     assert_nil note.closed_at
 
  40     assert create(:note, :status => "open").visible?
 
  41     assert create(:note, :status => "closed").visible?
 
  42     assert_not create(:note, :status => "hidden").visible?
 
  46     assert create(:note, :status => "closed", :closed_at => Time.now).closed?
 
  47     assert_not create(:note, :status => "open", :closed_at => nil).closed?
 
  51     comment = create(:note_comment)
 
  52     assert_nil comment.note.author
 
  55     comment = create(:note_comment, :author => user)
 
  56     assert_equal user, comment.note.author
 
  60     comment = create(:note_comment)
 
  61     assert_nil comment.note.author_ip
 
  63     comment = create(:note_comment, :author_ip => IPAddr.new("192.168.1.1"))
 
  64     assert_equal IPAddr.new("192.168.1.1"), comment.note.author_ip
 
  67   # Ensure the lat/lon is formatted as a decimal e.g. not 4.0e-05
 
  68   def test_lat_lon_format
 
  69     note = build(:note, :latitude => 0.00004 * GeoRecord::SCALE, :longitude => 0.00008 * GeoRecord::SCALE)
 
  71     assert_equal "0.0000400", note.lat.to_s
 
  72     assert_equal "0.0000800", note.lon.to_s