From 2fddd2bd717f36dc13829fa8b3a71fc1c26d2f08 Mon Sep 17 00:00:00 2001 From: Kevin Kim Date: Fri, 22 Jul 2016 09:28:19 -0400 Subject: [PATCH] Initial check of removing feature flag (#13058) --- .../tests/lms/test_account_settings.py | 28 +++++++++++++++ .../student_account/test/test_views.py | 36 ++++--------------- lms/djangoapps/student_account/views.py | 1 - lms/envs/bok_choy.py | 3 -- lms/envs/common.py | 3 -- .../account_settings_factory_spec.js | 1 - lms/static/js/spec/student_account/helpers.js | 9 +---- .../views/account_settings_factory.js | 1 - .../views/account_settings_view.js | 4 +-- lms/static/js/views/fields.js | 1 - 10 files changed, 36 insertions(+), 51 deletions(-) diff --git a/common/test/acceptance/tests/lms/test_account_settings.py b/common/test/acceptance/tests/lms/test_account_settings.py index 78a7389375..39984ce4e1 100644 --- a/common/test/acceptance/tests/lms/test_account_settings.py +++ b/common/test/acceptance/tests/lms/test_account_settings.py @@ -7,6 +7,8 @@ from nose.plugins.attrib import attr from bok_choy.web_app_test import WebAppTest from bok_choy.page_object import XSS_INJECTION +from datetime import datetime +from pytz import timezone, utc from ...pages.lms.account_settings import AccountSettingsPage from ...pages.lms.auto_auth import AutoAuthPage @@ -406,6 +408,32 @@ class AccountSettingsPageTest(AccountSettingsTestMixin, WebAppTest): [u'Pakistan', u'Palau'], ) + def test_time_zone_field(self): + """ + Test behaviour of "Time Zone" field + """ + kiev_abbr, kiev_offset = self._get_time_zone_info('Europe/Kiev') + pacific_abbr, pacific_offset = self._get_time_zone_info('US/Pacific') + self._test_dropdown_field( + u'time_zone', + u'Time Zone', + u'', + [ + u'Europe/Kiev ({abbr}, UTC{offset})'.format(abbr=kiev_abbr, offset=kiev_offset), + u'US/Pacific ({abbr}, UTC{offset})'.format(abbr=pacific_abbr, offset=pacific_offset), + ], + ) + + def _get_time_zone_info(self, time_zone_str): + """ + Helper that returns current time zone abbreviation and UTC offset + and accounts for daylight savings time + """ + time_zone = datetime.now(utc).astimezone(timezone(time_zone_str)) + abbr = time_zone.strftime('%Z') + offset = time_zone.strftime('%z') + return abbr, offset + def test_preferred_language_field(self): """ Test behaviour of "Preferred Language" field. diff --git a/lms/djangoapps/student_account/test/test_views.py b/lms/djangoapps/student_account/test/test_views.py index b47b02de0c..3fe25ae276 100644 --- a/lms/djangoapps/student_account/test/test_views.py +++ b/lms/djangoapps/student_account/test/test_views.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- """ Tests for student account views. """ -from copy import copy import re from unittest import skipUnless from urllib import urlencode @@ -462,9 +461,6 @@ class AccountSettingsViewTest(ThirdPartyAuthTestMixin, TestCase, ProgramsApiConf 'password', 'year_of_birth', 'preferred_language', - ] - - HIDDEN_FIELDS = [ 'time_zone', ] @@ -512,35 +508,15 @@ class AccountSettingsViewTest(ThirdPartyAuthTestMixin, TestCase, ProgramsApiConf self.assertEqual(context['auth']['providers'][0]['name'], 'Facebook') self.assertEqual(context['auth']['providers'][1]['name'], 'Google') - def test_hidden_fields_not_visible(self): + def test_view(self): """ - Test that hidden fields are not visible when disabled. + Test that all fields are visible """ - temp_features = copy(settings.FEATURES) - temp_features['ENABLE_TIME_ZONE_PREFERENCE'] = False - with self.settings(FEATURES=temp_features): - view_path = reverse('account_settings') - response = self.client.get(path=view_path) + view_path = reverse('account_settings') + response = self.client.get(path=view_path) - for attribute in self.FIELDS: - self.assertIn(attribute, response.content) - for attribute in self.HIDDEN_FIELDS: - self.assertIn('"%s": {"enabled": false' % (attribute), response.content) - - def test_hidden_fields_are_visible(self): - """ - Test that hidden fields are visible when enabled. - """ - temp_features = copy(settings.FEATURES) - temp_features['ENABLE_TIME_ZONE_PREFERENCE'] = True - with self.settings(FEATURES=temp_features): - view_path = reverse('account_settings') - response = self.client.get(path=view_path) - - for attribute in self.FIELDS: - self.assertIn(attribute, response.content) - for attribute in self.HIDDEN_FIELDS: - self.assertIn('"%s": {"enabled": true' % (attribute), response.content) + for attribute in self.FIELDS: + self.assertIn(attribute, response.content) def test_header_with_programs_listing_enabled(self): """ diff --git a/lms/djangoapps/student_account/views.py b/lms/djangoapps/student_account/views.py index 13edda3a8f..e93f704a8c 100644 --- a/lms/djangoapps/student_account/views.py +++ b/lms/djangoapps/student_account/views.py @@ -454,7 +454,6 @@ def account_settings_context(request): 'options': all_languages(), }, 'time_zone': { 'options': TIME_ZONE_CHOICES, - 'enabled': settings.FEATURES.get('ENABLE_TIME_ZONE_PREFERENCE'), } }, 'platform_name': get_themed_value('PLATFORM_NAME', settings.PLATFORM_NAME), diff --git a/lms/envs/bok_choy.py b/lms/envs/bok_choy.py index 047bf8d27b..cb742f4524 100644 --- a/lms/envs/bok_choy.py +++ b/lms/envs/bok_choy.py @@ -164,9 +164,6 @@ FEATURES['ENABLE_DASHBOARD_SEARCH'] = True # Enable support for OpenBadges accomplishments FEATURES['ENABLE_OPENBADGES'] = True -# Enable time zone field in account settings. Will be removed in Ticket #TNL-4750. -FEATURES['ENABLE_TIME_ZONE_PREFERENCE'] = True - # Use MockSearchEngine as the search engine for test scenario SEARCH_ENGINE = "search.tests.mock_search_engine.MockSearchEngine" # Path at which to store the mock index diff --git a/lms/envs/common.py b/lms/envs/common.py index 17822cffa3..7f853c298b 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -358,9 +358,6 @@ FEATURES = { # lives in the Extended table, saving the frontend from # making multiple queries. 'ENABLE_READING_FROM_MULTIPLE_HISTORY_TABLES': True, - - # WIP -- will be removed in Ticket #TNL-4750. - 'ENABLE_TIME_ZONE_PREFERENCE': False, } # Ignore static asset files on import which match this pattern diff --git a/lms/static/js/spec/student_account/account_settings_factory_spec.js b/lms/static/js/spec/student_account/account_settings_factory_spec.js index 67f2726f91..bd661cf30d 100644 --- a/lms/static/js/spec/student_account/account_settings_factory_spec.js +++ b/lms/static/js/spec/student_account/account_settings_factory_spec.js @@ -32,7 +32,6 @@ define(['backbone', 'options': Helpers.FIELD_OPTIONS }, 'time_zone': { 'options': Helpers.FIELD_OPTIONS, - 'enabled': false } }; diff --git a/lms/static/js/spec/student_account/helpers.js b/lms/static/js/spec/student_account/helpers.js index 5fb058454a..7cf34f8472 100644 --- a/lms/static/js/spec/student_account/helpers.js +++ b/lms/static/js/spec/student_account/helpers.js @@ -101,14 +101,7 @@ define(['underscore'], function(_) { if (fieldsAreRendered === false) { expect(sectionFieldElements.length).toBe(0); } else { - var visible_count = 0; - _.each(sectionsData[sectionIndex].fields, function(field) { - if (field.view.enabled) { - visible_count++; - } - }); - - expect(sectionFieldElements.length).toBe(visible_count); + expect(sectionFieldElements.length).toBe(sectionsData[sectionIndex].fields.length); _.each(sectionFieldElements, function (sectionFieldElement, fieldIndex) { expectElementContainsField(sectionFieldElement, sectionsData[sectionIndex].fields[fieldIndex]); diff --git a/lms/static/js/student_account/views/account_settings_factory.js b/lms/static/js/student_account/views/account_settings_factory.js index eab744e9c2..d8140c12e0 100644 --- a/lms/static/js/student_account/views/account_settings_factory.js +++ b/lms/static/js/student_account/views/account_settings_factory.js @@ -116,7 +116,6 @@ required: true, title: gettext('Time Zone'), valueAttribute: 'time_zone', - enabled: fieldsData.time_zone.enabled, helpMessage: gettext( 'Select the time zone for displaying course dates. If you do not specify a ' + 'time zone here, course dates, including assignment deadlines, are displayed in ' + diff --git a/lms/static/js/student_account/views/account_settings_view.js b/lms/static/js/student_account/views/account_settings_view.js index e4392f7e23..8b9f387e7f 100644 --- a/lms/static/js/student_account/views/account_settings_view.js +++ b/lms/static/js/student_account/views/account_settings_view.js @@ -68,9 +68,7 @@ _.each(view.$('.account-settings-section-body'), function (sectionEl, index) { _.each(view.options.tabSections[view.activeTab][index].fields, function (field) { - if (field.view.enabled) { - $(sectionEl).append(field.view.render().el); - } + $(sectionEl).append(field.view.render().el); }); }); return this; diff --git a/lms/static/js/views/fields.js b/lms/static/js/views/fields.js index 12fa5eef2d..f1c72dda76 100644 --- a/lms/static/js/views/fields.js +++ b/lms/static/js/views/fields.js @@ -82,7 +82,6 @@ this.helpMessage = this.options.helpMessage || ''; this.showMessages = _.isUndefined(this.options.showMessages) ? true : this.options.showMessages; - this.enabled = _.isUndefined(this.options.enabled) ? true: this.options.enabled; _.bindAll(this, 'modelValue', 'modelValueIsSet', 'showNotificationMessage','getNotificationMessage', 'getMessage', 'title', 'showHelpMessage', 'showInProgressMessage', 'showSuccessMessage',