From 0b1d1a3e312c1b5745680ba18ce94a3be962b6ef Mon Sep 17 00:00:00 2001 From: James Williams Date: Thu, 11 May 2017 07:48:21 -0600 Subject: [PATCH] don't include rejected teachers in account course list test plan: * create a course and invite a teacher * reject the invitation * the rejected user should not show in the list of "Teachers" on the account-level course list closes #CNVS-36830 Change-Id: I1ced8d37631aed1208c4781507abb090b3290443 Reviewed-on: https://gerrit.instructure.com/111472 Tested-by: Jenkins Reviewed-by: Jeremy Stanley QA-Review: David Tan Product-Review: James Williams --- app/controllers/accounts_controller.rb | 2 +- spec/controllers/accounts_controller_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 73d0e769b6c..77d246214bd 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -1007,7 +1007,7 @@ class AccountsController < ApplicationController end end - teachers = TeacherEnrollment.for_courses_with_user_name(courses_to_fetch_users_for).admin.active + teachers = TeacherEnrollment.for_courses_with_user_name(courses_to_fetch_users_for).admin.where.not(:enrollments => {:workflow_state => %w{rejected deleted}}) course_to_student_counts = StudentEnrollment.student_in_claimed_or_available.where(:course_id => courses_to_fetch_users_for).group(:course_id).distinct.count(:user_id) courses_to_teachers = teachers.inject({}) do |result, teacher| result[teacher.course_id] ||= [] diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index 16140fcf188..0dca42b2e42 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -244,6 +244,18 @@ describe AccountsController do end + it "should not list rejected teachers" do + account_with_admin_logged_in + course_with_teacher(:account => @account) + @teacher2 = User.create(:name => "rejected") + reject = @course.enroll_user(@teacher2, "TeacherEnrollment") + reject.reject! + + get 'show', :id => @account.id, :format => 'html' + + expect(assigns[:courses].find {|c| c.id == @course.id }.teacher_names).to eq [@teacher.name] + end + it "should sort courses as specified" do account_with_admin_logged_in(account: @account) course_with_teacher(:account => @account)