Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options to PromotionCode::BatchBuilder and spec for unique promotion code contention #2579

Merged
merged 2 commits into from
Feb 16, 2018

Commits on Feb 16, 2018

  1. Use an options hash for BatchBuilder

    This deprecates the existing class-attributes in favour of having a
    defaults option hash.
    
    This allows creating instances of BatchBuilder with different rules than
    the defaults. This makes testing different rules a lot easier and may
    allow for per-batch settings in the future.
    jhawthorn committed Feb 16, 2018
    Configuration menu
    Copy the full SHA
    8ee0cb3 View commit details
    Browse the repository at this point in the history
  2. Add spec for BatchBuilder contention

    Previously we had an issue where BatchBuilder would create the wrong
    number of promotion codes if it encountered a conflict. Out specs didn't
    catch this.
    
    This commit adds an additional spec which runs the BatchBuilder with
    settings that make it extremely likely that there will a conflict: from
    a space of 100 possible codes (00 to 99) we generate 50.
    
    An online birthday problem calculator tells me this is 99.99997%
    likely that the generator will encounter at least one conflict. That
    seems plenty. I haven't verified this, but intuitively it seems very
    likely.
    jhawthorn committed Feb 16, 2018
    Configuration menu
    Copy the full SHA
    17f0ef0 View commit details
    Browse the repository at this point in the history