Skip to content
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

Allow utc_to_local_returns_utc_offset_times to be set in new_framework_defaults_6_1.rb #38863

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion activesupport/CHANGELOG.md
Expand Up @@ -18,7 +18,7 @@

This changes the output of `ActiveSupport::TimeZone.utc_to_local`, but
can be controlled with the
`Rails.application.config.active_support.utc_to_local_returns_utc_offset_times` config.
`ActiveSupport.utc_to_local_returns_utc_offset_times` config.

New Rails 6.1 apps have it enabled by default, existing apps can upgrade
via the config in config/initializers/new_framework_defaults_6_1.rb
Expand Down
4 changes: 1 addition & 3 deletions railties/lib/rails/application/configuration.rb
Expand Up @@ -179,9 +179,7 @@ def load_defaults(target_version)
action_dispatch.cookies_same_site_protection = :lax
end

if respond_to?(:active_support)
active_support.utc_to_local_returns_utc_offset_times = true
end
ActiveSupport.utc_to_local_returns_utc_offset_times = true
else
raise "Unknown version #{target_version.to_s.inspect}"
end
Expand Down
Expand Up @@ -24,4 +24,4 @@

# Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an
# UTC offset or a UTC time.
# Rails.application.config.active_support.utc_to_local_returns_utc_offset_times = true
# ActiveSupport.utc_to_local_returns_utc_offset_times = true
26 changes: 24 additions & 2 deletions railties/test/application/configuration_test.rb
Expand Up @@ -2295,13 +2295,35 @@ class ::DummySerializer < ActiveJob::Serializers::ObjectSerializer; end
assert_equal :lax, Rails.application.config.action_dispatch.cookies_same_site_protection
end

test "enables utc_to_local_returns_utc_offset_times by default" do
test "ActiveSupport.utc_to_local_returns_utc_offset_times is true in 6.1 defaults" do
remove_from_config '.*config\.load_defaults.*\n'
add_to_config 'config.load_defaults "6.1"'

app "development"

assert_equal true, Rails.application.config.active_support.utc_to_local_returns_utc_offset_times
assert_equal true, ActiveSupport.utc_to_local_returns_utc_offset_times
end

test "ActiveSupport.utc_to_local_returns_utc_offset_times is false in 6.0 defaults" do
remove_from_config '.*config\.load_defaults.*\n'
add_to_config 'config.load_defaults "6.0"'

app "development"

assert_equal false, ActiveSupport.utc_to_local_returns_utc_offset_times
end

test "ActiveSupport.utc_to_local_returns_utc_offset_times can be configured in an initializer" do
remove_from_config '.*config\.load_defaults.*\n'
add_to_config 'config.load_defaults "6.0"'

app_file "config/initializers/new_framework_defaults_6_1.rb", <<-RUBY
ActiveSupport.utc_to_local_returns_utc_offset_times = true
RUBY

app "development"

assert_equal true, ActiveSupport.utc_to_local_returns_utc_offset_times
end

test "ActiveStorage.queues[:analysis] is :active_storage_analysis by default" do
Expand Down