Permalink
Browse files

Remove deprecated support to passing arguments to `#select` when a bl…

…ock is provided.
  • Loading branch information...
rafaelfranca committed Dec 29, 2016
1 parent fc3e679 commit 4fc3366d9d99a0eb19e45ad2bf38534efbf8c8ce
@@ -1,3 +1,7 @@
* Remove deprecated support to passing arguments to `#select` when a block is provided.
*Rafael Mendonça França*
* Remove deprecated support to query using commas on LIMIT.
*Rafael Mendonça França*
@@ -243,9 +243,7 @@ def references!(*table_names) # :nodoc:
def select(*fields)
if block_given?
if fields.any?
ActiveSupport::Deprecation.warn(<<-WARNING.squish)
When select is called with a block, it ignores other arguments. This behavior is now deprecated and will result in an ArgumentError in Rails 5.1. You can safely remove the arguments to resolve the deprecation warning because they do not have any effect on the output of the call to the select method with a block.
WARNING
raise ArgumentError, "`select' with block doesn't take arguments."
end
return super()
@@ -788,13 +788,6 @@ def test_select_with_block
assert_equal [1], posts(:welcome).comments.select { |c| c.id == 1 }.map(&:id)
end
def test_select_with_block_and_specific_attributes
assert_deprecated do
comments = posts(:welcome).comments.select(:id, :body) { |c| c.id == 1 }
assert_equal [1], comments.map(&:id)
end
end
def test_select_without_foreign_key
assert_equal companies(:first_firm).accounts.first.credit_limit, companies(:first_firm).accounts.select(:credit_limit).first.credit_limit
end

0 comments on commit 4fc3366

Please sign in to comment.