don't disallow deleting a section due to StudentViewEnrollments
fixes CNVS-2623 test plan: - create a course - create a section - use student view - delete the empty section - it should not give you a snarky message about you can't delete a section with enrollments Change-Id: Ieabf6dfa6c25eed7f637d529cd755490bde5635a Reviewed-on: https://gerrit.instructure.com/19120 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: James Williams <jamesw@instructure.com> QA-Review: Adam Phillipps <adam@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
parent
6d6319caf2
commit
cbe0907fb4
|
@ -213,7 +213,7 @@ class CourseSection < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def deletable?
|
||||
self.enrollments.count == 0
|
||||
self.enrollments.not_fake.count == 0
|
||||
end
|
||||
|
||||
def enroll_user(user, type, state='invited')
|
||||
|
|
|
@ -246,5 +246,26 @@ describe CourseSection, "moving to new course" do
|
|||
CourseAccountAssociation.find_all_by_course_id(course1.id).map(&:account_id).uniq.should == [account1.id]
|
||||
CourseAccountAssociation.find_all_by_course_id(course2.id).map(&:account_id).uniq.sort.should == [account1.id, account2.id].sort
|
||||
end
|
||||
|
||||
|
||||
describe 'deletable?' do
|
||||
before do
|
||||
course_with_teacher
|
||||
@section = course.course_sections.create!
|
||||
end
|
||||
|
||||
it 'should be deletable if empty' do
|
||||
@section.should be_deletable
|
||||
end
|
||||
|
||||
it 'should not be deletable if it has real enrollments' do
|
||||
student_in_course :section => @section
|
||||
@section.should_not be_deletable
|
||||
end
|
||||
|
||||
it 'should be deletable if it only has a student view enrollment' do
|
||||
@course.student_view_student
|
||||
@section.enrollments.map(&:type).should eql ['StudentViewEnrollment']
|
||||
@section.should be_deletable
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue