diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-11-23 23:35:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-23 23:35:29 -0500 |
commit | 171e32fc779fc26804f6670ea41850aec282d882 (patch) | |
tree | 2997a1d0402c2cb0ddc08a76364c367b03ee9e31 /activerecord/test/cases | |
parent | 6685e272b39fa3331a01242be8cf3a9f95b486b9 (diff) | |
parent | 4c8c31774a7c44080099f4a9c7e21d76fa097e09 (diff) | |
download | rails-171e32fc779fc26804f6670ea41850aec282d882.tar.gz rails-171e32fc779fc26804f6670ea41850aec282d882.tar.bz2 rails-171e32fc779fc26804f6670ea41850aec282d882.zip |
Merge pull request #34517 from EByrdS/immutable-enum
Pluralized enum raises error when attempting to modify
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/enum_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/enum_test.rb b/activerecord/test/cases/enum_test.rb index 867ce7082b..fef06e6edd 100644 --- a/activerecord/test/cases/enum_test.rb +++ b/activerecord/test/cases/enum_test.rb @@ -438,6 +438,20 @@ class EnumTest < ActiveRecord::TestCase assert_equal ["drafted", "uploaded"], book2.status_change end + test "attempting to modify enum raises error" do + e = assert_raises(RuntimeError) do + Book.statuses["bad_enum"] = 40 + end + + assert_match(/can't modify frozen/, e.message) + + e = assert_raises(RuntimeError) do + Book.statuses.delete("published") + end + + assert_match(/can't modify frozen/, e.message) + end + test "declare multiple enums at a time" do klass = Class.new(ActiveRecord::Base) do self.table_name = "books" |