Skip to content

Commit

Permalink
Updated to add in the reset functionality when someone starts the fir…
Browse files Browse the repository at this point in the history
…st step of the journey (#248)
  • Loading branch information
sam-c-dfe authored Jul 18, 2024
1 parent 52f4167 commit dc95225
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class QuestionsController(
[HttpGet("where-was-the-qualification-awarded")]
public async Task<IActionResult> WhereWasTheQualificationAwarded()
{
userJourneyCookieService.ResetUserJourneyCookie();
return await GetRadioView(QuestionPages.WhereWasTheQualificationAwarded,
nameof(this.WhereWasTheQualificationAwarded),
Questions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class UserJourneyCookieService(IHttpContextAccessor context, ILogger<User
{
Secure = true,
HttpOnly = true,
Expires = new DateTimeOffset(DateTime.Now.AddYears(1))
Expires = new DateTimeOffset(DateTime.Now.AddMinutes(30))
};

public void SetWhereWasQualificationAwarded(string location)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public async Task WhereWasTheQualificationAwarded_ContentServiceReturnsNoQuestio
mockQuestionModelValidator.Object);

var result = await controller.WhereWasTheQualificationAwarded();

mockUserJourneyCookieService.Verify(x => x.ResetUserJourneyCookie(), Times.Once);

mockContentService.VerifyAll();

Expand Down Expand Up @@ -77,6 +79,8 @@ public async Task WhereWasTheQualificationAwarded_ContentServiceReturnsQuestionP
mockQuestionModelValidator.Object);

var result = await controller.WhereWasTheQualificationAwarded();

mockUserJourneyCookieService.Verify(x => x.ResetUserJourneyCookie(), Times.Once);

result.Should().NotBeNull();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ private static Mock<IHttpContextAccessor> SetHttpContextWithExistingCookie(objec
private static void CheckSerializedModelWasSet(Mock<IHttpContextAccessor> mockContext,
string serializedModelToCheck)
{
var in364Days = new DateTimeOffset(DateTime.Now.AddDays(364));
var inOneYear = new DateTimeOffset(DateTime.Now.AddYears(1));
var in29Minutes = new DateTimeOffset(DateTime.Now.AddMinutes(29));
var in30Minutes = new DateTimeOffset(DateTime.Now.AddMinutes(30));

mockContext
.Verify(http =>
Expand All @@ -425,8 +425,8 @@ private static void CheckSerializedModelWasSet(Mock<IHttpContextAccessor> mockCo
options =>
options.Secure
&& options.HttpOnly
&& options.Expires > in364Days
&& options.Expires < inOneYear)
&& options.Expires > in29Minutes
&& options.Expires < in30Minutes)
),
Times.Once);
}
Expand Down

0 comments on commit dc95225

Please sign in to comment.