From 8483304dcf4ba0defe68e2374e9f7e6f4bb309c3 Mon Sep 17 00:00:00 2001 From: Ryan Shaw Date: Thu, 14 Nov 2019 09:13:20 -0700 Subject: [PATCH] redirect_back to page you were on when accepting enrollment redirect_back is a new method in rails 5: https://apidock.com/rails/ActionController/Redirecting/redirect_back and it is for doing exactly what we want here, redirect back to the page the person was on, otherwise still fall back to the fallback location we were using before test plan: * accept a course enrollment invitation from an assignment page * it should redirect you back to the same page you were looking at and not the course home page Change-Id: I9be2050b452ee67da3aac32a6e7670f5719e5c35 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/217234 Tested-by: Service Cloud Jenkins Tested-by: Jenkins QA-Review: Steven Burnett Product-Review: Steven Burnett Reviewed-by: Steven Burnett --- app/controllers/courses_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 2f9e87b4c72..b4e470d05f6 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1553,7 +1553,9 @@ class CoursesController < ApplicationController session[:accepted_enrollment_uuid] = enrollment.uuid if params[:action] != 'show' - redirect_to course_url(@context.id) + # Redirects back to HTTP_REFERER if it exists (so if you accept from an assignent page it will put + # you back on the same page you were looking at). Otherwise, it redirects back to the course homepage + redirect_back(fallback_location: course_url(@context.id)) else @context_enrollment = enrollment enrollment = nil