forked from capability-boosters-dev/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
localized-timezone-lists_spec.rb
45 lines (39 loc) · 1.68 KB
/
localized-timezone-lists_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#
# Copyright (C) 2017 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas 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 Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Rails.root.join('app', 'jsx', 'shared', 'components', 'TimeZoneSelect', 'localized-timezone-lists') do
it("each json file should match ruby data for that locale") do
def localized_timezones(zones)
zones.map { |tz| {name: tz.name, localized_name: tz.to_s} }
end
subject.mkpath
I18n.available_locales.each do |locale|
I18n.locale = locale
zones_for_this_locale = {
priority_zones: localized_timezones(I18nTimeZone.us_zones),
timezones: localized_timezones(I18nTimeZone.all)
}.as_json
file_for_this_locale = subject.join("#{locale}.json")
file_for_this_locale.write(zones_for_this_locale.to_json) # uncomment this line if you need to update json files with current data
expect(JSON.parse(file_for_this_locale.read)).to(
eq(zones_for_this_locale),
"you need to uncomment the line above and run this spec again to update #{file_for_this_locale}"
)
end
end
end