Skip to content

Commit

Permalink
Disable ETag caching on Teaching Event search
Browse files Browse the repository at this point in the history
There is odd behaviour in the hosted environments around search results not
always returning correctly. The only difference I can think of with the
development environment is that caching is disabled (although I've tested with
it enabled in dev and it does seem to behave).

Disable caching in hosted environments to see if that clears up the unexpected
results; if it does we can investigate further and then re-enable caching.
  • Loading branch information
ethax-ross committed Sep 28, 2020
1 parent c38b510 commit 986bbee
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion GetIntoTeachingApi/Controllers/TeachingEventsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public TeachingEventsController(
}

[HttpGet]
[CrmETag]
[Route("search")]
[SwaggerOperation(
Summary = "Searches for teaching events.",
Expand Down
6 changes: 3 additions & 3 deletions GetIntoTeachingApiTests/Attributes/CrmETagAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void OnActionExecuting_BeforeFirstCrmSyncJobHasRan_RespondsWithAnETag()
public void OnActionExecuting_AfterCrmSyncJobHasRan_RespondsWithNewETag()
{
const string eTag = "03AC2E21CC0F0298899728A7648684A16B08DF1EA22AAD296AC916B50D6A9FE1";
var jobDetails = new Dictionary<string, string>() { { "NextExecution", "2020-01-01 19:52:44" } };
var jobDetails = new Dictionary<string, string>() { { "LastExecution", "2020-01-01 19:52:44" } };
_mockStorageConnection.Setup(m => m.GetAllEntriesFromHash(
$"recurring-job:{JobConfiguration.CrmSyncJobId}")).Returns(jobDetails);
_mockHttpContext.Setup(m => m.Request.Headers["If-None-Match"]).Returns<string>(null);
Expand All @@ -141,7 +141,7 @@ public void OnActionExecuting_AfterCrmSyncJobHasRan_RespondsWithNewETag()
public void OnActionExecuting_WithMatchingIfNoneMatch_Responds304NotModified()
{
const string eTag = "03AC2E21CC0F0298899728A7648684A16B08DF1EA22AAD296AC916B50D6A9FE1";
var jobDetails = new Dictionary<string, string>() { { "NextExecution", "2020-01-01 19:52:44" } };
var jobDetails = new Dictionary<string, string>() { { "LastExecution", "2020-01-01 19:52:44" } };
_mockStorageConnection.Setup(m => m.GetAllEntriesFromHash(
$"recurring-job:{JobConfiguration.CrmSyncJobId}")).Returns(jobDetails);
_mockHttpContext.Setup(m => m.Request.Headers["If-None-Match"]).Returns(eTag);
Expand All @@ -161,7 +161,7 @@ public void OnActionExecuting_WithMatchingIfNoneMatch_Responds304NotModified()
public void OnActionExecuting_WithDifferentIfNoneMatch_RespondsWithResultAndETag()
{
const string eTag = "03AC2E21CC0F0298899728A7648684A16B08DF1EA22AAD296AC916B50D6A9FE1";
var jobDetails = new Dictionary<string, string>() { { "NextExecution", "2020-01-01 19:52:44" } };
var jobDetails = new Dictionary<string, string>() { { "LastExecution", "2020-01-01 19:52:44" } };
_mockStorageConnection.Setup(m => m.GetAllEntriesFromHash(
$"recurring-job:{JobConfiguration.CrmSyncJobId}")).Returns(jobDetails);
_mockHttpContext.Setup(m => m.Request.Headers["If-None-Match"]).Returns("wrong-etag");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void Authorize_IsPresent()
public void CrmETag_IsPresent()
{
JobStorage.Current = new Mock<JobStorage>().Object;
var methods = new [] { "Get", "Search" };
var methods = new [] { "Get" };

methods.ForEach(m => typeof(TeachingEventsController).GetMethod(m).Should().BeDecoratedWith<CrmETagAttribute>());
}
Expand Down

0 comments on commit 986bbee

Please sign in to comment.