favgroups: add stricter favgroup naming rules.

Don't allow favgroup names that:

* Start or end with underscores.
* Contain multiple underscores in a row.
* Contain asterisks or non-printable characters.
* Consist of only underscores.
* Consist of only digits (conflicts with `favgroup:1234` syntax).

Add a fix script that fixes favgroups that violate these rules and notifies the user.
This commit is contained in:
evazion
2022-11-20 21:35:49 -06:00
parent 4fd028a5ce
commit 1e478ab1b5
3 changed files with 102 additions and 8 deletions

View File

@@ -58,4 +58,15 @@ class FavoriteGroupTest < ActiveSupport::TestCase
assert_equal([], @fav_group.reload.post_ids)
end
end
context "when validating names" do
subject { build(:favorite_group) }
should_not allow_value("foo,bar").for(:name)
should_not allow_value("foo*bar").for(:name)
should_not allow_value("123").for(:name)
should_not allow_value("_").for(:name)
should_not allow_value("any").for(:name)
should_not allow_value("none").for(:name)
end
end