Skip to content

Commit fbdd206

Browse files
jensengzwily
authored andcommitted
fix group count bug
Change-Id: Ia9ca6ba4217785445c474e0a5128c0b9cc72dc4d Reviewed-on: https://gerrit.instructure.com/5369 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Zach Wily <zach@instructure.com>
1 parent 187d124 commit fbdd206

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

app/controllers/conversations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def can_add_notes_to?(course)
263263
def matching_contexts(search, exclude = [])
264264
avatar_url = avatar_url_for_group(true)
265265
course_user_counts = @current_user.enrollment_visibility[:user_counts]
266-
group_user_counts = @contexts[:groups].inject({}){ |hash, group| hash[group.id] = group.users.size; hash }
266+
group_user_counts = @current_user.groups.inject({}){ |hash, group| hash[group.id] = group.users.size; hash }
267267
@contexts.values.map(&:values).flatten.
268268
select{ |context| search.downcase.strip.split(/\s+/).all?{ |part| context[:name].downcase.include?(part) } }.
269269
select{ |context| context[:active] }.

spec/controllers/conversations_controller_spec.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,20 @@ def conversation(num_other_users = 1)
243243
describe "GET 'find_recipients'" do
244244
it "should assign variables" do
245245
course_with_student_logged_in(:active_all => true)
246-
other = User.create(:name => 'testuser')
246+
@course.update_attribute(:name, "this_is_a_test_course")
247+
248+
other = User.create(:name => 'this_is_a_test_user')
247249
enrollment = @course.enroll_student(other)
248250
enrollment.workflow_state = 'active'
249251
enrollment.save
250252

251-
get 'find_recipients', :search => other.name
253+
group = @course.groups.create(:name => 'this_is_a_test_group')
254+
group.users = [@user, other]
255+
256+
get 'find_recipients', :search => 'this_is_a_test_'
252257
response.should be_success
258+
response.body.should include(@course.name)
259+
response.body.should include(group.name)
253260
response.body.should include(other.name)
254261
end
255262
end

0 commit comments

Comments
 (0)