Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to add in the reset functionality #248

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading