Skip to content

Commit 0b34d07

Browse files
committed
use no-op when cancelling gift card subscriptions
since these subscriptions are not auto-renewing, a no-op makes their behaviour consistent with the other two providers by cancelling subscription at the end of current billing cycle
1 parent 8908229 commit 0b34d07

3 files changed

Lines changed: 1 addition & 5 deletions

File tree

src/integrationTest/java/com/trynoice/api/subscription/SubscriptionControllerTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
import javax.persistence.EntityManager;
3636
import javax.transaction.Transactional;
37-
import java.time.OffsetDateTime;
3837
import java.util.ArrayList;
3938
import java.util.Arrays;
4039
import java.util.HashMap;
@@ -410,7 +409,6 @@ void cancelSubscription(
410409
.cancelSubscription(subscription.getProvidedId());
411410
break;
412411
case GIFT_CARD:
413-
assertTrue(subscription.getEndAt().isBefore(OffsetDateTime.now()));
414412
break;
415413
default:
416414
throw new RuntimeException("unknown provider");

src/main/java/com/trynoice/api/subscription/SubscriptionService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ public void cancelSubscription(@NonNull Long customerId, @NonNull Long subscript
332332

333333
break;
334334
case GIFT_CARD:
335-
subscription.setEndAt(OffsetDateTime.now());
335+
// no-op as gift card subscriptions are not auto-renewing.
336336
break;
337337
default:
338338
throw new IllegalStateException("unsupported provider used in subscription plan");

src/test/java/com/trynoice/api/subscription/SubscriptionServiceTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import static org.junit.jupiter.api.Assertions.assertNotNull;
5353
import static org.junit.jupiter.api.Assertions.assertNull;
5454
import static org.junit.jupiter.api.Assertions.assertThrows;
55-
import static org.junit.jupiter.api.Assertions.assertTrue;
5655
import static org.junit.jupiter.params.provider.Arguments.arguments;
5756
import static org.mockito.ArgumentMatchers.any;
5857
import static org.mockito.ArgumentMatchers.eq;
@@ -325,7 +324,6 @@ <T extends Throwable> void cancelSubscription(
325324
.cancelSubscription(subscription.getProvidedId());
326325
break;
327326
case GIFT_CARD:
328-
assertTrue(subscription.getEndAt().isBefore(OffsetDateTime.now()));
329327
break;
330328
default:
331329
throw new RuntimeException("unknown provider");

0 commit comments

Comments
 (0)