Handle offset relative to TZ in options list (#39334)
This commit is contained in:
parent
a2064d4c7f
commit
e9697922c1
@ -57,6 +57,10 @@ module SettingsHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def time_zone_options
|
||||||
|
ActiveSupport::TimeZone.all.map { |tz| ["(GMT#{tz.now.formatted_offset}) #{tz.name}", tz.tzinfo.name] }
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def links_for_featured_tags(tags)
|
def links_for_featured_tags(tags)
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
wrapper: :with_label
|
wrapper: :with_label
|
||||||
.fields-group.fields-row__column.fields-row__column-6
|
.fields-group.fields-row__column.fields-row__column-6
|
||||||
= f.input :time_zone,
|
= f.input :time_zone,
|
||||||
collection: ActiveSupport::TimeZone.all.map { |tz| ["(GMT#{tz.formatted_offset}) #{tz.name}", tz.tzinfo.name] },
|
collection: time_zone_options,
|
||||||
hint: false,
|
hint: false,
|
||||||
selected: current_user.time_zone || Time.zone.tzinfo.name,
|
selected: current_user.time_zone || Time.zone.tzinfo.name,
|
||||||
wrapper: :with_label
|
wrapper: :with_label
|
||||||
|
|||||||
@ -50,4 +50,20 @@ RSpec.describe SettingsHelper do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#time_zone_options' do
|
||||||
|
subject { helper.time_zone_options }
|
||||||
|
|
||||||
|
context 'when summer time is in effect' do
|
||||||
|
before { travel_to(Date.new(2026, 6, 1)) }
|
||||||
|
|
||||||
|
it { is_expected.to include(['(GMT-08:00) Alaska', 'America/Juneau']) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when summer time is not in effect' do
|
||||||
|
before { travel_to(Date.new(2025, 12, 1)) }
|
||||||
|
|
||||||
|
it { is_expected.to include(['(GMT-09:00) Alaska', 'America/Juneau']) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user