Allow Sync to SIS icon to toggle without name length setting on

Fixes: SIS-2837

Test plan:
- Navigate to the Account settings page
- ONLY check the `SIS syncing` option and none of the sub
  settings below it
- Save the settings
- Navigate to a Course
- Create an Assignment without the `Post to SIS` option checked
- On the Assignment Index page check the `Sync to SIS` icon
- Confirm the icon turns the `Post to SIS` option on and no
  warning message pops up telling you to make sure the name of
  the assignment isn't too long

Change-Id: I11db81d37d22c8d3640a6583680b2266548f80ee
Reviewed-on: https://gerrit.instructure.com/109168
Tested-by: Jenkins
Reviewed-by: Brad Humphrey <brad@instructure.com>
QA-Review: Mark McDermott <mmcdermott@instructure.com>
Product-Review: Oxana
This commit is contained in:
Nick Houle 2017-04-19 17:38:46 -06:00
parent 25f97d5620
commit 4086d4087b
13 changed files with 57 additions and 9 deletions

View File

@ -322,6 +322,9 @@ define [
maxNameLength: =>
return ENV.MAX_NAME_LENGTH
maxNameLengthRequiredForAccount: =>
return ENV.MAX_NAME_LENGTH_REQUIRED_FOR_ACCOUNT
dueDateRequiredForAccount: =>
return ENV.DUE_DATE_REQUIRED_FOR_ACCOUNT

View File

@ -157,6 +157,9 @@ define [
maxNameLength: =>
return ENV.MAX_NAME_LENGTH
maxNameLengthRequiredForAccount: =>
return ENV.MAX_NAME_LENGTH_REQUIRED_FOR_ACCOUNT
dueDateRequiredForAccount: =>
return ENV.DUE_DATE_REQUIRED_FOR_ACCOUNT

View File

@ -5,12 +5,19 @@ define [], ->
constructor: (params) ->
@postToSIS = params['postToSIS']
@dueDateRequired = params['dueDateRequired']
@maxNameLengthRequired = params['maxNameLengthRequired']
@dueDate = params['dueDate']
@modelName = params['name']
@maxNameLength = params['maxNameLength']
nameTooLong: ->
return false unless @postToSIS
if @maxNameLengthRequired
@nameLengthComparison()
else if !@maxNameLengthRequired && @maxNameLength == 256
@nameLengthComparison()
nameLengthComparison: ->
@modelName.length > @maxNameLength
dueDateMissing: ->

View File

@ -391,6 +391,7 @@ define [
postToSIS: post_to_sis
maxNameLength: max_name_length
name: data.title
maxNameLengthRequired: ENV.MAX_NAME_LENGTH_REQUIRED_FOR_ACCOUNT
})
if validationHelper.nameTooLong()

View File

@ -22,6 +22,11 @@ define [
# is required
@optionProperty 'dueDateRequired'
# {boolean}
# boolean used to determine if name length
# is required
@optionProperty 'maxNameLengthRequired'
setAttributes: ->
newSisAttributes = @sisAttributes()
@$input.attr({
@ -41,6 +46,7 @@ define [
dueDate: @model.dueAt()
name: @model.name()
maxNameLength: @model.maxNameLength()
maxNameLengthRequired: @maxNameLengthRequired
})
errors = @errorsExist(validationHelper)
if errors['has_error'] == true && @model.sisIntegrationSettingsEnabled()

View File

@ -106,7 +106,11 @@ define [
saveURL: -> "#{ENV.URLS.assignment_sort_base_url}/#{@parentListView.value()}/reorder"
if @isGraded() && @model.postToSISEnabled() && @model.published()
@sisButtonView = new SisButtonView(model: @model, sisName: @model.postToSISName(), dueDateRequired: @model.dueDateRequiredForAccount())
@sisButtonView = new SisButtonView
model: @model
sisName: @model.postToSISName()
dueDateRequired: @model.dueDateRequiredForAccount()
maxNameLengthRequired: @model.maxNameLengthRequiredForAccount()
@dateDueColumnView = new DateDueColumnView(model: @model)
@dateAvailableColumnView = new DateAvailableColumnView(model: @model)

View File

@ -148,6 +148,7 @@ define [
postToSIS: post_to_sis
maxNameLength: max_name_length
name: data.name
maxNameLengthRequired: ENV.MAX_NAME_LENGTH_REQUIRED_FOR_ACCOUNT
})
if !data.name or $.trim(data.name.toString()).length == 0

View File

@ -484,6 +484,7 @@ define [
postToSIS: post_to_sis
maxNameLength: max_name_length
name: data.name
maxNameLengthRequired: ENV.MAX_NAME_LENGTH_REQUIRED_FOR_ACCOUNT
})
if !data.name or $.trim(data.name.toString()).length == 0

View File

@ -57,8 +57,12 @@ define [
content_id: @model.get('id'),
content_type: 'quiz'
})
if @model.postToSISEnabled() && @model.postToSIS() != null && @model.attributes.published
@sisButtonView = new SisButtonView(model: @model, sisName: @model.postToSISName(), dueDateRequired: @model.dueDateRequiredForAccount())
if @model.postToSIS() != null && @model.attributes.published
@sisButtonView = new SisButtonView
model: @model
sisName: @model.postToSISName()
dueDateRequired: @model.dueDateRequiredForAccount()
maxNameLengthRequired: @model.maxNameLengthRequiredForAccount()
@dateDueColumnView = new DateDueColumnView(model: @model)
@dateAvailableColumnView = new DateAvailableColumnView(model: @model)

View File

@ -107,6 +107,7 @@ class Quizzes::QuizzesController < ApplicationController
max_name_length = AssignmentUtil.assignment_max_name_length(@context)
sis_name = AssignmentUtil.post_to_sis_friendly_name(@context)
due_date_required_for_account = AssignmentUtil.due_date_required_for_account?(@context)
max_name_length_required_for_account = AssignmentUtil.name_length_required_for_account?(@context)
sis_integration_settings_enabled = AssignmentUtil.sis_integration_settings_enabled?(@context)
hash = {
@ -135,6 +136,7 @@ class Quizzes::QuizzesController < ApplicationController
:SIS_NAME => sis_name,
:MAX_NAME_LENGTH => max_name_length,
:DUE_DATE_REQUIRED_FOR_ACCOUNT => due_date_required_for_account,
:MAX_NAME_LENGTH_REQUIRED_FOR_ACCOUNT => max_name_length_required_for_account,
:SIS_INTEGRATION_SETTINGS_ENABLED => sis_integration_settings_enabled
}
if @context.is_a?(Course) && @context.grants_right?(@current_user, session, :read)

View File

@ -28,7 +28,8 @@ define [
model: new AssignmentStub()
postToSIS: true
name: 'Too Much Tuna'
maxNameLength: 5)
maxNameLength: 5,
maxNameLengthRequired: true)
ok @helper.nameTooLong()
test 'nameTooLong returns false if name is too long AND postToSIS is false', ->
@ -36,7 +37,8 @@ define [
model: new AssignmentStub()
postToSIS: false
name: 'Too Much Tuna'
maxNameLength: 5)
maxNameLength: 5,
maxNameLengthRequired: false)
ok !@helper.nameTooLong()
test 'dueDateMissing returns true if dueAt is null AND postToSIS is true', ->

