From ae33aea62cd1d3cf489a9335fadc30d1c11e0dc4 Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Fri, 13 Feb 2015 16:18:22 -0800 Subject: Enums should be referred to by symbols Also updated the documentation about the new ability to query them normally, and added test to make sure they work! --- activerecord/test/cases/enum_test.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/enum_test.rb b/activerecord/test/cases/enum_test.rb index ed568413a2..ed1585da1a 100644 --- a/activerecord/test/cases/enum_test.rb +++ b/activerecord/test/cases/enum_test.rb @@ -32,9 +32,22 @@ class EnumTest < ActiveRecord::TestCase assert Book.where(status: Book.statuses[:proposed]).build.proposed? end - test "find via where" do + test "find via where with symbols" do + assert_equal @book, Book.where(format: :paperback).first + refute_equal @book, Book.where(format: :ebook).first + assert_equal @book, Book.where(format: [:paperback]).first + refute_equal @book, Book.where(format: [:ebook]).first + refute_equal @book, Book.where("format <> ?", :paperback).first + assert_equal @book, Book.where("format <> ?", :ebook).first + end + + test "find via where with strings" do assert_equal @book, Book.where(status: "proposed").first refute_equal @book, Book.where(status: "written").first + assert_equal @book, Book.where(status: ["proposed"]).first + refute_equal @book, Book.where(status: ["written"]).first + refute_equal @book, Book.where("format <> ?", "paperback").first + assert_equal @book, Book.where("format <> ?", "ebook").first end test "update by declaration" do -- cgit v1.2.3