mirror of
https://github.com/discourse/discourse.git
synced 2025-04-02 17:02:45 +08:00
FIX: Make category updates slug validation idempotent
Co-authored-by: Michael Brown <supermathie@gmail.com>
This commit is contained in:
parent
3ad07aacfa
commit
2e73985d1b
@ -285,6 +285,7 @@ class Category < ActiveRecord::Base
|
|||||||
|
|
||||||
if slug.present?
|
if slug.present?
|
||||||
# santized custom slug
|
# santized custom slug
|
||||||
|
slug = SiteSetting.slug_generation_method == 'encoded' ? CGI.unescape(self.slug) : self.slug
|
||||||
self.slug = Slug.sanitize(slug)
|
self.slug = Slug.sanitize(slug)
|
||||||
errors.add(:slug, 'is already in use') if duplicate_slug?
|
errors.add(:slug, 'is already in use') if duplicate_slug?
|
||||||
else
|
else
|
||||||
|
@ -316,6 +316,12 @@ describe Category do
|
|||||||
expect(@category.slug).to eq("%E6%B5%8B%E8%AF%95")
|
expect(@category.slug).to eq("%E6%B5%8B%E8%AF%95")
|
||||||
expect(@category.slug_for_url).to eq("%E6%B5%8B%E8%AF%95")
|
expect(@category.slug_for_url).to eq("%E6%B5%8B%E8%AF%95")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "keeps the slug" 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")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user