This commit is contained in:
John Hawthorn 2024-03-28 15:28:30 -07:00
Родитель 695104543c
Коммит d0bb0daeca
3 изменённых файлов: 23 добавлений и 8 удалений

Просмотреть файл

@ -1,7 +1,7 @@
source "https://rubygems.org"
gemspec
DEFAULT_RAILS_VERSION = '6.0.3.5'
DEFAULT_RAILS_VERSION = '7.1.3'
ENV['RAILS_VERSION'] ||= DEFAULT_RAILS_VERSION
if ENV['RAILS_VERSION'] == '4.2.10'

Просмотреть файл

@ -1,6 +1,5 @@
require "test_helper"
require "rails"
require "rails/test_help"
require "active_record"
require "rails/generators/test_case"
require "generators/github/ds/active_record_generator"

Просмотреть файл

@ -285,7 +285,7 @@ class GitHub::SQLTest < Minitest::Test
def test_add_doesnt_modify_timezone_if_early_return_invoked
begin
original_default_timezone = ActiveRecord::Base.default_timezone
original_default_timezone = get_default_timezone
refute_nil original_default_timezone
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS `repositories`")
@ -300,16 +300,16 @@ class GitHub::SQLTest < Minitest::Test
sql = GitHub::SQL.new("SELECT * FROM repositories WHERE id = ?", force_timezone: :local)
sql.add nil, id: 1
assert_equal original_default_timezone, ActiveRecord::Base.default_timezone
assert_equal original_default_timezone, get_default_timezone
ensure
ActiveRecord::Base.default_timezone = original_default_timezone
set_default_timezone = original_default_timezone
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS `repositories`")
end
end
def test_results_doesnt_modify_timezone_if_early_return_invoked
begin
original_default_timezone = ActiveRecord::Base.default_timezone
original_default_timezone = get_default_timezone
refute_nil original_default_timezone
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS `repositories`")
@ -325,12 +325,28 @@ class GitHub::SQLTest < Minitest::Test
sql.results
sql.results
assert_equal original_default_timezone, ActiveRecord::Base.default_timezone
assert_equal original_default_timezone, get_default_timezone
ensure
ActiveRecord::Base.default_timezone = original_default_timezone
set_default_timezone original_default_timezone
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS `repositories`")
end
end
def get_default_timezone
if ActiveRecord.respond_to?(:default_timezone)
ActiveRecord
else
ActiveRecord::Base
end.default_timezone
end
def set_default_timezone(value)
if ActiveRecord.respond_to?(:default_timezone)
ActiveRecord
else
ActiveRecord::Base
end.default_timezone = (value)
end
end
class GitHub::SQLModelTest < Minitest::Test