specify timezone and locale via ENV
and use them to initialize tz() during the common bundle Change-Id: I0aa8215d4e83514be3ec2e5e1450df42185b8c83 Reviewed-on: https://gerrit.instructure.com/24674 Reviewed-by: Braden Anderson <banderson@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> Product-Review: Jacob Fugal <jacob@instructure.com> QA-Review: Jacob Fugal <jacob@instructure.com>
This commit is contained in:
parent
6105631c8d
commit
1d8e7adf33
|
@ -6,6 +6,7 @@ require [
|
|||
'compiled/widget/courseList'
|
||||
'compiled/helpDialog'
|
||||
'compiled/tours'
|
||||
'timezone'
|
||||
|
||||
# modules that do their own thing on every page that simply need to
|
||||
# be required
|
||||
|
@ -49,7 +50,7 @@ require [
|
|||
'vendor/jquery.pageless'
|
||||
'vendor/jquery.scrollTo'
|
||||
'compiled/badge_counts'
|
||||
], ($, Backbone, courseList, helpDialog, tours) ->
|
||||
], ($, Backbone, courseList, helpDialog, tours, tz) ->
|
||||
courseList.init()
|
||||
helpDialog.initTriggers()
|
||||
tours.init()
|
||||
|
@ -74,3 +75,7 @@ require [
|
|||
event.preventDefault()
|
||||
Backbone.history.navigate $(this).attr('href'), yes
|
||||
|
||||
##
|
||||
# Set up timezone
|
||||
tz.changeZone(ENV.TIMEZONE)
|
||||
tz.changeLocale(ENV.LOCALE.replace('-', '_'))
|
||||
|
|
|
@ -120,6 +120,8 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
@js_env[:IS_LARGE_ROSTER] = true if !@js_env[:IS_LARGE_ROSTER] && @context.respond_to?(:large_roster?) && @context.large_roster?
|
||||
@js_env[:context_asset_string] = @context.try(:asset_string) if !@js_env[:context_asset_string]
|
||||
@js_env[:TIMEZONE] = Time.zone.tzinfo.identifier if !@js_env[:TIMEZONE]
|
||||
@js_env[:LOCALE] = I18n.qualified_locale if !@js_env[:LOCALE]
|
||||
@js_env
|
||||
end
|
||||
helper_method :js_env
|
||||
|
|
|
@ -34,6 +34,13 @@ describe ApplicationController do
|
|||
controller.js_env[:files_domain].should == 'files.example.com'
|
||||
end
|
||||
|
||||
it "should auto-set timezone and locale" do
|
||||
I18n.locale = :fr
|
||||
Time.zone = 'Alaska'
|
||||
@controller.js_env[:LOCALE].should == 'fr-FR'
|
||||
@controller.js_env[:TIMEZONE].should == 'America/Juneau'
|
||||
end
|
||||
|
||||
it "should allow multiple items" do
|
||||
controller.js_env :A => 'a', :B => 'b'
|
||||
controller.js_env[:A].should == 'a'
|
||||
|
|
Loading…
Reference in New Issue