]> git.openstreetmap.org Git - rails.git/blobdiff - test/models/relation_member_test.rb
Add titles to changeset element page links
[rails.git] / test / models / relation_member_test.rb
index 82eaa7e58432a139031520cb2a7fe3de0079efc2..7535c342ddbb4e2d586e12c01d29d5c6f1564e94 100644 (file)
@@ -1,9 +1,24 @@
-require 'test_helper'
+require "test_helper"
 
 class RelationMemberTest < ActiveSupport::TestCase
-  api_fixtures
-  
-  def test_relation_member_count
-    assert_equal 9, RelationMember.count
+  def test_role_with_invalid_characters
+    invalid = ["\x7f<hr/>", "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