adds validation for name to assignment quick add
fixes CNVS-9495 test plan: - with draft state enabled - from assignment index page as a teacher - click quick add button for assignment - save without title - verify that the error message renders - also verify that you can save assignment with a title from quick add window Change-Id: If7359af56656b9e3dd6a33b9db9d6638c8b3f175 Reviewed-on: https://gerrit.instructure.com/26281 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Cameron Matheson <cameron@instructure.com> QA-Review: Caleb Guanzon <cguanzon@instructure.com> Product-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
parent
12077de92d
commit
9b2d4e36b3
|
@ -4,9 +4,10 @@ define [
|
|||
'compiled/views/DialogFormView'
|
||||
'jst/assignments/CreateAssignment'
|
||||
'jst/EmptyDialogFormWrapper'
|
||||
'i18n!assignments'
|
||||
'jquery'
|
||||
'jquery.instructure_date_and_time'
|
||||
], (_, Assignment, DialogFormView, template, wrapper, $) ->
|
||||
], (_, Assignment, DialogFormView, template, wrapper, I18n, $) ->
|
||||
|
||||
class CreateAssignmentView extends DialogFormView
|
||||
defaults:
|
||||
|
@ -88,3 +89,16 @@ define [
|
|||
|
||||
newAssignmentUrl: ->
|
||||
ENV.URLS.new_assignment_url
|
||||
|
||||
validateBeforeSave: (data, errors) ->
|
||||
errors = @_validateTitle data, errors
|
||||
errors
|
||||
|
||||
_validateTitle: (data, errors) ->
|
||||
frozenTitle = _.contains(@model.frozenAttributes(), "title")
|
||||
|
||||
if !frozenTitle and (!data.name or $.trim(data.name.toString()).length == 0)
|
||||
errors["name"] = [
|
||||
message: I18n.t 'name_is_required', 'Name is required!'
|
||||
]
|
||||
errors
|
|
@ -17,6 +17,9 @@ define [
|
|||
assignment2 = ->
|
||||
new Assignment(buildAssignment2())
|
||||
|
||||
assignment3 = ->
|
||||
new Assignment(buildAssignment3())
|
||||
|
||||
buildAssignment1 = ->
|
||||
date1 =
|
||||
"due_at":"2013-08-28T23:59:00-06:00"
|
||||
|
@ -44,6 +47,15 @@ define [
|
|||
"position":2
|
||||
)
|
||||
|
||||
buildAssignment3 = ->
|
||||
buildAssignment(
|
||||
"id":4
|
||||
"name":""
|
||||
"due_at":"2013-08-23T23:59:00-06:00"
|
||||
"points_possible":10
|
||||
"position":3
|
||||
)
|
||||
|
||||
buildAssignment = (options) ->
|
||||
options ?= {}
|
||||
|
||||
|
@ -82,6 +94,7 @@ define [
|
|||
setup: ->
|
||||
@assignment1 = assignment1()
|
||||
@assignment2 = assignment2()
|
||||
@assignment3 = assignment3()
|
||||
@group = assignmentGroup()
|
||||
|
||||
test "initialize generates a new assignment for creation", ->
|
||||
|
@ -191,3 +204,12 @@ define [
|
|||
$.fn.datetime_field.restore()
|
||||
DialogFormView.prototype.openAgain.restore()
|
||||
|
||||
test "requires name to save assignment", ->
|
||||
view = createView(@assignment3)
|
||||
data =
|
||||
name: ""
|
||||
errors = view.validateBeforeSave(data, [])
|
||||
|
||||
ok errors["name"]
|
||||
equal errors["name"].length, 1
|
||||
equal errors["name"][0]["message"], "Name is required!"
|
Loading…
Reference in New Issue