From 696bbd169b210bd0ab29a045d8952c9839a09690 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 14 Mar 2018 17:24:41 +0800 Subject: [PATCH] Redirect to the reportable after creating a report. --- app/controllers/reports_controller.rb | 2 +- test/controllers/reports_controller_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 4d2220a26..21c717581 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -20,7 +20,7 @@ class ReportsController < ApplicationController if @report.save @report.issue.save @report.issue.reopen! unless @report.issue.open? - redirect_to root_path, :notice => t("issues.create.successful_report") + redirect_to helpers.reportable_url(@report.issue.reportable), :notice => t("issues.create.successful_report") else redirect_to new_report_path(:reportable_type => @report.issue.reportable_type, :reportable_id => @report.issue.reportable_id), :notice => t("issues.create.provide_details") end diff --git a/test/controllers/reports_controller_test.rb b/test/controllers/reports_controller_test.rb index 206958ab8..d9bc190d8 100644 --- a/test/controllers/reports_controller_test.rb +++ b/test/controllers/reports_controller_test.rb @@ -32,7 +32,7 @@ class ReportsControllerTest < ActionController::TestCase end assert_equal 1, Issue.count assert_response :redirect - assert_redirected_to root_path + assert_redirected_to user_path(target_user.display_name) end def test_new_report_with_incomplete_details @@ -61,7 +61,7 @@ class ReportsControllerTest < ActionController::TestCase end assert_equal 1, Issue.count assert_response :redirect - assert_redirected_to root_path + assert_redirected_to user_path(target_user.display_name) get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" } assert_response :success @@ -107,7 +107,7 @@ class ReportsControllerTest < ActionController::TestCase end assert_equal 1, Issue.count assert_response :redirect - assert_redirected_to root_path + assert_redirected_to user_path(target_user.display_name) # Create a report for an existing Issue get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" } -- 2.39.5