From ed471e5c7df004284321fdce21f87bd3d4e90acd Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Wed, 13 Jun 2012 10:07:37 -0600 Subject: [PATCH] don't try to link account rubrics to assessments; fixes #8864 testing steps: * try to create a rubric associated with an account (not a course or assignment) * it should work Change-Id: I98e7ed77b5ee4c4c6c7feb2557174d1edc052185 Reviewed-on: https://gerrit.instructure.com/11579 Tested-by: Jenkins Reviewed-by: Simon Williams --- app/models/rubric_association.rb | 2 +- spec/models/rubric_association_spec.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models/rubric_association.rb b/app/models/rubric_association.rb index df346387af9..1f3eb17b868 100644 --- a/app/models/rubric_association.rb +++ b/app/models/rubric_association.rb @@ -210,7 +210,7 @@ class RubricAssociation < ActiveRecord::Base # Go up to the assignment and loop through all submissions. # Update each submission's assessment_requests with a link to this rubric association # but only if not already associated and the assessment is incomplete. - if self.association_id + if self.association_id && self.association_type != 'Account' self.association.submissions.each do |sub| sub.assessment_requests.incomplete.update_all(['rubric_association_id = ?', self.id], 'rubric_association_id IS NULL') diff --git a/spec/models/rubric_association_spec.rb b/spec/models/rubric_association_spec.rb index b27daa35484..f02f3433f98 100644 --- a/spec/models/rubric_association_spec.rb +++ b/spec/models/rubric_association_spec.rb @@ -106,4 +106,17 @@ describe RubricAssociation do end end end + + context "when a rubric is associated with an account" do + it "should not try to link to assessments" do + site_admin_user + user_session(@user) + @account = @user.account + @rubric = @account.rubrics.build + rubric_params = HashWithIndifferentAccess.new({"title"=>"Some Rubric", "criteria"=>{"0"=>{"learning_outcome_id"=>"", "ratings"=>{"0"=>{"points"=>"5", "id"=>"blank", "description"=>"Full Marks"}, "1"=>{"points"=>"0", "id"=>"blank_2", "description"=>"No Marks"}}, "points"=>"5", "long_description"=>"", "id"=>"", "description"=>"Description of criterion"}}, "points_possible"=>"5", "free_form_criterion_comments"=>"0"}) + rubric_association_params = HashWithIndifferentAccess.new({:association=>@account, :hide_score_total=>"0", :use_for_grading=>"0", :purpose=>"bookmark"}) + #8864: the below raised a MethodNotFound error by trying to call @account.submissions + lambda { @rubric.update_with_association(@user, rubric_params, @account, rubric_association_params, nil) }.should_not raise_error + end + end end