From 8f290092f088c66a88addf82e0b4cdb88b64e854 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Fri, 24 Jun 2016 17:43:25 +0900 Subject: [PATCH] return correct type from `EnumType` --- activerecord/lib/active_record/enum.rb | 2 ++ activerecord/test/cases/enum_test.rb | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/activerecord/lib/active_record/enum.rb b/activerecord/lib/active_record/enum.rb index 7be332fb97..b884edf920 100644 --- a/activerecord/lib/active_record/enum.rb +++ b/activerecord/lib/active_record/enum.rb @@ -105,6 +105,8 @@ module ActiveRecord end class EnumType < Type::Value # :nodoc: + delegate :type, to: :subtype + def initialize(name, mapping, subtype) @name = name @mapping = mapping diff --git a/activerecord/test/cases/enum_test.rb b/activerecord/test/cases/enum_test.rb index babacd1ee9..e781b60464 100644 --- a/activerecord/test/cases/enum_test.rb +++ b/activerecord/test/cases/enum_test.rb @@ -421,4 +421,8 @@ class EnumTest < ActiveRecord::TestCase book = Book.new assert book.hard? end + + test "data type of Enum type" do + assert_equal :integer, Book.type_for_attribute('status').type + end end