Skip to content

Remove workarounds for old Rubies #1299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1948,19 +1948,6 @@ class SchemaCacheTest < ActiveRecord::TestCase
# Tests fail on Windows AppVeyor CI with 'Permission denied' error when renaming file during `File.atomic_write` call.
coerce_tests! :test_yaml_dump_and_load, :test_yaml_dump_and_load_with_gzip if RbConfig::CONFIG["host_os"] =~ /mswin|mingw/

# Ruby 2.5 and 2.6 have issues to marshal Time before 1900. 2012.sql has one column with default value 1753
coerce_tests! :test_marshal_dump_and_load_with_gzip, :test_marshal_dump_and_load_via_disk

# Tests fail on Windows AppVeyor CI with 'Permission denied' error when renaming file during `File.atomic_write` call.
unless RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
def test_marshal_dump_and_load_with_gzip_coerced
with_marshable_time_defaults { original_test_marshal_dump_and_load_with_gzip }
end
def test_marshal_dump_and_load_via_disk_coerced
with_marshable_time_defaults { original_test_marshal_dump_and_load_via_disk }
end
end

# Cast type in SQL Server is :varchar rather than Unicode :string.
coerce_tests! :test_yaml_load_8_0_dump_without_cast_type_still_get_the_right_one
def test_yaml_load_8_0_dump_without_cast_type_still_get_the_right_one
Expand All @@ -1977,25 +1964,6 @@ def test_yaml_load_8_0_dump_without_cast_type_still_get_the_right_one

private

def with_marshable_time_defaults
# Detect problems
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.7")
column = @connection.columns(:sst_datatypes).find { |c| c.name == "datetime" }
current_default = column.default if column.default.is_a?(Time) && column.default.year < 1900
end

# Correct problems
if current_default.present?
@connection.change_column_default(:sst_datatypes, :datetime, current_default.dup.change(year: 1900))
end

# Run original test
yield
ensure
# Revert changes
@connection.change_column_default(:sst_datatypes, :datetime, current_default) if current_default.present?
end

# We need to give the full paths for this to work.
undef_method :schema_dump_5_1_path
def schema_dump_5_1_path
Expand Down
Loading