diff options
author | Małgorzata Ksionek <mksionek@gitlab.com> | 2019-07-04 15:12:43 +0300 |
---|---|---|
committer | Małgorzata Ksionek <mksionek@gitlab.com> | 2019-07-09 13:16:37 +0300 |
commit | 6f6805ed6a7fd6857f54e74d98665d2050a173f1 (patch) | |
tree | 4b89bcc2ae1f335b33ef138de98fd38666e005d2 /spec/models/cycle_analytics | |
parent | ae2514d0a1d1ac6eec66c11b3246b365cde0b6c1 (diff) |
Move project level specs
Diffstat (limited to 'spec/models/cycle_analytics')
-rw-r--r-- | spec/models/cycle_analytics/project_level_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/models/cycle_analytics/project_level_spec.rb b/spec/models/cycle_analytics/project_level_spec.rb new file mode 100644 index 00000000000..196306fd52a --- /dev/null +++ b/spec/models/cycle_analytics/project_level_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe CycleAnalytics::ProjectLevel do + let(:project) { create(:project, :repository) } + let(:from_date) { 10.days.ago } + let(:user) { create(:user, :admin) } + let(:issue) { create(:issue, project: project, created_at: 2.days.ago) } + let(:milestone) { create(:milestone, project: project) } + let(:mr) { create_merge_request_closing_issue(user, project, issue, commit_message: "References #{issue.to_reference}") } + let(:pipeline) { create(:ci_empty_pipeline, status: 'created', project: project, ref: mr.source_branch, sha: mr.source_branch_sha, head_pipeline_of: mr) } + + subject { described_class.new(project: project, options: { from: from_date }) } + + describe '#all_medians_per_stage' do + before do + allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return([issue]) + + create_cycle(user, project, issue, mr, milestone, pipeline) + deploy_master(user, project) + end + + it 'returns every median for each stage for a specific project' do + values = described_class::STAGES.each_with_object({}) do |stage_name, hsh| + hsh[stage_name] = subject[stage_name].median.presence + end + + expect(subject.all_medians_per_stage).to eq(values) + end + end +end |