X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/124ec2e9d560e0df291e5a8e5aa67ef5db2f5d46..6bf3b453f9d31b595ac5cc216cffba8df77f378c:/test/models/relation_member_test.rb
diff --git a/test/models/relation_member_test.rb b/test/models/relation_member_test.rb
index 170b1977c..7535c342d 100644
--- a/test/models/relation_member_test.rb
+++ b/test/models/relation_member_test.rb
@@ -1,4 +1,24 @@
require "test_helper"
class RelationMemberTest < ActiveSupport::TestCase
+ def test_role_with_invalid_characters
+ invalid = ["\x7f
", "test@example.com\x0e-", "s/\x1ff", "aa/\ufffe",
+ "aa\x0b-,", "aa?\x08", "/;\uffff.,?", "\x0c#ping",
+ "foo\x1fbar", "foo\x7fbar", "foo\ufffebar", "foo\uffffbar"]
+ relation = create(:relation)
+ node = create(:node)
+ invalid.each do |r|
+ member = build(:relation_member, :relation => relation, :member => node, :member_role => r)
+ assert_not_predicate member, :valid?, "'#{r}' should not be valid"
+ assert_predicate member.errors[:member_role], :any?
+ end
+ end
+
+ def test_role_too_long
+ relation = create(:relation)
+ node = create(:node)
+ member = build(:relation_member, :relation => relation, :member => node, :member_role => "r" * 256)
+ assert_not_predicate member, :valid?, "Role should be too long"
+ assert_predicate member.errors[:member_role], :any?
+ end
end