Skip to content

Commit

Permalink
Merge pull request #13527 from code-dot-org/fixTransfers
Browse files Browse the repository at this point in the history
Fix bug in student counting.
  • Loading branch information
ashercodeorg committed Mar 2, 2017
2 parents 75858f8 + 6b42e01 commit c1ba231
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dashboard/app/controllers/transfers_controller.rb
Expand Up @@ -77,7 +77,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
Expand Down
5 changes: 3 additions & 2 deletions dashboard/test/controllers/transfers_controller_test.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit c1ba231

Please sign in to comment.