Commit 63b54108 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rs-burndown-spec-performance' into 'master'

Improve performance of ee/spec/models/burndown_spec.rb

Closes #6156

See merge request gitlab-org/gitlab-ee!5827
parents 99ba247c 145bafd1
require 'spec_helper' require 'spec_helper'
describe Burndown do describe Burndown do
set(:user) { create(:user) }
let(:start_date) { "2017-03-01" } let(:start_date) { "2017-03-01" }
let(:due_date) { "2017-03-05" } let(:due_date) { "2017-03-03" }
let(:user) { create(:user) }
shared_examples 'burndown for milestone' do shared_examples 'burndown for milestone' do
before do before do
scope.add_master(user)
build_sample(milestone, issue_params) build_sample(milestone, issue_params)
end end
...@@ -21,11 +21,9 @@ describe Burndown do ...@@ -21,11 +21,9 @@ describe Burndown do
it "generates an array with date, issue count and weight" do it "generates an array with date, issue count and weight" do
expect(subject).to eq([ expect(subject).to eq([
["2017-03-01", 33, 66], ["2017-03-01", 3, 6],
["2017-03-02", 35, 70], ["2017-03-02", 4, 8],
["2017-03-03", 28, 56], ["2017-03-03", 2, 4]
["2017-03-04", 32, 64],
["2017-03-05", 21, 42]
].to_json) ].to_json)
end end
...@@ -60,11 +58,9 @@ describe Burndown do ...@@ -60,11 +58,9 @@ describe Burndown do
it "considers closed_at as milestone start date" do it "considers closed_at as milestone start date" do
expect(subject).to eq([ expect(subject).to eq([
["2017-03-01", 27, 54], ["2017-03-01", 3, 6],
["2017-03-02", 27, 54], ["2017-03-02", 3, 6],
["2017-03-03", 27, 54], ["2017-03-03", 3, 6]
["2017-03-04", 27, 54],
["2017-03-05", 27, 54]
].to_json) ].to_json)
end end
...@@ -94,12 +90,10 @@ describe Burndown do ...@@ -94,12 +90,10 @@ describe Burndown do
let(:project) { milestone.project } let(:project) { milestone.project }
let(:issue_params) do let(:issue_params) do
{ {
title: FFaker::Lorem.sentence(6),
description: FFaker::Lorem.sentence,
state: 'opened',
milestone: milestone, milestone: milestone,
weight: 2, weight: 2,
project_id: project.id project_id: project.id,
author: user
} }
end end
let(:scope) { project } let(:scope) { project }
...@@ -119,12 +113,10 @@ describe Burndown do ...@@ -119,12 +113,10 @@ describe Burndown do
let(:milestone) { nested_group_milestone } let(:milestone) { nested_group_milestone }
let(:issue_params) do let(:issue_params) do
{ {
title: FFaker::Lorem.sentence(6),
description: FFaker::Lorem.sentence,
state: 'opened',
milestone: milestone, milestone: milestone,
weight: 2, weight: 2,
project_id: nested_group_project.id project_id: nested_group_project.id,
author: user
} }
end end
let(:scope) { group } let(:scope) { group }
...@@ -136,12 +128,10 @@ describe Burndown do ...@@ -136,12 +128,10 @@ describe Burndown do
let(:milestone) { group_milestone } let(:milestone) { group_milestone }
let(:issue_params) do let(:issue_params) do
{ {
title: FFaker::Lorem.sentence(6),
description: FFaker::Lorem.sentence,
state: 'opened',
milestone: milestone, milestone: milestone,
weight: 2, weight: 2,
project_id: group_project.id project_id: group_project.id,
author: user
} }
end end
let(:scope) { group } let(:scope) { group }
...@@ -155,7 +145,7 @@ describe Burndown do ...@@ -155,7 +145,7 @@ describe Burndown do
day = date.day day = date.day
next if day.even? next if day.even?
count = day * 4 count = day
Timecop.travel(date) do Timecop.travel(date) do
# Create issues # Create issues
issues = create_list(:issue, count, issue_params) issues = create_list(:issue, count, issue_params)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment