diff options
author | Christophe Maximin <christophe.maximin@gmail.com> | 2018-11-07 22:38:41 +0000 |
---|---|---|
committer | Christophe Maximin <christophe.maximin@gmail.com> | 2018-11-07 23:36:39 +0000 |
commit | 25f1cbdecd4f506b46a6c476f18074dafdb581f2 (patch) | |
tree | 322a0212b12eb6de351076ecf40c635d036bf1de /activerecord/test/cases | |
parent | fc2684c9c012b95ce003cce22b378d5ea9ab56d3 (diff) | |
download | rails-25f1cbdecd4f506b46a6c476f18074dafdb581f2.tar.gz rails-25f1cbdecd4f506b46a6c476f18074dafdb581f2.tar.bz2 rails-25f1cbdecd4f506b46a6c476f18074dafdb581f2.zip |
Guard Enums against definitions with blank label names
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/enum_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/enum_test.rb b/activerecord/test/cases/enum_test.rb index b4593ccdf2..867ce7082b 100644 --- a/activerecord/test/cases/enum_test.rb +++ b/activerecord/test/cases/enum_test.rb @@ -274,6 +274,24 @@ class EnumTest < ActiveRecord::TestCase end assert_match(/must be either a hash, an array of symbols, or an array of strings./, e.message) + + e = assert_raises(ArgumentError) do + Class.new(ActiveRecord::Base) do + self.table_name = "books" + enum status: { "" => 1, "active" => 2 } + end + end + + assert_match(/Enum label name must not be blank/, e.message) + + e = assert_raises(ArgumentError) do + Class.new(ActiveRecord::Base) do + self.table_name = "books" + enum status: ["active", ""] + end + end + + assert_match(/Enum label name must not be blank/, e.message) end test "reserved enum names" do |