Skip to content

Commit

Permalink
Fix flaky tests:
Browse files Browse the repository at this point in the history
- Some tests modify the `ActiveRecord.default_timezone` which
  has an influence on column information. It used to work before
  because the type (.e.g Type::DateTime) was not included in the
  Column object. Now that the type is included and that a Column
  is cached, we'd grab whatever type was in the cached column.

  So we have to force a reloading of the schema cache in order
  for whenver `ActiveRecord.default_timezone` is modified.
  • Loading branch information
Edouard-chin committed Jan 26, 2025
1 parent 1b58366 commit 23abfb6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions activerecord/test/cases/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1982,4 +1982,12 @@ def test_protected_environments_are_stored_as_an_array_of_string
assert_not ActiveRecord::Base.current_preventing_writes
end
end

private
def with_timezone_config(cfg, &block)
super(cfg) do
Default.reset_column_information
block.call
end
end
end

0 comments on commit 23abfb6

Please sign in to comment.