diff options
| author | Timothy Andrew <mail@timothyandrew.net> | 2016-09-07 14:22:03 +0530 |
|---|---|---|
| committer | Timothy Andrew <mail@timothyandrew.net> | 2016-09-07 14:22:03 +0530 |
| commit | 32147ddf5412bceaea809dedb028b23f55461a89 (patch) | |
| tree | 9c28703a0e04dd5c89775f306d51d2bf5c813de3 /spec/support | |
| parent | 9cff3f8f5282633fd0c5920e3b6d277415ae9000 (diff) | |
| download | gitlab-ce-32147ddf5412bceaea809dedb028b23f55461a89.tar.gz | |
Add a test case for "end condition happens before start condition".
- In the cycle analytics specs.
Diffstat (limited to 'spec/support')
| -rw-r--r-- | spec/support/cycle_analytics_helpers.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb index c369caf8041..60524624782 100644 --- a/spec/support/cycle_analytics_helpers.rb +++ b/spec/support/cycle_analytics_helpers.rb @@ -80,6 +80,27 @@ module CycleAnalyticsHelpers expect(subject.send(phase)).to be_nil end end + + context "when the end condition happens before the start condition" do + it 'returns nil' do + data = data_fn[self] + start_time = Time.now + end_time = start_time + rand(1..5).days + + # 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(start_time) { condition_fn[self, data] } + end + + start_time_conditions.each do |condition_name, condition_fn| + Timecop.freeze(end_time) { condition_fn[self, data] } + end + + expect(subject.send(phase)).to be_nil + end + end end end |
