Don't close modal on click outside new course update modal.

STUD-1404
This commit is contained in:
Waheed Ahmed
2014-03-07 19:31:49 +05:00
parent 2a149a8b89
commit f16efbb285
2 changed files with 16 additions and 3 deletions

View File

@@ -65,6 +65,19 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model
previewContents = @courseInfoEdit.$el.find('.update-contents').html()
expect(previewContents).not.toEqual('unsaved changes')
@doNotCloseNewCourseInfo = () ->
@courseInfoEdit.onNew(@event)
spyOn(@courseInfoEdit.$modalCover, 'hide').andCallThrough()
spyOn(@courseInfoEdit.$codeMirror, 'getValue').andReturn('unsaved changes')
model = @collection.at(0)
spyOn(model, "save").andCallThrough()
cancelEditingUpdate(@courseInfoEdit, @courseInfoEdit.$modalCover, false)
expect(model.save).not.toHaveBeenCalled()
expect(@courseInfoEdit.$modalCover.hide).not.toHaveBeenCalled()
@cancelExistingCourseInfo = (useCancelButton) ->
@createNewUpdate('existing update')
@courseInfoEdit.$el.find('.edit-button').click()
@@ -125,8 +138,8 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model
it "removes newly created course info on cancel", ->
@cancelNewCourseInfo(true)
it "removes newly created course info on click outside modal", ->
@cancelNewCourseInfo(false)
it "do not close new course info on click outside modal", ->
@doNotCloseNewCourseInfo()
it "does not remove existing course info on cancel", ->
@cancelExistingCourseInfo(true)

View File

@@ -64,7 +64,7 @@ define(["js/views/baseview", "underscore", "codemirror", "js/models/course_updat
// Variable stored for unit test.
this.$modalCover = ModalUtils.showModalCover(false, function() {
self.closeEditor(true)
// Binding empty function to prevent default hideModal.
});
$('.date').datepicker('destroy');