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