From 44406d1e77061ce22effaae4698918c1f9f6271a Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Tue, 5 Nov 2013 17:29:52 +0100 Subject: 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. --- activerecord/test/cases/enum_test.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'activerecord/test') 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 -- cgit v1.2.3