Skip to content

Commit bc8517c

Browse files
committed
fix tooltip times on Syllabus page when user/browser tz don't match
test plan: - in your user profile, change your time zone to something different from your system time zone - hover over due dates and calendar event times and ensure the Course and Local times are correct (the Local time should match the time in the table) - also ensure that events are collated based on the local timezone, not the course timezone (that is, an assignment that is due on October 20 in the course timezone, but October 21 in the local timezone, should appear in a row with left-side heading of October 21). fixes CNVS-17781 Change-Id: I73d5b758807251cb6b8c547534f4c07b44b72b79 Reviewed-on: https://gerrit.instructure.com/46792 Reviewed-by: Jacob Fugal <jacob@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Clare Strong <clare@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
1 parent bddd219 commit bc8517c

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

app/coffeescripts/handlebars_helpers.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ define [
7474
new Handlebars.SafeString "<time data-tooltip data-html-tooltip-title='#{htmlEscape timeTitle}' datetime='#{datetime.toISOString()}' #{$.raw('pubdate' if pubdate)}>#{$.friendlyDatetime(fudged)}</time>"
7575

7676

77+
fudge: (datetime) ->
78+
$.fudgeDateForProfileTimezone(datetime)
79+
80+
unfudge: (datetime) ->
81+
$.unfudgeDateForProfileTimezone(datetime)
7782

7883
# expects: a Date object or an ISO string
7984
formattedDate : (datetime, format, {hash: {pubdate}}) ->

app/views/jst/courses/Syllabus.handlebars

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
<td class="dates{{#unless last}} not_last{{/unless}}">
4444
{{#if start_at}}
4545
{{#if due_at}}
46-
due by <span {{contextSensitiveDatetimeTitle due_at}} >{{tTimeHours due_at}}</span>
46+
due by <span {{contextSensitiveDatetimeTitle (unfudge due_at)}} >{{tTimeHours due_at}}</span>
4747
{{else}}
48-
<span {{contextSensitiveDatetimeTitle start_at}} >{{tTimeHours start_at}}</span>
48+
<span {{contextSensitiveDatetimeTitle (unfudge start_at)}} >{{tTimeHours start_at}}</span>
4949
{{#unless same_time}}
5050
to
51-
<span {{contextSensitiveDatetimeTitle end_at}} >
51+
<span {{contextSensitiveDatetimeTitle (unfudge end_at)}} >
5252
{{#if same_day}}
5353
{{tTimeHours end_at}}
5454
{{else}}

spec/coffeescripts/views/SyllabusViewSpec.coffee

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ define [
2121
'underscore'
2222
'timezone'
2323
'vendor/timezone/America/Denver'
24+
'vendor/timezone/America/New_York'
2425
'compiled/behaviors/SyllabusBehaviors'
2526
'compiled/collections/SyllabusCollection'
2627
'compiled/collections/SyllabusCalendarEventsCollection'
@@ -29,7 +30,7 @@ define [
2930
'spec/javascripts/compiled/views/SyllabusViewPrerendered'
3031
'helpers/fakeENV'
3132
'helpers/jquery.simulate'
32-
], ($, _, tz, denver, SyllabusBehaviors, SyllabusCollection, SyllabusCalendarEventsCollection, SyllabusAppointmentGroupsCollection, SyllabusView, SyllabusViewPrerendered, fakeENV) ->
33+
], ($, _, tz, denver, newYork, SyllabusBehaviors, SyllabusCollection, SyllabusCalendarEventsCollection, SyllabusAppointmentGroupsCollection, SyllabusView, SyllabusViewPrerendered, fakeENV) ->
3334

3435
setupServerResponses = ->
3536
server = sinon.fakeServer.create()
@@ -76,12 +77,13 @@ define [
7677

7778
module 'Syllabus',
7879
setup: ->
79-
fakeENV.setup()
80+
fakeENV.setup(TIMEZONE: 'America/Denver', CONTEXT_TIMEZONE: 'America/New_York')
8081
# Setup stubs/mocks
8182
@server = setupServerResponses()
8283

8384
@tzSnapshot = tz.snapshot()
8485
tz.changeZone(denver, 'America/Denver')
86+
tz.preload("America/New_York", newYork)
8587

8688
@clock = sinon.useFakeTimers(new Date(2012, 0, 23, 15, 30).getTime())
8789

@@ -147,7 +149,7 @@ define [
147149
SyllabusBehaviors.bindToSyllabus()
148150

149151
renderAssertions: ->
150-
expect 15
152+
expect 19
151153

152154
# rendering
153155
syllabus = $('#syllabus')
@@ -193,6 +195,15 @@ define [
193195
equal expected.length, 2, 'passed events - passed events found'
194196
deepEqual actual.toArray(), expected.toArray(), 'passed events - events before today marked as passed'
195197

198+
# context-sensitive datetime titles
199+
assignment_ts = $('.events_2012_01_01 .related-assignment_1 .dates > span:nth-child(1)')
200+
equal assignment_ts.text(), "10am", "assignment - local time in table"
201+
equal assignment_ts.data('html-tooltip-title'), "Local: Jan 1 at 10:00am<br>Course: Jan 1 at 12:00pm", 'assignment - correct local and course times given'
202+
203+
event_ts = $('.events_2012_01_01 .related-appointment_group_1 .dates > span:nth-child(1)')
204+
equal event_ts.text(), " 8am", "event - local time in table"
205+
equal event_ts.data('html-tooltip-title'), "Local: Jan 1 at 8:00am<br>Course: Jan 1 at 10:00am", 'event - correct local and course times given'
206+
196207
test 'render (user public course)', ->
197208
@view.can_read = true # public course -- can read
198209
@view.is_valid_user = true # user - enrolled (can read)

0 commit comments

Comments
 (0)