Skip to content

Commit

Permalink
Merge pull request comfy#195 from brokenladder/unicode_accents
Browse files Browse the repository at this point in the history
Allow Unicode accent characters in slug name
  • Loading branch information
GBH committed Jul 5, 2012
2 parents bb7a0a6 + 026c768 commit 04cf209
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/cms/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Cms::Page < ActiveRecord::Base
:presence => true
validates :slug,
:presence => true,
:format => /^\p{Alnum}[\.\p{Alnum}_-]*$/i,
:format => /^\p{Alnum}[\.\p{Alnum}\p{Mark}_-]*$/i,
:uniqueness => { :scope => :parent_id },
:unless => lambda{ |p| p.site && (p.site.pages.count == 0 || p.site.pages.root == self) }
validates :layout,
Expand Down
10 changes: 9 additions & 1 deletion test/unit/models/page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ def test_validation_of_slug
page.slug = 'acción'
assert page.valid?
end


def test_validation_of_slug_allows_unicode_accent_characters
page = cms_pages(:child)
thai_character_ko_kai = "\u0e01"
thai_character_mai_tho = "\u0E49"
page.slug = thai_character_ko_kai + thai_character_mai_tho
assert page.valid?
end

def test_label_assignment
page = cms_sites(:default).pages.new(
:slug => 'test',
Expand Down

0 comments on commit 04cf209

Please sign in to comment.