OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Group timezones in select, when they use the same canonical id
Klaus Zanders07e29b72fa0a
diff --git a/app/components/settings/time_zone_setting_component.rb b/app/components/settings/time_zone_setting_component.rbindex 906d2139a16..c38027834c9 100644--- a/app/components/settings/time_zone_setting_component.rb+++ b/app/components/settings/time_zone_setting_component.rb@@ -72,9 +72,18 @@ module Settingsdef time_zone_entriesUserPreferences::UpdateContract.assignable_time_zones- .map do |tz|- [tz.to_s, tz.tzinfo.canonical_identifier]- end+ .group_by { |tz| tz.tzinfo.canonical_zone }+ .map { |canonical_zone, included_zones| time_zone_option(canonical_zone, included_zones) }+ end++ private++ def time_zone_option(canonical_zone, zones)+ zone_names = zones.map(&:name).join(', ')+ [+ "(UTC#{ActiveSupport::TimeZone.seconds_to_utc_offset(canonical_zone.base_utc_offset)}) #{zone_names}",+ canonical_zone.identifier+ ]endendenddiff --git a/spec/components/settings/time_zone_setting_component_spec.rb b/spec/components/settings/time_zone_setting_component_spec.rbnew file mode 100644index 00000000000..1450fa1c08a--- /dev/null+++ b/spec/components/settings/time_zone_setting_component_spec.rb@@ -0,0 +1,44 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require "rails_helper"++RSpec.describe Settings::TimeZoneSettingComponent, type: :component do+ subject { render_inline(described_class.new("user_default_timezone")) }++ it "renders the timezones as options, grouping cities with the same identifier" do+ subject++ expect(page).to have_selector("option[value=\"America/Los_Angeles\"]",+ text: "(UTC-08:00) Pacific Time (US & Canada)")+ expect(page).to have_selector("option[value=\"Europe/Berlin\"]", text: "(UTC+01:00) Berlin, Copenhagen, Stockholm")+ expect(page).to have_selector("option[value=\"Asia/Shanghai\"]", text: "(UTC+08:00) Beijing, Chongqing")+ end+end