diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-05-26 10:35:14 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-05-26 10:35:14 +0200 |
commit | adfab2dcf4003ca564d78d4425566dd2d9cd8b4f (patch) | |
tree | 494149351a1e31e7391ee42c859afbdcb35d1f6f /activerecord/test/cases/relation | |
parent | b8c31fd9b94cd8ac2963c252fcca40b29c43e75c (diff) | |
download | rails-adfab2dcf4003ca564d78d4425566dd2d9cd8b4f.tar.gz rails-adfab2dcf4003ca564d78d4425566dd2d9cd8b4f.tar.bz2 rails-adfab2dcf4003ca564d78d4425566dd2d9cd8b4f.zip |
deprecate `Relation#uniq` use `Relation#distinct` instead.
See #9683 for the reasons we switched to `distinct`.
Here is the discussion that triggered the actual deprecation #20198.
`uniq`, `uniq!` and `uniq_value` are still around.
They will be removed in the next minor release after Rails 5.
Diffstat (limited to 'activerecord/test/cases/relation')
-rw-r--r-- | activerecord/test/cases/relation/mutation_test.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/activerecord/test/cases/relation/mutation_test.rb b/activerecord/test/cases/relation/mutation_test.rb index 45ead08bd5..2f2987e42d 100644 --- a/activerecord/test/cases/relation/mutation_test.rb +++ b/activerecord/test/cases/relation/mutation_test.rb @@ -81,7 +81,7 @@ module ActiveRecord assert_equal [], relation.extending_values end - (Relation::SINGLE_VALUE_METHODS - [:lock, :reordering, :reverse_order, :create_with]).each do |method| + (Relation::SINGLE_VALUE_METHODS - [:lock, :reordering, :reverse_order, :create_with, :uniq]).each do |method| test "##{method}!" do assert relation.public_send("#{method}!", :foo).equal?(relation) assert_equal :foo, relation.public_send("#{method}_value") @@ -153,13 +153,22 @@ module ActiveRecord test 'distinct!' do relation.distinct! :foo assert_equal :foo, relation.distinct_value - assert_equal :foo, relation.uniq_value # deprecated access + + assert_deprecated do + assert_equal :foo, relation.uniq_value # deprecated access + end end test 'uniq! was replaced by distinct!' do - relation.uniq! :foo + assert_deprecated(/use distinct! instead/) do + relation.uniq! :foo + end + + e = assert_deprecated(/use distinct_value instead/) do + assert_equal :foo, relation.uniq_value # deprecated access + end + assert_equal :foo, relation.distinct_value - assert_equal :foo, relation.uniq_value # deprecated access end end end |