aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-07-28 16:34:24 +0900
committerGitHub <noreply@github.com>2019-07-28 16:34:24 +0900
commit715dad107b5cce4f09065b4f6b84641f6d18f028 (patch)
tree84af5f884d066d317386543216b65ed83a26dbdb /activerecord
parent36b32bb32e84aff0f507c690aafa1e51e0a3acf6 (diff)
parent6fbf52d580b661d79dd001774b254b4d258ab8bf (diff)
downloadrails-715dad107b5cce4f09065b4f6b84641f6d18f028.tar.gz
rails-715dad107b5cce4f09065b4f6b84641f6d18f028.tar.bz2
rails-715dad107b5cce4f09065b4f6b84641f6d18f028.zip
Merge pull request #36787 from st0012/refactor-sql-tests
Use capture_sql helper method in tests
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb5
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb5
2 files changed, 2 insertions, 8 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb
index 21286be320..6bd305306f 100644
--- a/activerecord/test/cases/associations/belongs_to_associations_test.rb
+++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -60,10 +60,7 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
end
def test_belongs_to_does_not_use_order_by
- ActiveRecord::SQLCounter.clear_log
- Client.find(3).firm
- ensure
- sql_log = ActiveRecord::SQLCounter.log
+ sql_log = capture_sql { Client.find(3).firm }
assert sql_log.all? { |sql| !/order by/i.match?(sql) }, "ORDER BY was used in the query: #{sql_log}"
end
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb
index 9227f10c0e..46498a6dfb 100644
--- a/activerecord/test/cases/associations/has_one_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_associations_test.rb
@@ -37,10 +37,7 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
end
def test_has_one_does_not_use_order_by
- ActiveRecord::SQLCounter.clear_log
- companies(:first_firm).account
- ensure
- sql_log = ActiveRecord::SQLCounter.log
+ sql_log = capture_sql { companies(:first_firm).account }
assert sql_log.all? { |sql| !/order by/i.match?(sql) }, "ORDER BY was used in the query: #{sql_log}"
end