pools: strip leading/trailing, consecutive underscores in names (fix #3263).

This commit is contained in:
evazion
2017-08-10 18:16:50 -05:00
parent 87b0dc3ae3
commit 3b9a54f681
3 changed files with 27 additions and 18 deletions

View File

@@ -249,7 +249,10 @@ class PoolTest < ActiveSupport::TestCase
end
should "normalize its name" do
@pool.update_attributes(:name => "A B")
@pool.update(:name => " A B ")
assert_equal("A_B", @pool.name)
@pool.update(:name => "__A__B__")
assert_equal("A_B", @pool.name)
end
@@ -257,6 +260,16 @@ class PoolTest < ActiveSupport::TestCase
@pool.update_attributes(:post_ids => " 1 2 ")
assert_equal("1 2", @pool.post_ids)
end
context "when validating names" do
should_not allow_value("foo,bar").for(:name)
should_not allow_value("___").for(:name)
should_not allow_value(" ").for(:name)
%w[any none series collection].each do |type|
should_not allow_value(type).for(:name)
end
end
end
context "An existing pool" do