From 40b0b549ffdfa4b5f02f6df012869a3834d31a30 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 21 Oct 2019 13:35:19 -0400 Subject: [PATCH] DEV: update the comments re the encoded slug changes * followup to 2e73985d --- app/models/category.rb | 3 ++- spec/models/category_spec.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/category.rb b/app/models/category.rb index a6c5deb4885..74a6d87fb54 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -284,8 +284,9 @@ class Category < ActiveRecord::Base self.name.strip! if slug.present? - # santized custom slug + # if we don't unescape it first we strip the % from the encoded version slug = SiteSetting.slug_generation_method == 'encoded' ? CGI.unescape(self.slug) : self.slug + # sanitize the custom slug self.slug = Slug.sanitize(slug) errors.add(:slug, 'is already in use') if duplicate_slug? else diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb index fdf2b7a9e52..f9a63c5151c 100644 --- a/spec/models/category_spec.rb +++ b/spec/models/category_spec.rb @@ -317,7 +317,7 @@ describe Category do expect(@category.slug_for_url).to eq("%E6%B5%8B%E8%AF%95") end - it "keeps the slug" do + it "keeps the encoded slug after saving" do @category.save expect(@category.slug).to eq("%E6%B5%8B%E8%AF%95") expect(@category.slug_for_url).to eq("%E6%B5%8B%E8%AF%95")