don't allow setting assignment or group positions to nil
also fix the grade summary page if any existing rows have null positions test plan: * use the assignments API to try to update an assignment to have a blank/null position * it should not save the change closes #LA-139 Change-Id: I9a3e26a41dad328defa763c5f9c8f9697ed5a4c5 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/216204 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Tested-by: Jenkins QA-Review: Jeremy Stanley <jeremy@instructure.com> Product-Review: James Williams <jamesw@instructure.com> Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
parent
17cb63df31
commit
61c6a42125
|
@ -873,6 +873,7 @@ class Assignment < ActiveRecord::Base
|
||||||
self.title ||= (self.assignment_group.default_assignment_name rescue nil) || "Assignment"
|
self.title ||= (self.assignment_group.default_assignment_name rescue nil) || "Assignment"
|
||||||
|
|
||||||
self.infer_all_day
|
self.infer_all_day
|
||||||
|
self.position = self.position_was if self.will_save_change_to_position? && self.position.nil? # don't allow setting to nil
|
||||||
|
|
||||||
if !self.assignment_group || (self.assignment_group.deleted? && !self.deleted?)
|
if !self.assignment_group || (self.assignment_group.deleted? && !self.deleted?)
|
||||||
ensure_assignment_group(false)
|
ensure_assignment_group(false)
|
||||||
|
|
|
@ -67,6 +67,7 @@ class AssignmentGroup < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
self.default_assignment_name = self.name
|
self.default_assignment_name = self.name
|
||||||
self.default_assignment_name = self.default_assignment_name.singularize if I18n.locale == :en
|
self.default_assignment_name = self.default_assignment_name.singularize if I18n.locale == :en
|
||||||
|
self.position = self.position_was if self.will_save_change_to_position? && self.position.nil? # don't allow setting to nil
|
||||||
end
|
end
|
||||||
protected :generate_default_values
|
protected :generate_default_values
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ class GradeSummaryPresenter
|
||||||
when :module
|
when :module
|
||||||
sorted_by_modules(assignments)
|
sorted_by_modules(assignments)
|
||||||
when :assignment_group
|
when :assignment_group
|
||||||
assignments.sort_by { |a| [a.assignment_group.position, a.position] }
|
assignments.sort_by { |a| [a.assignment_group.position, a.position].map{|p| p || CanvasSort::Last} }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3191,6 +3191,14 @@ describe AssignmentsApiController, type: :request do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should not be able to update position to nil" do
|
||||||
|
@assignment = @course.assignments.create!
|
||||||
|
json = api_update_assignment_call(@course, @assignment, {'position' => ''})
|
||||||
|
@assignment.reload
|
||||||
|
expect(json['position']).to eq 1
|
||||||
|
expect(@assignment.position).to eq 1
|
||||||
|
end
|
||||||
|
|
||||||
it "should process html content in description on update" do
|
it "should process html content in description on update" do
|
||||||
@assignment = @course.assignments.create!
|
@assignment = @course.assignments.create!
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue