Skip to content

Commit

Permalink
test to find the prefix/suffix leak
Browse files Browse the repository at this point in the history
  • Loading branch information
BuonOmo committed Sep 25, 2023
1 parent ace5fbd commit bf1ae57
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/cases/migration/foreign_key_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,21 +284,25 @@ def change

def test_add_foreign_key_with_prefix
ActiveRecord::Base.table_name_prefix = "p_"
puts "\n--t--1A: setting prefix"
migration = CreateSchoolsAndClassesMigration.new
silence_stream($stdout) { migration.migrate(:up) }
silence_stream(StringIO.new) { migration.migrate(:up) }
assert_equal 1, @connection.foreign_keys("p_classes").size
ensure
silence_stream($stdout) { migration.migrate(:down) }
silence_stream(StringIO.new) { migration.migrate(:down) }
ActiveRecord::Base.table_name_prefix = nil
puts "\n--t--1B: setting prefix"
end

def test_add_foreign_key_with_suffix
ActiveRecord::Base.table_name_suffix = "_s"
puts "\n--t--2A: setting suffix"
migration = CreateSchoolsAndClassesMigration.new
silence_stream($stdout) { migration.migrate(:up) }
silence_stream(StringIO.new) { migration.migrate(:up) }
assert_equal 1, @connection.foreign_keys("classes_s").size
ensure
silence_stream($stdout) { migration.migrate(:down) }
silence_stream(StringIO.new) { migration.migrate(:down) }
puts "\n--t--2B: unsetting suffix"
ActiveRecord::Base.table_name_suffix = nil
end

Expand Down

0 comments on commit bf1ae57

Please sign in to comment.