From 9fed93281f3671b7a178a4e16ca5f4d3d42c83de Mon Sep 17 00:00:00 2001 From: ashercodeorg Date: Wed, 1 Mar 2017 12:52:15 -0600 Subject: [PATCH 1/2] Fix bug in student counting. --- dashboard/app/controllers/transfers_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/app/controllers/transfers_controller.rb b/dashboard/app/controllers/transfers_controller.rb index da2066006905f..a06896b1513a1 100644 --- a/dashboard/app/controllers/transfers_controller.rb +++ b/dashboard/app/controllers/transfers_controller.rb @@ -80,7 +80,7 @@ def create return end - if student_ids.count != current_user.followers.where(student_user_id: student_ids).count + if student_ids.count != current_user.followers.where(section_id: current_section.id, student_user_id: student_ids).count render json: { error: I18n.t('move_students.all_students_must_be_in_current_section') }, status: :forbidden From 6b42e018dce63cd76fc57105e666cc217c6ca188 Mon Sep 17 00:00:00 2001 From: ashercodeorg Date: Wed, 1 Mar 2017 15:10:19 -0600 Subject: [PATCH 2/2] Fix (pre-existing) broken tests. --- dashboard/test/controllers/transfers_controller_test.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dashboard/test/controllers/transfers_controller_test.rb b/dashboard/test/controllers/transfers_controller_test.rb index c87fc3d4ac06d..45a1b9b1cda3e 100644 --- a/dashboard/test/controllers/transfers_controller_test.rb +++ b/dashboard/test/controllers/transfers_controller_test.rb @@ -11,7 +11,7 @@ class TransfersControllerTest < ActionController::TestCase @word_user_1 = create(:follower, section: @word_section).student_user @picture_section = create(:section, user: @teacher, login_type: 'picture') - @picture_user_1 = create(:follower, section: @word_section).student_user + @picture_user_1 = create(:follower, section: @picture_section).student_user end test "returns an error when student ids are not provided" do @@ -155,7 +155,7 @@ class TransfersControllerTest < ActionController::TestCase new_section_code: @picture_section.code, student_ids: @word_user_1.id.to_s } - assert_not Follower.exists?(student_user: @picture_user_1, section: @picture_section) + assert_not Follower.exists?(student_user: @word_user_1, section: @picture_section) end test "transferring to a new teacher causes a student to join the section" do @@ -189,6 +189,7 @@ class TransfersControllerTest < ActionController::TestCase post :create, params: { new_section_code: @word_section.code, + current_section_code: @picture_section.code, student_ids: @picture_user_1.id.to_s }