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