View File

@ -86,7 +86,7 @@ define [
ENV.SIS_INTEGRATION_SETTINGS_ENABLED = true
@assignment.set('post_to_sis', false)
@assignment.set('name', 'Too Much Tuna')
@view = new SisButtonView(model: @assignment)
@view = new SisButtonView(model: @assignment, maxNameLengthRequired: true)
@view.render()
@view.$el.click()
ok !@assignment.postToSIS()
@ -96,7 +96,7 @@ define [
ENV.SIS_INTEGRATION_SETTINGS_ENABLED = false
@assignment.set('post_to_sis', false)
@assignment.set('name', 'Too Much Tuna')
@view = new SisButtonView(model: @assignment)
@view = new SisButtonView(model: @assignment, maxNameLengthRequired: false)
@view.render()
@view.$el.click()
ok @assignment.postToSIS()
@ -106,7 +106,7 @@ define [
ENV.SIS_INTEGRATION_SETTINGS_ENABLED = true
@quiz.set('post_to_sis', false)
@quiz.set('title', 'Too Much Tuna')
@view = new SisButtonView(model: @quiz)
@view = new SisButtonView(model: @quiz, maxNameLengthRequired: true)
@view.render()
@view.$el.click()
ok !@quiz.postToSIS()
@ -116,7 +116,7 @@ define [
ENV.SIS_INTEGRATION_SETTINGS_ENABLED = false
@quiz.set('post_to_sis', false)
@quiz.set('title', 'Too Much Tuna')
@view = new SisButtonView(model: @quiz)
@view = new SisButtonView(model: @quiz, maxNameLengthRequired: false)
@view.render()
@view.$el.click()
ok @quiz.postToSIS()

View File

@ -158,6 +158,20 @@ describe Quizzes::QuizzesController do
get 'index', :course_id => @course.id
expect(assigns[:js_env][:DUE_DATE_REQUIRED_FOR_ACCOUNT]).to eq(false)
end
it "js_env MAX_NAME_LENGTH_REQUIRED_FOR_ACCOUNT is true when AssignmentUtil.name_length_required_for_account? == true" do
user_session(@teacher)
AssignmentUtil.stubs(:name_length_required_for_account?).returns(true)
get 'index', :course_id => @course.id
expect(assigns[:js_env][:MAX_NAME_LENGTH_REQUIRED_FOR_ACCOUNT]).to eq(true)
end
it "js_env MAX_NAME_LENGTH_REQUIRED_FOR_ACCOUNT is false when AssignmentUtil.name_length_required_for_account? == false" do
user_session(@teacher)
AssignmentUtil.stubs(:name_length_required_for_account?).returns(false)
get 'index', :course_id => @course.id
expect(assigns[:js_env][:MAX_NAME_LENGTH_REQUIRED_FOR_ACCOUNT]).to eq(false)
end
end
describe "GET 'new'" do