refactor(jobs): centralize status lifecycle
This commit is contained in:
@@ -113,21 +113,8 @@ public sealed class JobApplicationsAppliedDateHistoryTests
|
||||
return job;
|
||||
}
|
||||
|
||||
private static JobApplicationsController CreateController(JobTrackerContext db, string userId)
|
||||
{
|
||||
var controller = new JobApplicationsController(db, Mock.Of<ISummarizerService>(), TestHostFactory.CreateUserManager().Object);
|
||||
controller.ControllerContext = new ControllerContext
|
||||
{
|
||||
HttpContext = new DefaultHttpContext
|
||||
{
|
||||
User = new ClaimsPrincipal(new ClaimsIdentity(new[]
|
||||
{
|
||||
new Claim(ClaimTypes.NameIdentifier, userId)
|
||||
}, "test"))
|
||||
}
|
||||
};
|
||||
return controller;
|
||||
}
|
||||
private static JobApplicationLifecycleController CreateController(JobTrackerContext db, string userId)
|
||||
=> new(db);
|
||||
|
||||
private static JobTrackerContext CreateDb() => TestHostFactory.CreateInMemoryDb();
|
||||
}
|
||||
|
||||
@@ -69,7 +69,8 @@ public sealed class JobApplicationsAuthorizationTests
|
||||
var jobId = await ownerDb.JobApplications.Select(j => j.Id).FirstAsync();
|
||||
|
||||
await using var attackerDb = CreateDb(dbName, "other-user");
|
||||
var result = await CreateController(attackerDb).GetStatusSuggestion(jobId, CancellationToken.None);
|
||||
var result = await new JobApplicationLifecycleController(attackerDb)
|
||||
.GetStatusSuggestion(jobId, CancellationToken.None);
|
||||
|
||||
Assert.IsType<NotFoundResult>(result.Result);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public sealed class JobApplicationsEndpointBehaviorTests
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
var controller = CreateController(db, "user-1");
|
||||
var controller = new JobApplicationLifecycleController(db);
|
||||
var result = await controller.GetStatusSuggestion(job.Id, CancellationToken.None);
|
||||
|
||||
var ok = Assert.IsType<OkObjectResult>(result.Result);
|
||||
@@ -110,7 +110,7 @@ public sealed class JobApplicationsEndpointBehaviorTests
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
var controller = CreateController(db, "user-1");
|
||||
var controller = new JobApplicationLifecycleController(db);
|
||||
var result = await controller.GetStatusSuggestion(job.Id, CancellationToken.None);
|
||||
|
||||
var ok = Assert.IsType<OkObjectResult>(result.Result);
|
||||
|
||||
Reference in New Issue
Block a user