Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Block rejected enrollments with an instant timeframe

Rafied7578a3d6f2
diff --git a/apps/web/lib/program-applications/throw-if-application-blocked.ts b/apps/web/lib/program-applications/throw-if-application-blocked.ts
index 25eec3140c..503ee3e252 100644
--- a/apps/web/lib/program-applications/throw-if-application-blocked.ts
+++ b/apps/web/lib/program-applications/throw-if-application-blocked.ts
@@ -49,8 +49,11 @@ export function throwIfApplicationBlocked({
);
}
- // Instant reapplication timeframe will be reapplied immediately, so we don't need to handle it here.
- return;
+ // An instant rejection deletes the enrollment, so a rejected one should not
+ // exist here. Block it, because the upsert would leave it rejected.
+ throw new Error(
+ "You have already applied to this program. You cannot apply to this program again.",
+ );
case ProgramEnrollmentStatus.invited:
throw new Error("You have a pending invitation to join this program.");
case ProgramEnrollmentStatus.declined:
diff --git a/apps/web/tests/partners/throw-if-application-blocked.test.ts b/apps/web/tests/partners/throw-if-application-blocked.test.ts
index 96e013b173..4652639bbf 100644
--- a/apps/web/tests/partners/throw-if-application-blocked.test.ts
+++ b/apps/web/tests/partners/throw-if-application-blocked.test.ts
@@ -87,7 +87,7 @@ describe("throwIfApplicationBlocked", () => {
}
});
- it("allows with instant timeframe", () => {
+ it("blocks with instant timeframe", () => {
expect(() =>
throwIfApplicationBlocked({
enrollment: enrollment(
@@ -97,7 +97,9 @@ describe("throwIfApplicationBlocked", () => {
groupId: TARGET_GROUP_ID,
rejectedAt: subDays(NOW, 1),
}),
- ).not.toThrow();
+ ).toThrow(
+ "You have already applied to this program. You cannot apply to this program again.",
+ );
});
});