diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-09-07 13:06:58 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-09-07 13:06:58 +0530 |
commit | de483c6834153b75403633b42f20b0c85eae35e7 (patch) | |
tree | 078b3fa675ea3c9742847199abc3afdcb0a95dbd /spec/support | |
parent | dd112ef1174b2b0207769a361cddfc44dfe2e6d0 (diff) | |
download | gitlab-ce-de483c6834153b75403633b42f20b0c85eae35e7.tar.gz |
Test the `production` cycle analytics phase.
Add a `before_end_fn` option to the code that generates cycle analytics
specs. `before_end_fn` is called before the end conditions are. Used for
data setup that needs to be called after the start conditions and before
the end conditions.
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/cycle_analytics_helpers.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb index 4819f8b517a..c369caf8041 100644 --- a/spec/support/cycle_analytics_helpers.rb +++ b/spec/support/cycle_analytics_helpers.rb @@ -16,8 +16,9 @@ module CycleAnalyticsHelpers # end_time_conditions: An array of `conditions`. Each condition is an tuple of `condition_name` and `condition_fn`. `condition_fn` is called with # `context` (no lexical scope, so need to do `context.create` for factories, for example) and `data` (from the `data_fn`). # Each `condition_fn` is expected to implement a case which consitutes the end of the given cycle analytics phase. + # before_end_fn: This function is run before calling the end time conditions. Used for setup that needs to be run between the start and end conditions. - def generate_cycle_analytics_spec(phase:, data_fn:, start_time_conditions:, end_time_conditions:) + def generate_cycle_analytics_spec(phase:, data_fn:, start_time_conditions:, end_time_conditions:, before_end_fn: nil) combinations_of_start_time_conditions = (1..start_time_conditions.size).flat_map { |size| start_time_conditions.combination(size).to_a } combinations_of_end_time_conditions = (1..end_time_conditions.size).flat_map { |size| end_time_conditions.combination(size).to_a } @@ -35,6 +36,9 @@ module CycleAnalyticsHelpers Timecop.freeze(start_time) { condition_fn[self, data] } end + # Run `before_end_fn` at the midpoint between `start_time` and `end_time` + Timecop.freeze(start_time + (end_time - start_time)/2) { before_end_fn[self, data] } if before_end_fn + end_time_conditions.each do |condition_name, condition_fn| Timecop.freeze(end_time) { condition_fn[self, data] } end |