exclude deleted group memberships in User#groups

test plan:
 - create an account-level group
 - put some calendar events in it
 - add a student to it
 - remove the student from it
 - confirm events from the group do not appear in the student's
   "Coming Up" list on the dashboard

fixes CNVS-32755

Change-Id: I093d5b99953c110fc30115598e5e76fdbd4cca5c
Reviewed-on: https://gerrit.instructure.com/93621
Reviewed-by: James Williams  <jamesw@instructure.com>
Tested-by: Jenkins
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
Jeremy Stanley 2016-10-25 13:38:51 -06:00
parent f65c48777a
commit 806a1bcb6c
1 changed files with 1 additions and 1 deletions

View File

@ -63,7 +63,7 @@ class User < ActiveRecord::Base
has_many :observed_users, :through => :user_observees, :source => :user
has_many :all_courses, :source => :course, :through => :enrollments
has_many :group_memberships, -> { preload(:group) }, dependent: :destroy
has_many :groups, :through => :group_memberships
has_many :groups, -> { where("group_memberships.workflow_state<>'deleted'") }, :through => :group_memberships
has_many :polls, class_name: 'Polling::Poll'
has_many :current_group_memberships, -> { eager_load(:group).where("group_memberships.workflow_state = 'accepted' AND groups.workflow_state<>'deleted'") }, class_name: 'GroupMembership'