1 # -*- coding: utf-8 -*-
4 class NoteTest < ActiveSupport::TestCase
8 ok = %w(open closed hidden)
9 bad = %w(expropriated fubared)
14 assert note.valid?, "#{status} is invalid, when it should be"
20 assert !note.valid?, "#{status} is valid when it shouldn't be"
26 assert_equal "open", note.status
27 assert_nil note.closed_at
29 assert_equal "closed", note.status
30 assert_not_nil note.closed_at
34 note = create(:note, :status => "closed", :closed_at => Time.now)
35 assert_equal "closed", note.status
36 assert_not_nil note.closed_at
38 assert_equal "open", note.status
39 assert_nil note.closed_at
43 assert_equal true, create(:note, :status => "open").visible?
44 assert_equal true, create(:note, :status => "closed").visible?
45 assert_equal false, create(:note, :status => "hidden").visible?
49 assert_equal true, create(:note, :status => "closed", :closed_at => Time.now).closed?
50 assert_equal false, create(:note, :status => "open", :closed_at => nil).closed?
54 comment = create(:note_comment)
55 assert_nil comment.note.author
57 comment = create(:note_comment, :author => users(:normal_user))
58 assert_equal users(:normal_user), comment.note.author
62 comment = create(:note_comment)
63 assert_nil comment.note.author_ip
65 comment = create(:note_comment, :author_ip => IPAddr.new("192.168.1.1"))
66 assert_equal IPAddr.new("192.168.1.1"), comment.note.author_ip