Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tests to assert unicode slug validation and escaping/unescaping.

  • Loading branch information...
commit b0c5fe65902641a2805c14e791c39fa9e5bf89a7 1 parent 8c9d327
Eric Lukoff authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 test/unit/models/page_test.rb
View
19 test/unit/models/page_test.rb
@@ -1,3 +1,4 @@
+# encoding: utf-8
require File.expand_path('../../test_helper', File.dirname(__FILE__))
class CmsPageTest < ActiveSupport::TestCase
@@ -51,6 +52,9 @@ def test_validation_of_slug
page.slug = 'inva lid'
assert page.invalid?
+
+ page.slug = 'acción'
+ assert page.valid?
end
def test_label_assignment
@@ -204,6 +208,21 @@ def test_url
assert_equal 'http://test.host/', cms_pages(:default).url
assert_equal 'http://test.host/child-page', cms_pages(:child).url
end
+
+ def test_unicode_slug_escaping
+ page = cms_pages(:child)
+ page_1 = cms_sites(:default).pages.create!(new_params(:parent => page, :slug => 'tést-ünicode-slug'))
+ assert_equal CGI::escape('tést-ünicode-slug'), page_1.slug
+ assert_equal CGI::escape('/child-page/tést-ünicode-slug').gsub('%2F', '/'), page_1.full_path
+ end
+
+ def test_unicode_slug_unescaping
+ page = cms_pages(:child)
+ page_1 = cms_sites(:default).pages.create!(new_params(:parent => page, :slug => 'tést-ünicode-slug'))
+ found_page = cms_sites(:default).pages.where(:slug => CGI::escape('tést-ünicode-slug')).first
+ assert_equal 'tést-ünicode-slug', found_page.slug
+ assert_equal '/child-page/tést-ünicode-slug', found_page.full_path
+ end
protected
Please sign in to comment.
Something went wrong with that request. Please try again.