parse dates on edit-section page

test plan:
 - go to course settings / sections tab, click a section,
   and click Edit
 - enter dates in various forms (such as M/D/YY), and ensure the
   small text below the box understands you correctly
 - submit the form, reload the page, and ensure the correct date
   was stored (1/2/15 is Jan 2, 2015 and not Feb 15, 1)

fixes CNVS-17564

Change-Id: Ie5da34937163419cb9bcb8368a05a079c77a25fb
Reviewed-on: https://gerrit.instructure.com/46540
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Willesen <jonw@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
Jeremy Stanley 2015-01-05 14:53:33 -07:00
parent 66d20740d8
commit ff7c929889
2 changed files with 20 additions and 0 deletions

View File

@ -33,6 +33,12 @@ define([
});
$edit_section_form.formSubmit({
processData: function(data) {
var start_at = $.datetime.parse(data['course_section[start_at]']);
var end_at = $.datetime.parse(data['course_section[end_at]']);
data['course_section[start_at]'] = start_at ? $.unfudgeDateForProfileTimezone(start_at).toISOString() : "";
data['course_section[end_at]'] = end_at ? $.unfudgeDateForProfileTimezone(end_at).toISOString() : "";
},
beforeSubmit: function(data) {
$edit_section_form.hide();
$edit_section_form.find(".name").text(data['course_section[name]']).show();

View File

@ -65,4 +65,18 @@ describe "course sections" do
wait_for_ajaximations
expect(f('#section_name')).to include_text(edit_name)
end
it "should parse dates" do
get "/courses/#{@course.id}/sections/#{@section.id}"
f('.edit_section_link').click
edit_form = f('#edit_section_form')
replace_content(edit_form.find_element(:id, 'course_section_start_at'), '1/2/15')
replace_content(edit_form.find_element(:id, 'course_section_end_at'), '04 Mar 2015')
submit_form(edit_form)
wait_for_ajax_requests
@section.reload
expect(@section.start_at).to eq(Date.new(2015, 1, 2))
expect(@section.end_at).to eq(Date.new(2015, 3, 4))
end
end