1 # -*- coding: utf-8 -*-
4 class NoteTest < ActiveSupport::TestCase
6 ok = %w[open closed hidden]
7 bad = %w[expropriated fubared]
12 assert note.valid?, "#{status} is invalid, when it should be"
18 assert !note.valid?, "#{status} is valid when it shouldn't be"
24 assert_equal "open", note.status
25 assert_nil note.closed_at
27 assert_equal "closed", note.status
28 assert_not_nil note.closed_at
32 note = create(:note, :status => "closed", :closed_at => Time.now)
33 assert_equal "closed", note.status
34 assert_not_nil note.closed_at
36 assert_equal "open", note.status
37 assert_nil note.closed_at
41 assert_equal true, create(:note, :status => "open").visible?
42 assert_equal true, create(:note, :status => "closed").visible?
43 assert_equal false, create(:note, :status => "hidden").visible?
47 assert_equal true, create(:note, :status => "closed", :closed_at => Time.now).closed?
48 assert_equal false, create(:note, :status => "open", :closed_at => nil).closed?
52 comment = create(:note_comment)
53 assert_nil comment.note.author
56 comment = create(:note_comment, :author => user)
57 assert_equal user, comment.note.author
61 comment = create(:note_comment)
62 assert_nil comment.note.author_ip
64 comment = create(:note_comment, :author_ip => IPAddr.new("192.168.1.1"))
65 assert_equal IPAddr.new("192.168.1.1"), comment.note.author_ip