Skip to content

Commit

Permalink
don't load all contexts for group recipient lookup
Browse files Browse the repository at this point in the history
fixes CNVS-18578

test plan
quauntitative functionality test
- regression test recipient picker when picking in groups

qualitative speed test
- have a high enrollment user with normally slow response times
 during conversation recipient finding
- compose a conversation message
- search for recipients in a group using the dropdown recipient
 picker
- ensure that the response time for the recipient is not as bad
 as it was

Change-Id: Ie7655544f93d1168ac78f0b1497c1bec9f0319c6
Reviewed-on: https://gerrit.instructure.com/49395
Tested-by: Jenkins
Reviewed-by: Matthew Wheeler <mwheeler@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Joel Hough <joel@instructure.com>
  • Loading branch information
JoelHough committed Mar 5, 2015
1 parent b19f89d commit df718ff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/helpers/search_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def load_all_contexts(options = {})
end
add_sections.call sections
add_groups.call context.groups.active, context
elsif context.is_a?(Group)
if context.grants_right?(@current_user, session, :read)
add_groups.call [context]
add_courses.call [context.context], :current if context.context.is_a?(Course)
end
elsif context.is_a?(CourseSection)
visibility = context.course.enrollment_visibility_level_for(@current_user, context.course.section_visibilities_for(@current_user), true)
sections = (visibility == :restricted) ? [] : [context]
Expand Down
12 changes: 12 additions & 0 deletions spec/helpers/search_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
expect(@contexts[:sections].count).to eq 1
end

it "only loads the group and its course when given a group context" do
course_with_teacher(:active_all => true)
course_with_teacher(:active_all => true, :user => @teacher)
@current_user = @teacher
group_model(context: @course)
load_all_contexts(context: @group)

expect(@contexts[:courses].count).to eq 1
expect(@contexts[:groups].count).to eq 1
expect(@contexts[:sections].count).to eq 0
end

it "loads the section even with section-restricted teacher privileges" do
course_with_teacher(:active_all => true, :limit_privileges_to_course_section => true)
@current_user = @teacher
Expand Down

0 comments on commit df718ff

Please sign in to comment.