diff --git a/app/models/pace_plan_module_item.rb b/app/models/pace_plan_module_item.rb index ab4c608e996..eb0ef1b8e83 100644 --- a/app/models/pace_plan_module_item.rb +++ b/app/models/pace_plan_module_item.rb @@ -36,7 +36,7 @@ class PacePlanModuleItem < ActiveRecord::Base } def assignable_module_item - unless module_item&.can_have_assignment? + unless module_item&.assignment self.errors.add(:module_item, 'is not assignable') end end diff --git a/spec/models/pace_plan_module_item_spec.rb b/spec/models/pace_plan_module_item_spec.rb index 300ab237ede..ee1f762592f 100644 --- a/spec/models/pace_plan_module_item_spec.rb +++ b/spec/models/pace_plan_module_item_spec.rb @@ -74,10 +74,14 @@ describe PacePlanModuleItem do end 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_tag = @mod2.add_item id: quiz.id, type: 'quiz' 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: header_tag)).not_to be_valid end