Skip to content

Commit fe3cceb

Browse files
authored
Merge pull request #3305 from TechnologyEnhancedLearning/Develop/Fixes/TD-3223-Showingconsole'404'errorwhenremovingthedelegatefromactivityandclickingbrowserbackbutton
TD-3223 Showing console '404' error when removing the delegate from activity and clicking browser back button
2 parents 753d6bc + ce1d59c commit fe3cceb

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/Delegates/DelegateProgressControllerTests.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
namespace DigitalLearningSolutions.Web.Tests.Controllers.TrackingSystem.Delegates
22
{
3-
using System;
4-
using System.Collections.Generic;
53
using DigitalLearningSolutions.Data.Models;
64
using DigitalLearningSolutions.Data.Models.Courses;
75
using DigitalLearningSolutions.Data.Models.CustomPrompts;
@@ -15,8 +13,11 @@
1513
using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates.DelegateProgress;
1614
using FakeItEasy;
1715
using FluentAssertions.AspNetCore.Mvc;
16+
using Microsoft.AspNetCore.Mvc;
1817
using Microsoft.Extensions.Configuration;
1918
using NUnit.Framework;
19+
using System;
20+
using System.Collections.Generic;
2021

2122
public class DelegateProgressControllerTests
2223
{
@@ -386,7 +387,11 @@ public void Delegate_removal_for_delegate_with_no_active_progress_returns_not_fo
386387
);
387388

388389
// Then
389-
result.Should().BeNotFoundResult();
390+
result.Should()
391+
.BeRedirectToActionResult()
392+
.WithActionName("StatusCode")
393+
.WithControllerName("LearningSolutions")
394+
.WithRouteValue("code", 410);
390395
}
391396

392397
[Test]

DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/DelegateProgressController.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,8 @@ public IActionResult ConfirmRemoveFromCourse(
275275
)
276276
{
277277
var progress = progressService.GetDetailedCourseProgress(progressId);
278-
if (progress == null)
279-
{
280-
return StatusCode((int)HttpStatusCode.Gone);
281-
}
278+
if (!courseService.DelegateHasCurrentProgress(progressId) || progress == null)
279+
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 410 });
282280

283281
var model = new RemoveFromCourseViewModel(
284282
progress,
@@ -305,9 +303,7 @@ RemoveFromCourseViewModel model
305303

306304
var progress = progressService.GetDetailedCourseProgress(progressId);
307305
if (!courseService.DelegateHasCurrentProgress(progressId) || progress == null)
308-
{
309-
return new NotFoundResult();
310-
}
306+
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 410 });
311307

312308
courseService.RemoveDelegateFromCourse(
313309
progress.DelegateId,

0 commit comments

Comments
 (0)