From 22b3481ba2aa55fad1f9a5db94072312b345fb55 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Thu, 27 Jun 2013 21:46:24 +0200 Subject: remove deprecated implicit join references. --- activerecord/test/cases/associations/eager_test.rb | 20 +++++------------ activerecord/test/cases/relations_test.rb | 25 ++-------------------- .../test/cases/scoping/named_scoping_test.rb | 5 ----- 3 files changed, 7 insertions(+), 43 deletions(-) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index 846ef05c7d..28bf48f4fd 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -346,9 +346,7 @@ class EagerAssociationTest < ActiveRecord::TestCase def test_eager_association_loading_with_belongs_to_and_conditions_string_with_unquoted_table_name assert_nothing_raised do - ActiveSupport::Deprecation.silence do - Comment.all.merge!(:includes => :post, :where => ['posts.id = ?',4]).to_a - end + Comment.includes(:post).references(:posts).where('posts.id = ?', 4) end end @@ -367,9 +365,7 @@ class EagerAssociationTest < ActiveRecord::TestCase def test_eager_association_loading_with_belongs_to_and_conditions_string_with_quoted_table_name quoted_posts_id= Comment.connection.quote_table_name('posts') + '.' + Comment.connection.quote_column_name('id') assert_nothing_raised do - ActiveSupport::Deprecation.silence do - Comment.all.merge!(:includes => :post, :where => ["#{quoted_posts_id} = ?",4]).to_a - end + Comment.includes(:post).references(:posts).where("#{quoted_posts_id} = ?", 4) end end @@ -382,9 +378,7 @@ class EagerAssociationTest < ActiveRecord::TestCase def test_eager_association_loading_with_belongs_to_and_order_string_with_quoted_table_name quoted_posts_id= Comment.connection.quote_table_name('posts') + '.' + Comment.connection.quote_column_name('id') assert_nothing_raised do - ActiveSupport::Deprecation.silence do - Comment.all.merge!(:includes => :post, :order => quoted_posts_id).to_a - end + Comment.includes(:post).references(:posts).order(quoted_posts_id) end end @@ -548,14 +542,10 @@ class EagerAssociationTest < ActiveRecord::TestCase end def test_eager_with_has_many_and_limit_and_conditions_array_on_the_eagers - posts = ActiveSupport::Deprecation.silence do - Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => [ "authors.name = ?", 'David' ]).to_a - end + posts = Post.includes(:author, :comments).limit(2).references(:author).where("authors.name = ?", 'David') assert_equal 2, posts.size - count = ActiveSupport::Deprecation.silence do - Post.includes(:author, :comments).limit(2).references(:author).where("authors.name = ?", 'David').count - end + count = Post.includes(:author, :comments).limit(2).references(:author).where("authors.name = ?", 'David').count assert_equal posts.size, count end diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index e26cecde20..7a6d9be515 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1208,33 +1208,12 @@ class RelationTest < ActiveRecord::TestCase assert_equal "id", Post.all.primary_key end - def test_eager_loading_with_conditions_on_joins - scope = Post.includes(:comments) - - # This references the comments table, and so it should cause the comments to be eager - # loaded via a JOIN, rather than by subsequent queries. - scope = scope.joins( - Post.arel_table.create_join( - Post.arel_table, - Post.arel_table.create_on(Comment.arel_table[:id].eq(3)) - ) - ) - + def test_disable_implicit_join_references_is_deprecated assert_deprecated do - assert scope.eager_loading? + ActiveRecord::Base.disable_implicit_join_references = true end end - def test_turn_off_eager_loading_with_conditions_on_joins - original_value = ActiveRecord::Base.disable_implicit_join_references - ActiveRecord::Base.disable_implicit_join_references = true - - scope = Topic.where(author_email_address: 'my.example@gmail.com').includes(:replies) - assert_not scope.eager_loading? - ensure - ActiveRecord::Base.disable_implicit_join_references = original_value - end - def test_ordering_with_extra_spaces assert_equal authors(:david), Author.order('id DESC , name DESC').last end diff --git a/activerecord/test/cases/scoping/named_scoping_test.rb b/activerecord/test/cases/scoping/named_scoping_test.rb index afe32af1d1..73ff8abb4e 100644 --- a/activerecord/test/cases/scoping/named_scoping_test.rb +++ b/activerecord/test/cases/scoping/named_scoping_test.rb @@ -60,11 +60,6 @@ class NamedScopingTest < ActiveRecord::TestCase assert Topic.approved.respond_to?(:length) end - def test_respond_to_respects_include_private_parameter - assert !Topic.approved.respond_to?(:tables_in_string) - assert Topic.approved.respond_to?(:tables_in_string, true) - end - def test_scopes_with_options_limit_finds_to_those_matching_the_criteria_specified assert !Topic.all.merge!(:where => {:approved => true}).to_a.empty? -- cgit v1.2.3