fix user quota calculation with no submission attachments
test plan: * create a new user * as the user, upload a new file to the user's folder * refresh the page * the quota should be updated close #CNVS-27064 Change-Id: Ic16b807428802f24b2dd502de25bdbd4902f6d82 Reviewed-on: https://gerrit.instructure.com/71606 Tested-by: Jenkins Reviewed-by: Jeremy Stanley <jeremy@instructure.com> QA-Review: Clare Strong <clare@instructure.com> Product-Review: Matt Fairbourn <mfairbourn@instructure.com>
This commit is contained in:
parent
31460a3f29
commit
6b8c1b13c9
|
@ -582,7 +582,7 @@ class Attachment < ActiveRecord::Base
|
|||
|
||||
if context.is_a?(User)
|
||||
excluded_attachment_ids = context.attachments.joins(:attachment_associations).where("attachment_associations.context_type = ?", "Submission").pluck(:id)
|
||||
attachment_scope = attachment_scope.where("id NOT IN (?)", excluded_attachment_ids)
|
||||
attachment_scope = attachment_scope.where("id NOT IN (?)", excluded_attachment_ids) if excluded_attachment_ids.any?
|
||||
end
|
||||
|
||||
min = self.minimum_size_for_quota
|
||||
|
|
|
@ -1251,6 +1251,9 @@ describe Attachment do
|
|||
attachment_model(:context => @user, :uploaded_data => stub_png_data, :filename => "homework.png")
|
||||
@attachment.update_attribute(:size, 1.megabyte)
|
||||
|
||||
quota = Attachment.get_quota(@user)
|
||||
expect(quota[:quota_used]).to eq 1.megabyte
|
||||
|
||||
@assignment = @course.assignments.create!
|
||||
sub = @assignment.submit_homework(@user, attachments: [@attachment])
|
||||
|
||||
|
|
Loading…
Reference in New Issue