Add delegate :pick, to: :all

This commit is contained in:
Yuji Hanamura 2018-03-09 16:04:56 +09:00
parent eec723f69a
commit 6f4e66fefb
2 changed files with 6 additions and 1 deletions

@ -13,7 +13,7 @@ module Querying
:where, :rewhere, :preload, :eager_load, :includes, :from, :lock, :readonly, :extending,
:having, :create_with, :distinct, :references, :none, :unscope, :merge, to: :all
delegate :count, :average, :minimum, :maximum, :sum, :calculate, to: :all
delegate :pluck, :ids, to: :all
delegate :pluck, :ids, :pick, to: :all
# Executes a custom SQL query against your database and returns all the results. The results will
# be returned as an array with columns requested encapsulated as attributes of the model you call

@ -811,6 +811,11 @@ def test_pick_two
assert_nil Topic.where("1=0").pick(:author_name, :author_email_address)
end
def test_pick_delegate_to_all
cool_first = minivans(:cool_first)
assert_equal cool_first.color, Minivan.pick(:color)
end
def test_grouped_calculation_with_polymorphic_relation
part = ShipPart.create!(name: "has trinket")
part.trinkets.create!