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 <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
This commit is contained in:
Jeremy Stanley 2012-06-13 10:07:37 -06:00
parent b988d4512c
commit ed471e5c7d
2 changed files with 14 additions and 1 deletions

View File

@ -210,7 +210,7 @@ class RubricAssociation < ActiveRecord::Base
# Go up to the assignment and loop through all submissions. # Go up to the assignment and loop through all submissions.
# Update each submission's assessment_requests with a link to this rubric association # Update each submission's assessment_requests with a link to this rubric association
# but only if not already associated and the assessment is incomplete. # 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| self.association.submissions.each do |sub|
sub.assessment_requests.incomplete.update_all(['rubric_association_id = ?', self.id], sub.assessment_requests.incomplete.update_all(['rubric_association_id = ?', self.id],
'rubric_association_id IS NULL') 'rubric_association_id IS NULL')

View File

@ -106,4 +106,17 @@ describe RubricAssociation do
end end
end 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 end