]> git.openstreetmap.org Git - rails.git/blob - test/models/note_comment_test.rb
Defer deletion of avatars to a background job
[rails.git] / test / models / note_comment_test.rb
1 require "test_helper"
2
3 class NoteCommentTest < ActiveSupport::TestCase
4   def test_event_valid
5     ok = %w[opened closed reopened commented hidden]
6     bad = %w[expropriated fubared]
7
8     ok.each do |event|
9       note_comment = create(:note_comment)
10       note_comment.event = event
11       assert note_comment.valid?, "#{event} is invalid, when it should be"
12     end
13
14     bad.each do |event|
15       note_comment = create(:note_comment)
16       note_comment.event = event
17       assert_not note_comment.valid?, "#{event} is valid when it shouldn't be"
18     end
19   end
20
21   def test_body_valid
22     ok = %W[Name vergrößern foo\nbar
23             ルシステムにも対応します 輕觸搖晃的遊戲]
24     bad = ["foo\x00bar", "foo\x08bar", "foo\x1fbar", "foo\x7fbar",
25            "foo\ufffebar", "foo\uffffbar"]
26
27     ok.each do |body|
28       note_comment = create(:note_comment)
29       note_comment.body = body
30       assert note_comment.valid?, "#{body} is invalid, when it should be"
31     end
32
33     bad.each do |body|
34       note_comment = create(:note_comment)
35       note_comment.body = body
36       assert_not note_comment.valid?, "#{body} is valid when it shouldn't be"
37     end
38   end
39 end