]> git.openstreetmap.org Git - rails.git/blobdiff - test/lib/rich_text_test.rb
Preserve rel=me on links in rich text
[rails.git] / test / lib / rich_text_test.rb
index 9d00d658d5bac697b3e4a8bce6e4bfb01fc52469..aa99e2a4dc6ff9e80de7985ec8a96897a17dd3e1 100644 (file)
@@ -18,6 +18,13 @@ class RichTextTest < ActiveSupport::TestCase
       assert_select "a[rel='nofollow noopener noreferrer']", 1
     end
 
       assert_select "a[rel='nofollow noopener noreferrer']", 1
     end
 
+    r = RichText.new("html", "foo <a rel='junk me trash' href='http://example.com/'>bar</a> baz")
+    assert_html r do
+      assert_select "a", 1
+      assert_select "a[href='http://example.com/']", 1
+      assert_select "a[rel='me nofollow noopener noreferrer']", 1
+    end
+
     r = RichText.new("html", "foo example@example.com bar")
     assert_html r do
       assert_select "a", 0
     r = RichText.new("html", "foo example@example.com bar")
     assert_html r do
       assert_select "a", 0
@@ -91,6 +98,13 @@ class RichTextTest < ActiveSupport::TestCase
       assert_select "a[rel='nofollow noopener noreferrer']", 1
     end
 
       assert_select "a[rel='nofollow noopener noreferrer']", 1
     end
 
+    r = RichText.new("markdown", "foo <a rel='junk me trash' href='http://example.com/'>bar</a>) baz")
+    assert_html r do
+      assert_select "a", 1
+      assert_select "a[href='http://example.com/']", 1
+      assert_select "a[rel='me nofollow noopener noreferrer']", 1
+    end
+
     r = RichText.new("markdown", "foo example@example.com bar")
     assert_html r do
       assert_select "a", 1
     r = RichText.new("markdown", "foo example@example.com bar")
     assert_html r do
       assert_select "a", 1