aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2015-02-13 16:18:22 -0800
committerGodfrey Chan <godfreykfc@gmail.com>2015-02-13 16:18:26 -0800
commitae33aea62cd1d3cf489a9335fadc30d1c11e0dc4 (patch)
tree352706eb141bd56dc299df0fc9cfc5a8ca70b46f /activerecord/test/cases
parent62133326df3c7edff67a2e57ae32c95bf6e8a818 (diff)
downloadrails-ae33aea62cd1d3cf489a9335fadc30d1c11e0dc4.tar.gz
rails-ae33aea62cd1d3cf489a9335fadc30d1c11e0dc4.tar.bz2
rails-ae33aea62cd1d3cf489a9335fadc30d1c11e0dc4.zip
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!
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/enum_test.rb15
1 files changed, 14 insertions, 1 deletions
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