diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-09-07 08:05:01 +0300 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-09-07 08:09:46 +0300 |
commit | f77c952ae71ec03c9691e44479f0e4a7fc5ef8e8 (patch) | |
tree | 484d1a631a52ea9fc4d8930a1fd1794d98ad2e97 /spec/support | |
parent | 98c9d1207708cd7d9fc37167e65e8a26b668aaa7 (diff) |
Test the `code` cycle analytics phase.
- Move the "data belongs to other project" test case into the generated
tests, and remove the explicit tests from the `code` and `plan` phases.
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/cycle_analytics_helpers.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb index ba18b390c1a..b2ca42d7cce 100644 --- a/spec/support/cycle_analytics_helpers.rb +++ b/spec/support/cycle_analytics_helpers.rb @@ -45,6 +45,37 @@ module CycleAnalyticsHelpers median_time_difference = time_differences.sort[2] expect(subject.send(phase)).to be_within(2).of(median_time_difference) end + + context "when the data belongs to another project" do + let(:other_project) { create(:project) } + + it "returns nil" do + # Use a stub to "trick" the data/condition functions + # into using another project. This saves us from having to + # define separate data/condition functions for this particular + # test case. + allow(self).to receive(:project) { other_project } + + 5.times do + data = data_fn[self] + start_time = Time.now + end_time = rand(1..10).days.from_now + + start_time_conditions.each do |condition_name, condition_fn| + Timecop.freeze(start_time) { condition_fn[self, data] } + end + + end_time_conditions.each do |condition_name, condition_fn| + Timecop.freeze(end_time) { condition_fn[self, data] } + end + end + + # Turn off the stub before checking assertions + allow(self).to receive(:project).and_call_original + + expect(subject.send(phase)).to be_nil + end + end end end |