Fix tests broken by twenty-four-hour-time feature.

(imported from commit 4f6215b303de8e27323141f687e046048f1456b5)
This commit is contained in:
Tim Abbott
2015-08-20 17:50:47 -07:00
parent b58867451d
commit 1880e96a22
3 changed files with 10 additions and 7 deletions

View File

@@ -1722,6 +1722,7 @@ def do_change_twenty_four_hour_time(user_profile, twenty_four_hour_time, log=Tru
user_profile.save(update_fields=["twenty_four_hour_time"])
event = {'type': 'update_display_settings',
'user': user_profile.email,
'setting_name': 'twenty_four_hour_time',
'setting': twenty_four_hour_time}
if log:
log_event(event)
@@ -2503,7 +2504,8 @@ def apply_events(state, events, user_profile):
elif event['type'] == "realm_filters":
state['realm_filters'] = event["realm_filters"]
elif event['type'] == "update_display_settings":
state['twenty_four_hour_time'] == event["twenty_four_hour_time"]
if event['setting_name'] == "twenty_four_hour_time":
state['twenty_four_hour_time'] = event["setting"]
else:
raise ValueError("Unexpected event type %s" % (event['type'],))

View File

@@ -438,12 +438,10 @@ class EventsRegisterTest(AuthedTestCase):
def test_change_twenty_four_hour_time(self):
schema_checker = check_dict([
('type', equals('update_display_settings')),
('op', equals('update')),
('person', check_dict([
('email', check_string),
('twenty_four_hour_time', check_bool),
])),
])
('setting_name', equals('twenty_four_hour_time')),
('user', check_string),
('setting', check_bool),
])
# The first False is probably a noop, then we get transitions in both directions.
for twenty_four_hour_time in [False, True, False]:
events = self.do_test(lambda: do_change_twenty_four_hour_time(self.user_profile, twenty_four_hour_time))

View File

@@ -7,6 +7,9 @@ add_dependencies({
util: 'js/util.js'
});
set_global('page_params', {
twenty_four_hour_time: false
});
set_global('home_msg_list', null);
set_global('feature_flags', {twenty_four_hour_time: false});
set_global('ui', {small_avatar_url: function () { return ''; }});