]> git.openstreetmap.org Git - rails.git/blob - test/models/note_comment_test.rb
Add status traits to user factory.
[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
6
7   def test_event_valid
8     ok = %w(opened closed reopened commented hidden)
9     bad = %w(expropriated fubared)
10
11     ok.each do |event|
12       note_comment = create(:note_comment)
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 = create(:note_comment)
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 = %W(Name vergrößern foo\nbar
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 = create(:note_comment)
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 = create(:note_comment)
38       note_comment.body = body
39       assert !note_comment.valid?, "#{body} is valid when it shouldn't be"
40     end
41   end
42 end