fix for empty create group dialog
fixes CNVS-9490 trigger render event on the collection so that we don't accidentally re-render the entire IndexView test plan ========= with draft state enabled: - navigate to the assignments index page and edit an assignment group from the gear menu - click the button to add a new assignment group - verify that the modal has a form in it and that a new assignment group can be added Change-Id: I877dc6daddfcb4a2b6f67dfd862dc2cb5328bcc3 Reviewed-on: https://gerrit.instructure.com/26420 Reviewed-by: Simon Williams <simon@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Caleb Guanzon <cguanzon@instructure.com> Product-Review: Matthew Irish <mirish@instructure.com>
This commit is contained in:
parent
00f3fbd82b
commit
c250957a4c
|
@ -60,6 +60,7 @@ define [
|
|||
attachCollection: ->
|
||||
super
|
||||
@itemViewOptions = course: @course
|
||||
@collection.on 'render', @render
|
||||
@collection.on 'add', @render
|
||||
@collection.on 'remove', @render
|
||||
@collection.on 'change:groupWeights', @render
|
||||
|
|
|
@ -41,14 +41,17 @@ define [
|
|||
|
||||
onSaveSuccess: ->
|
||||
super
|
||||
if @assignmentGroup # meaning we are editing
|
||||
@model.collection.view.render()
|
||||
# meaning we are editing
|
||||
if @assignmentGroup
|
||||
# trigger instead of calling render directly
|
||||
@model.collection.trigger 'render', @model.collection
|
||||
else
|
||||
@assignmentGroups.add(@model)
|
||||
@model = new AssignmentGroup(assignments: [])
|
||||
|
||||
@render()
|
||||
|
||||
|
||||
getFormData: ->
|
||||
data = super
|
||||
delete data.rules.drop_lowest if _.contains(["", "0"], data.rules.drop_lowest)
|
||||
|
|
|
@ -17,10 +17,12 @@ define [
|
|||
assignmentGroups = ->
|
||||
@groups = new AssignmentGroupCollection([group(), group()])
|
||||
|
||||
createView = ->
|
||||
view = new CreateGroupView
|
||||
createView = (hasAssignmentGroup=true)->
|
||||
args =
|
||||
assignmentGroups: assignmentGroups()
|
||||
assignmentGroup: @groups.first()
|
||||
assignmentGroup: @groups.first() if hasAssignmentGroup
|
||||
|
||||
view = new CreateGroupView(args)
|
||||
|
||||
module 'CreateGroupView'
|
||||
|
||||
|
@ -59,3 +61,18 @@ define [
|
|||
errors = view.validateFormData(data)
|
||||
ok errors
|
||||
equal _.keys(errors).length, 1
|
||||
|
||||
|
||||
test 'it should trigger a render event on save success when editing', ->
|
||||
triggerSpy = sinon.spy(AssignmentGroupCollection::, 'trigger')
|
||||
view = createView()
|
||||
view.onSaveSuccess()
|
||||
ok triggerSpy.calledWith 'render'
|
||||
triggerSpy.restore()
|
||||
|
||||
test 'it should call render on save success if adding an assignmentGroup', ->
|
||||
view = createView(false)
|
||||
renderStub = sinon.stub(view, 'render')
|
||||
calls = renderStub.callCount
|
||||
view.onSaveSuccess()
|
||||
equal renderStub.callCount, calls + 1
|
||||
|
|
Loading…
Reference in New Issue