mirror of
https://github.com/zulip/zulip.git
synced 2026-07-15 21:03:26 +08:00
events: Fix timezone realm-time sync and add test.
This commit is contained in:
parent
86e3d1effc
commit
2b905d242d
@ -153,9 +153,8 @@ def fetch_initial_state_data(user_profile, event_types, queue_id,
|
||||
state['twenty_four_hour_time'] = user_profile.twenty_four_hour_time
|
||||
state['left_side_userlist'] = user_profile.left_side_userlist
|
||||
state['emoji_alt_code'] = user_profile.emoji_alt_code
|
||||
|
||||
default_language = user_profile.default_language
|
||||
state['default_language'] = default_language
|
||||
state['timezone'] = user_profile.timezone
|
||||
state['default_language'] = user_profile.default_language
|
||||
|
||||
if want('update_global_notifications'):
|
||||
state['enable_stream_desktop_notifications'] = user_profile.enable_stream_desktop_notifications
|
||||
@ -386,6 +385,8 @@ def apply_event(state, event, user_profile, include_subscribers):
|
||||
state['emoji_alt_code'] = event["setting"]
|
||||
if event['setting_name'] == 'default_language':
|
||||
state['default_language'] = event["setting"]
|
||||
if event['setting_name'] == 'timezone':
|
||||
state['timezone'] = event["setting"]
|
||||
elif event['type'] == "update_global_notifications":
|
||||
if event['notification_name'] == "enable_stream_desktop_notifications":
|
||||
state['enable_stream_desktop_notifications'] = event['setting']
|
||||
|
||||
@ -32,6 +32,7 @@ from zerver.lib.actions import (
|
||||
do_change_is_admin,
|
||||
do_change_stream_description,
|
||||
do_change_subscription_property,
|
||||
do_change_timezone,
|
||||
do_create_user,
|
||||
do_deactivate_stream,
|
||||
do_deactivate_user,
|
||||
@ -936,6 +937,19 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
error = schema_checker('events[0]', events[0])
|
||||
self.assert_on_error(error)
|
||||
|
||||
def test_change_timezone(self):
|
||||
# type: () -> None
|
||||
schema_checker = check_dict([
|
||||
('type', equals('update_display_settings')),
|
||||
('setting_name', equals('timezone')),
|
||||
('user', check_string),
|
||||
('setting', check_string),
|
||||
])
|
||||
for setting_value in ['US/Mountain', 'US/Samoa', 'Pacific/Galapagos', '']:
|
||||
events = self.do_test(lambda: do_change_timezone(self.user_profile, setting_value))
|
||||
error = schema_checker('events[0]', events[0])
|
||||
self.assert_on_error(error)
|
||||
|
||||
def test_change_enable_stream_desktop_notifications(self):
|
||||
# type: () -> None
|
||||
schema_checker = check_dict([
|
||||
|
||||
Loading…
Reference in New Issue
Block a user