]> git.openstreetmap.org Git - rails.git/blob - test/models/relation_member_test.rb
Merge remote-tracking branch 'upstream/pull/4409'
[rails.git] / test / models / relation_member_test.rb
1 require "test_helper"
2
3 class RelationMemberTest < ActiveSupport::TestCase
4   def test_role_with_invalid_characters
5     invalid = ["\x7f<hr/>", "test@example.com\x0e-", "s/\x1ff", "aa/\ufffe",
6                "aa\x0b-,", "aa?\x08", "/;\uffff.,?", "\x0c#ping",
7                "foo\x1fbar", "foo\x7fbar", "foo\ufffebar", "foo\uffffbar"]
8     relation = create(:relation)
9     node = create(:node)
10     invalid.each do |r|
11       member = build(:relation_member, :relation => relation, :member => node, :member_role => r)
12       assert_not member.valid?, "'#{r}' should not be valid"
13       assert_predicate member.errors[:member_role], :any?
14     end
15   end
16
17   def test_role_too_long
18     relation = create(:relation)
19     node = create(:node)
20     member = build(:relation_member, :relation => relation, :member => node, :member_role => "r" * 256)
21     assert_not member.valid?, "Role should be too long"
22     assert_predicate member.errors[:member_role], :any?
23   end
24 end