3 class NoteTest < ActiveSupport::TestCase
5 ok = %w[open closed hidden]
6 bad = %w[expropriated fubared]
11 assert_predicate note, :valid?, "#{status} is invalid, when it should be"
17 assert_not_predicate 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, :closed)
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_predicate create(:note, :status => "open"), :visible?
41 assert_predicate create(:note, :closed), :visible?
42 assert_not_predicate create(:note, :status => "hidden"), :visible?
46 assert_predicate create(:note, :closed), :closed?
47 assert_not_predicate create(:note, :status => "open", :closed_at => nil), :closed?
52 assert_equal "Default note's description", note.description
54 note = create(:note, :description => "Test description #1")
55 assert_equal "Test description #1", note.description
57 comment = create(:note_comment)
58 assert_equal "Default note's description", comment.note.description
60 comment = create(:note_comment, :note => build(:note, :description => "Test description #2"))
61 assert_equal "Test description #2", comment.note.description
67 note = create(:note, :author => user)
68 assert_equal user, note.author
70 comment = create(:note_comment)
71 assert_nil comment.note.author
73 comment = create(:note_comment, :author => user, :note => build(:note, :author => user))
74 assert_equal user, comment.note.author
77 # Ensure the lat/lon is formatted as a decimal e.g. not 4.0e-05
78 def test_lat_lon_format
79 note = build(:note, :latitude => 0.00004 * GeoRecord::SCALE, :longitude => 0.00008 * GeoRecord::SCALE)
81 assert_equal "0.0000400", note.lat.to_s
82 assert_equal "0.0000800", note.lon.to_s