allow appointment groups in soft-concluded courses to be managed

this permission was unintentionally taken away by the combination
of g/72384 and g/74637, but the `manageable_by` scope still
includes these courses, resulting in appointment groups visible
on a course admin's page that cannot be interacted with

test plan:
 - ensure a teacher can still manage an appointment group
   in a course that is soft-concluded (the end date is past and
   "Users can only participate in the course between these dates"
   is checked in course settings)
 - ensure an appointment group covering multiple courses can
   be managed by a teacher who is only enrolled in one of these
   courses (regression test g/74637)
 - ensure an appointment group covering multiple courses can
   be managed by a teacher who is enrolled in all of them, but
   one of them is hard-concluded (regression test g/72384)

fixes CNVS-29474

Change-Id: I02123eb5f8e7dc5ced82f14a31d8fd7576872ae8
Reviewed-on: https://gerrit.instructure.com/80806
Tested-by: Jenkins
Reviewed-by: Joel Hough <joel@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
Jeremy Stanley 2016-05-26 15:14:18 -06:00
parent 39fcc0a092
commit ca6050ae16
2 changed files with 13 additions and 3 deletions

View File

@ -39,7 +39,7 @@ class AppointmentGroup < ActiveRecord::Base
end
def active_contexts
contexts.reject { |context| context.workflow_state == 'deleted' || context.concluded? }
contexts.reject { |context| context.workflow_state == 'deleted' }
end
def sub_contexts

View File

@ -328,11 +328,21 @@ describe AppointmentGroup do
expect(@g8.reload.grants_right?(@teacher2, :manage)).to be_truthy
end
it "should ignore concluded courses when performing permissions checks" do
it "should give :manage permission even if some contexts are concluded" do
@course3.complete!
expect(@g8.active_contexts).not_to include @course3
expect(@g8.reload.grants_right?(@teacher2, :manage)).to be_truthy
end
it "should not give :manage permission if all contexts are (hard-)concluded" do
@course2.complete!
@course3.complete!
expect(@g8.reload.grants_right?(@teacher2, :manage)).to be_falsey
end
it "should give :manage permission if a context is soft-concluded" do
@course.soft_conclude!
expect(@g1.reload.grants_right?(@teacher, :manage)).to be_truthy
end
end
context "notifications" do