wikis: force wiki names to follow same rules as tag names.
Don't allow wiki pages to have invalid names. This incidentally means that you can't create wiki pages for pools. For example, you can't create a wiki titled "pool:almost_heart-warming". This is not a valid tag name, so it's not a valid wiki name either. This was done in a handful of cases to translate Pixiv tags to Danbooru pools (see: <https://danbooru.donmai.us/wiki_page_versions?search[title_like]=pool:*>) Also fix it so that titles are normalized before validation, not before save.
This commit is contained in:
@@ -78,6 +78,29 @@ class WikiPageTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "during title validation" do
|
||||
# these values are allowed because they're normalized first
|
||||
should allow_value(" foo ").for(:title).on(:create)
|
||||
should allow_value("~foo").for(:title).on(:create)
|
||||
should allow_value("_foo").for(:title).on(:create)
|
||||
should allow_value("foo_").for(:title).on(:create)
|
||||
should allow_value("foo__bar").for(:title).on(:create)
|
||||
should allow_value("FOO").for(:title).on(:create)
|
||||
should allow_value("foo bar").for(:title).on(:create)
|
||||
|
||||
should_not allow_value("").for(:title).on(:create)
|
||||
should_not allow_value("___").for(:title).on(:create)
|
||||
should_not allow_value("-foo").for(:title).on(:create)
|
||||
should_not allow_value("/foo").for(:title).on(:create)
|
||||
should_not allow_value("foo*bar").for(:title).on(:create)
|
||||
should_not allow_value("foo,bar").for(:title).on(:create)
|
||||
should_not allow_value("foo\abar").for(:title).on(:create)
|
||||
should_not allow_value("café").for(:title).on(:create)
|
||||
should_not allow_value("東方").for(:title).on(:create)
|
||||
should_not allow_value("FAV:blah").for(:title).on(:create)
|
||||
should_not allow_value("X"*171).for(:title).on(:create)
|
||||
end
|
||||
|
||||
context "with other names" do
|
||||
should "not allow artist wikis to have other names" do
|
||||
tag = create(:artist_tag)
|
||||
|
||||
Reference in New Issue
Block a user