Skip to content

Commit 524b2c0

Browse files
aidanharanAidan Haran
and
Aidan Haran
authored
Coerce and reimplement test (#931)
Delete records that were created as part of test before adding index back Fix test Co-authored-by: Aidan Haran <[email protected]>
1 parent 3c89b8e commit 524b2c0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,7 @@ def test_statement_cache_values_differ_coerced
15211521

15221522
original_test_statement_cache_values_differ
15231523
ensure
1524+
Book.where(author_id: nil, name: 'my book').delete_all
15241525
Book.connection.add_index(:books, [:author_id, :name], unique: true)
15251526
end
15261527
end
@@ -1748,6 +1749,7 @@ class EnumTest < ActiveRecord::TestCase
17481749

17491750
send(:'original_enums are distinct per class')
17501751
ensure
1752+
Book.where(author_id: nil, name: nil).delete_all
17511753
Book.connection.add_index(:books, [:author_id, :name], unique: true)
17521754
end
17531755

@@ -1758,6 +1760,7 @@ class EnumTest < ActiveRecord::TestCase
17581760

17591761
send(:'original_creating new objects with enum scopes')
17601762
ensure
1763+
Book.where(author_id: nil, name: nil).delete_all
17611764
Book.connection.add_index(:books, [:author_id, :name], unique: true)
17621765
end
17631766

@@ -1768,6 +1771,7 @@ class EnumTest < ActiveRecord::TestCase
17681771

17691772
send(:'original_enums are inheritable')
17701773
ensure
1774+
Book.where(author_id: nil, name: nil).delete_all
17711775
Book.connection.add_index(:books, [:author_id, :name], unique: true)
17721776
end
17731777

@@ -1778,6 +1782,7 @@ class EnumTest < ActiveRecord::TestCase
17781782

17791783
send(:'original_declare multiple enums at a time')
17801784
ensure
1785+
Book.where(author_id: nil, name: nil).delete_all
17811786
Book.connection.add_index(:books, [:author_id, :name], unique: true)
17821787
end
17831788
end
@@ -1843,6 +1848,14 @@ class LogSubscriberTest < ActiveRecord::TestCase
18431848
def test_vebose_query_logs_coerced
18441849
original_test_vebose_query_logs
18451850
end
1851+
1852+
# Bindings logged slightly differently.
1853+
coerce_tests! :test_where_in_binds_logging_include_attribute_names
1854+
def test_where_in_binds_logging_include_attribute_names_coerced
1855+
Developer.where(id: [1, 2, 3, 4, 5]).load
1856+
wait
1857+
assert_match(%{@0 = 1, @1 = 2, @2 = 3, @3 = 4, @4 = 5 [["id", nil], ["id", nil], ["id", nil], ["id", nil], ["id", nil]]}, @logger.logged(:debug).last)
1858+
end
18461859
end
18471860

18481861
class ActiveRecordSchemaTest < ActiveRecord::TestCase

0 commit comments

Comments
 (0)