fix unused courses reports to ignore deleted files

test plan
 - create a file in a course 
 - course should not show up in unused courses report
 - delete the file
 - course should show up in unused courses report

Change-Id: I0075fa039493192746d1201fa5e872a8b19861b4
Reviewed-on: https://gerrit.instructure.com/23273
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Adam Phillipps <adam@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
This commit is contained in:
Rob Orton 2013-08-13 12:45:27 -06:00
parent c36b0231dd
commit b3d9e566ce
2 changed files with 18 additions and 13 deletions

View File

@ -105,7 +105,7 @@ module Canvas::AccountReports
FROM attachments at
WHERE at.context_id = courses.id
AND at.context_type = 'Course'
AND at.workflow_state <> 'deleted')
AND at.file_state <> 'deleted')
AND NOT EXISTS (SELECT NULL
FROM discussion_topics d
WHERE d.context_id = courses.id

View File

@ -33,7 +33,7 @@ describe "Course Account Reports" do
@sub_account.sis_source_id = 'sub1'
@sub_account.save!
@term1 = EnrollmentTerm.create(:name => 'Fall',:start_at => 6.months.ago,
@term1 = EnrollmentTerm.create(:name => 'Fall', :start_at => 6.months.ago,
:end_at => 1.year.from_now)
@term1.root_account = @account
@term1.sis_source_id = 'fall12'
@ -41,15 +41,15 @@ describe "Course Account Reports" do
start_at = 1.day.ago
end_at = 3.months.from_now
@course1 = Course.new(:name => 'English 101',:course_code => 'ENG101',
:start_at => start_at,:conclude_at => end_at,
@course1 = Course.new(:name => 'English 101', :course_code => 'ENG101',
:start_at => start_at, :conclude_at => end_at,
:account => @sub_account, :enrollment_term => @term1)
@course1.sis_source_id = "SIS_COURSE_ID_1"
@course1.restrict_enrollments_to_course_dates = true
@course1.save!
@course2 = Course.new(:name => 'Math 101', :course_code => 'MAT101',
:conclude_at => end_at,:account => @account)
:conclude_at => end_at, :account => @account)
@course2.sis_source_id = "SIS_COURSE_ID_2"
@course2.save!
@course2.destroy
@ -60,11 +60,11 @@ describe "Course Account Reports" do
@course3.sis_source_id = "SIS_COURSE_ID_3"
@course3.save!
@course4 = Course.new(:name => 'self help',:course_code => 'self')
@course4 = Course.new(:name => 'self help', :course_code => 'self')
@course4.workflow_state = 'available'
@course4.save!
@course5 = Course.new(:name => 'talking 101',:course_code => 'Tal101')
@course5 = Course.new(:name => 'talking 101', :course_code => 'Tal101')
@course5.workflow_state = 'completed'
@course5.save!
end
@ -162,13 +162,18 @@ describe "Course Account Reports" do
it "should find courses with no active objects" do
@assignment.destroy
parsed = ReportSpecHelper.run_report(@account,@type,{},3)
parsed.length.should == 2
@attachment.destroy
parsed = ReportSpecHelper.run_report(@account, @type, {}, 3)
parsed.length.should == 3
parsed[0].should == [@course1.id.to_s, "SIS_COURSE_ID_1", "ENG101",
"English 101", "unpublished",
@course1.created_at.iso8601]
parsed[1].should == [@course6.id.to_s, nil, "THE01",
parsed[1].should == [@course3.id.to_s, "SIS_COURSE_ID_3", "SCI101",
"Science 101", "unpublished",
@course3.created_at.iso8601]
parsed[2].should == [@course6.id.to_s, nil, "THE01",
"Theology 101", "unpublished",
@course6.created_at.iso8601]
end
@ -177,7 +182,7 @@ describe "Course Account Reports" do
@wiki_page = @course6.wiki.wiki_pages.create(
:title => "Some random wiki page",
:body => "wiki page content")
parsed = ReportSpecHelper.run_report(@account,@type,{},3)
parsed = ReportSpecHelper.run_report(@account, @type, {}, 3)
parsed.length.should == 0
end
@ -190,7 +195,7 @@ describe "Course Account Reports" do
@course6.save
parameters = {}
parameters["enrollment_term_id"] = @term1.id
parsed = ReportSpecHelper.run_report(@account,@type,parameters,3)
parsed = ReportSpecHelper.run_report(@account, @type, parameters, 3)
parsed.length.should == 1
parsed[0].should == [@course6.id.to_s, nil, "THE01",
@ -206,7 +211,7 @@ describe "Course Account Reports" do
@course4.account = sub_account
@course4.save
@module.destroy
parsed = ReportSpecHelper.run_report(sub_account,@type,{},3)
parsed = ReportSpecHelper.run_report(sub_account, @type, {}, 3)
parsed.length.should == 1
parsed[0].should == [@course4.id.to_s, nil, "self",