Skip to content

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

remove method that used to convert to tzinfo

ulferts92cc5a603e11
diff --git a/app/cells/settings/time_zone_setting_cell.rb b/app/cells/settings/time_zone_setting_cell.rb
index 344e9f99db7..3b9696f46a0 100644
--- a/app/cells/settings/time_zone_setting_cell.rb
+++ b/app/cells/settings/time_zone_setting_cell.rb
@@ -63,7 +63,7 @@ module Settings
end
# If there are multiple AS::TimeZones for a single TZInfo::Timezone, we
- # one return the one that is the namesake.
+ # only return the one that is the namesake.
def namesake_time_zone(time_zones)
if time_zones.length == 1
time_zones.first
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index 1eeab687538..c46442a6f30 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.rb
@@ -130,13 +130,6 @@ class UserPreference < ApplicationRecord
super.presence || [1, 2, 3, 4, 5]
end
- def canonical_time_zone
- return if time_zone.nil?
-
- zone = ActiveSupport::TimeZone.new(time_zone)
- zone&.tzinfo&.canonical_identifier
- end
-
private
def to_boolean(value)
diff --git a/lib/api/v3/user_preferences/user_preference_representer.rb b/lib/api/v3/user_preferences/user_preference_representer.rb
index c49585903dd..c34ed881258 100644
--- a/lib/api/v3/user_preferences/user_preference_representer.rb
+++ b/lib/api/v3/user_preferences/user_preference_representer.rb
@@ -57,7 +57,6 @@ module API
property :hide_mail
property :time_zone,
- getter: ->(*) { canonical_time_zone },
render_nil: true
property :warn_on_leaving_unsaved
diff --git a/spec/lib/api/v3/user_preferences/user_preference_representer_rendering_spec.rb b/spec/lib/api/v3/user_preferences/user_preference_representer_rendering_spec.rb
index d380f80df81..d105fc31e8d 100644
--- a/spec/lib/api/v3/user_preferences/user_preference_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/user_preferences/user_preference_representer_rendering_spec.rb
@@ -59,7 +59,7 @@ describe ::API::V3::UserPreferences::UserPreferenceRepresenter,
it { expect(subject).to have_json_path('autoHidePopups') }
describe 'timeZone' do
- context 'no time zone set' do
+ context 'without a timezone set' do
let(:preference) { FactoryBot.build(:user_preference, time_zone: '') }
it 'shows the timeZone as nil' do
@@ -67,15 +67,7 @@ describe ::API::V3::UserPreferences::UserPreferenceRepresenter,
end
end
- context 'short timezone set' do
- let(:preference) { FactoryBot.build(:user_preference, time_zone: 'Berlin') }
-
- it 'shows the canonical time zone' do
- expect(subject).to be_json_eql('Europe/Berlin'.to_json).at_path('timeZone')
- end
- end
-
- context 'canonical timezone set' do
+ context 'with a timezone set' do
let(:preference) { FactoryBot.build(:user_preference, time_zone: 'Europe/Paris') }
it 'shows the canonical time zone' do
diff --git a/spec/models/user_preference_spec.rb b/spec/models/user_preference_spec.rb
index f6ad4f4220d..68534f8fbff 100644
--- a/spec/models/user_preference_spec.rb
+++ b/spec/models/user_preference_spec.rb
@@ -165,20 +165,6 @@ describe UserPreference do
end
end
- describe 'time_zone' do
- it 'allows to save short time zones' do
- subject.time_zone = 'Berlin'
- expect(subject.time_zone).to eq('Berlin')
- expect(subject.canonical_time_zone).to eq('Europe/Berlin')
- end
-
- it 'allows to set full time zones' do
- subject.time_zone = 'Europe/Paris'
- expect(subject.time_zone).to eq('Europe/Paris')
- expect(subject.canonical_time_zone).to eq('Europe/Paris')
- end
- end
-
describe '[]=' do
let(:user) { FactoryBot.create(:user) }
diff --git a/spec/requests/api/v3/user_preferences/user_preferences_resource_spec.rb b/spec/requests/api/v3/user_preferences/user_preferences_resource_spec.rb
index e7f766251cc..ca794ad65e5 100644
--- a/spec/requests/api/v3/user_preferences/user_preferences_resource_spec.rb
+++ b/spec/requests/api/v3/user_preferences/user_preferences_resource_spec.rb
@@ -162,7 +162,7 @@ describe 'API v3 UserPreferences resource', type: :request, content_type: :json
end
end
- context 'with full time zone' do
+ context 'with valid time zone' do
let(:params) do
{ timeZone: 'Europe/Paris' }
end
@@ -172,18 +172,6 @@ describe 'API v3 UserPreferences resource', type: :request, content_type: :json
expect(preference.time_zone).to eq('Europe/Paris')
end
end
-
- context 'with short time zone' do
- let(:params) do
- { timeZone: 'Hawaii' }
- end
-
- it 'responds with a UserPreferences representer' do
- expect(subject.body).to be_json_eql('Pacific/Honolulu'.to_json).at_path('timeZone')
- expect(preference.time_zone).to eq('Hawaii')
- expect(preference.canonical_time_zone).to eq('Pacific/Honolulu')
- end
- end
end
end
end