Update PacePlanModuleItem to verify module_item assignment
fixes LS-2772 flag=pace_plans test plan: - Create a course with a module containing a variety of things. Make sure some are graded assignments like a graded discussion and some are not graded like a practice quiz or a wiki page. - Go to the pace plans index and verify that the module items shown only include assignments from the modules that can be graded. Change-Id: I32d95c15489f15d68e132f7f012ba2e76d88d76a Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/276429 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Jeremy Stanley <jeremy@instructure.com> QA-Review: Jeremy Stanley <jeremy@instructure.com> Product-Review: Eric Saupe <eric.saupe@instructure.com>
This commit is contained in:
parent
03ff06699f
commit
c5b6a1fa4d
|
@ -36,7 +36,7 @@ class PacePlanModuleItem < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
|
|
||||||
def assignable_module_item
|
def assignable_module_item
|
||||||
unless module_item&.can_have_assignment?
|
unless module_item&.assignment
|
||||||
self.errors.add(:module_item, 'is not assignable')
|
self.errors.add(:module_item, 'is not assignable')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,10 +74,14 @@ describe PacePlanModuleItem do
|
||||||
end
|
end
|
||||||
|
|
||||||
context "validation" do
|
context "validation" do
|
||||||
it "requires the module item to be assignable" do
|
it "requires the module item to have an assignment" do
|
||||||
quiz = @course.quizzes.create!
|
quiz = @course.quizzes.create!
|
||||||
quiz_tag = @mod2.add_item id: quiz.id, type: 'quiz'
|
quiz_tag = @mod2.add_item id: quiz.id, type: 'quiz'
|
||||||
header_tag = @mod2.add_item type: 'context_module_sub_header', title: 'not an assignment'
|
header_tag = @mod2.add_item type: 'context_module_sub_header', title: 'not an assignment'
|
||||||
|
expect(@pace_plan.pace_plan_module_items.build(module_item: quiz_tag)).not_to be_valid
|
||||||
|
expect(@pace_plan.pace_plan_module_items.build(module_item: header_tag)).not_to be_valid
|
||||||
|
quiz.save! # Save again to create associated assignment
|
||||||
|
quiz_tag.reload
|
||||||
expect(@pace_plan.pace_plan_module_items.build(module_item: quiz_tag)).to be_valid
|
expect(@pace_plan.pace_plan_module_items.build(module_item: quiz_tag)).to be_valid
|
||||||
expect(@pace_plan.pace_plan_module_items.build(module_item: header_tag)).not_to be_valid
|
expect(@pace_plan.pace_plan_module_items.build(module_item: header_tag)).not_to be_valid
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue