diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-11-05 17:29:52 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-11-05 17:44:08 +0100 |
commit | 44406d1e77061ce22effaae4698918c1f9f6271a (patch) | |
tree | 2b6864e46ed700719a81bf79c233bfa626a4fafd /activerecord/test | |
parent | 6c720d18a2770299433fae82c1cab25d0bd4033e (diff) | |
download | rails-44406d1e77061ce22effaae4698918c1f9f6271a.tar.gz rails-44406d1e77061ce22effaae4698918c1f9f6271a.tar.bz2 rails-44406d1e77061ce22effaae4698918c1f9f6271a.zip |
store enum mapping using `Strings` instead of `Symbols`.
This allows to assign both `String` and `Symbol` values to the enum
without having to call `to_sym`, which is a security problem.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/enum_test.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/activerecord/test/cases/enum_test.rb b/activerecord/test/cases/enum_test.rb index 087db4c32c..54cc60913a 100644 --- a/activerecord/test/cases/enum_test.rb +++ b/activerecord/test/cases/enum_test.rb @@ -17,8 +17,8 @@ class EnumTest < ActiveRecord::TestCase end test "query state with symbol" do - assert_equal :proposed, @book.status - assert_equal :unread, @book.read_status + assert_equal "proposed", @book.status + assert_equal "unread", @book.read_status end test "find via scope" do @@ -46,6 +46,11 @@ class EnumTest < ActiveRecord::TestCase assert @book.written? end + test "assign string value" do + @book.status = "written" + assert @book.written? + end + test "assign non existing value raises an error" do e = assert_raises(ArgumentError) do @book.status = :unknown |