Skip to content

Conversation

michalrus
Copy link
Contributor

Solves #1703

def couponActiveFrom: Instant = Instant.now.minus(1, DAYS)
def couponActiveTo: Option[Instant] = None
def couponUsageRules: CouponUsageRules =
CouponUsageRules(isUnlimitedPerCode = true, isUnlimitedPerCustomer = true)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d argue they shouldn’t have defaults, either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also cake pattern here is pretty unintuitive. I have to

  1. add another method parameter
  2. provide overrideable value that this method uses as a default

instead of

  1. just calling the function with arguments I want

usesPerCustomer = Some(1)
)

// TODO: extract CheckoutFixture and reuse it here (more refactoring will be needed for that) @michalrus
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

form * <~ ObjectForms.mustFindById400(coupon.formId)
couponUsage * <~ CouponUsages
.filterByCoupon(coupon.formId)
def incrementUsageCounts(codeId: Int, customer: User, incrementBy: Int)(implicit ec: EC,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it’s None… just… don’t call it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants