kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
217 lines
9.5 KiB
217 lines
9.5 KiB
11 years ago
|
#-- copyright
|
||
|
# OpenProject Backlogs Plugin
|
||
|
#
|
||
11 years ago
|
# Copyright (C)2013-2014 the OpenProject Foundation (OPF)
|
||
11 years ago
|
# Copyright (C)2011 Stephan Eckardt, Tim Felgentreff, Marnen Laibow-Koser, Sandro Munda
|
||
|
# Copyright (C)2010-2011 friflaj
|
||
|
# Copyright (C)2010 Maxime Guilbot, Andrew Vit, Joakim Kolsjö, ibussieres, Daniel Passos, Jason Vasquez, jpic, Emiliano Heyns
|
||
|
# Copyright (C)2009-2010 Mark Maglana
|
||
|
# Copyright (C)2009 Joe Heck, Nate Lowrie
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or modify it under
|
||
|
# the terms of the GNU General Public License version 3.
|
||
|
#
|
||
|
# OpenProject Backlogs is a derivative work based on ChiliProject Backlogs.
|
||
|
# The copyright follows:
|
||
|
# Copyright (C) 2010-2011 - Emiliano Heyns, Mark Maglana, friflaj
|
||
|
# Copyright (C) 2011 - Jens Ulferts, Gregor Schmidt - Finn GmbH - Berlin, Germany
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
#
|
||
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
|
|
||
14 years ago
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
||
|
|
||
9 years ago
|
describe Burndown, type: :model do
|
||
13 years ago
|
def set_attribute_journalized(story, attribute, value, day)
|
||
|
story.reload
|
||
14 years ago
|
story.send(attribute, value)
|
||
13 years ago
|
story.save!
|
||
11 years ago
|
story.current_journal.update_attribute(:created_at, day)
|
||
14 years ago
|
end
|
||
|
|
||
7 years ago
|
let(:user) { @user ||= FactoryBot.create(:user) }
|
||
|
let(:role) { @role ||= FactoryBot.create(:role) }
|
||
|
let(:type_feature) { @type_feature ||= FactoryBot.create(:type_feature) }
|
||
|
let(:type_task) { @type_task ||= FactoryBot.create(:type_task) }
|
||
|
let(:issue_priority) { @issue_priority ||= FactoryBot.create(:priority, is_default: true) }
|
||
|
let(:version) { @version ||= FactoryBot.create(:version, project: project) }
|
||
14 years ago
|
let(:sprint) { @sprint ||= Sprint.find(version.id) }
|
||
|
|
||
|
let(:project) do
|
||
|
unless @project
|
||
7 years ago
|
@project = FactoryBot.build(:project)
|
||
|
@project.members = [FactoryBot.build(:member, principal: user,
|
||
9 years ago
|
project: @project,
|
||
|
roles: [role])]
|
||
14 years ago
|
@project.versions << version
|
||
|
end
|
||
|
@project
|
||
|
end
|
||
|
|
||
7 years ago
|
let(:issue_open) { @status1 ||= FactoryBot.create(:status, name: 'status 1', is_default: true) }
|
||
|
let(:issue_closed) { @status2 ||= FactoryBot.create(:status, name: 'status 2', is_closed: true) }
|
||
|
let(:issue_resolved) { @status3 ||= FactoryBot.create(:status, name: 'status 3', is_closed: false) }
|
||
14 years ago
|
|
||
|
before(:each) do
|
||
12 years ago
|
Rails.cache.clear
|
||
|
|
||
11 years ago
|
allow(User).to receive(:current).and_return(user)
|
||
11 years ago
|
|
||
9 years ago
|
allow(Setting).to receive(:plugin_openproject_backlogs).and_return({ 'points_burn_direction' => 'down',
|
||
|
'wiki_template' => '',
|
||
|
'card_spec' => 'Sattleford VM-5040',
|
||
|
'story_types' => [type_feature.id.to_s],
|
||
|
'task_type' => type_task.id.to_s })
|
||
14 years ago
|
|
||
13 years ago
|
project.save!
|
||
11 years ago
|
|
||
11 years ago
|
[issue_open, issue_closed, issue_resolved].permutation(2).each do |transition|
|
||
7 years ago
|
FactoryBot.create(:workflow,
|
||
11 years ago
|
old_status: transition[0],
|
||
|
new_status: transition[1],
|
||
|
role: role,
|
||
|
type_id: type_feature.id)
|
||
11 years ago
|
end
|
||
14 years ago
|
end
|
||
|
|
||
9 years ago
|
describe 'Sprint Burndown' do
|
||
|
describe 'WITH the today date fixed to April 4th, 2011 and having a 10 (working days) sprint' do
|
||
14 years ago
|
before(:each) do
|
||
9 years ago
|
allow(Time).to receive(:now).and_return(Time.utc(2011, 'apr', 4, 20, 15, 1))
|
||
|
allow(Date).to receive(:today).and_return(Date.civil(2011, 04, 04))
|
||
14 years ago
|
end
|
||
|
|
||
9 years ago
|
describe 'WITH having a version in the future' do
|
||
11 years ago
|
before(:each) do
|
||
|
version.start_date = Date.today + 1.days
|
||
|
version.effective_date = Date.today + 6.days
|
||
|
version.save!
|
||
|
end
|
||
|
|
||
9 years ago
|
it 'should generate a burndown' do
|
||
11 years ago
|
expect(sprint.burndown(project).series[:story_points]).to be_empty
|
||
11 years ago
|
end
|
||
|
end
|
||
|
|
||
9 years ago
|
describe 'WITH having a 10 (working days) sprint and being 5 (working) days into it' do
|
||
14 years ago
|
before(:each) do
|
||
14 years ago
|
version.start_date = Date.today - 7.days
|
||
14 years ago
|
version.effective_date = Date.today + 6.days
|
||
|
version.save!
|
||
|
end
|
||
|
|
||
9 years ago
|
describe 'WITH 1 story assigned to the sprint' do
|
||
14 years ago
|
before(:each) do
|
||
7 years ago
|
@story = FactoryBot.build(:story, subject: 'Story 1',
|
||
9 years ago
|
project: project,
|
||
|
fixed_version: version,
|
||
|
type: type_feature,
|
||
|
status: issue_open,
|
||
|
priority: issue_priority,
|
||
|
created_at: Date.today - 20.days,
|
||
|
updated_at: Date.today - 20.days)
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
9 years ago
|
describe 'WITH the story having story_point defined on creation' do
|
||
14 years ago
|
before(:each) do
|
||
13 years ago
|
@story.story_points = 9
|
||
|
@story.save!
|
||
11 years ago
|
@story.current_journal.update_attribute(:created_at, @story.created_at)
|
||
14 years ago
|
end
|
||
|
|
||
9 years ago
|
describe 'WITH the story being closed and opened again within the sprint duration' do
|
||
14 years ago
|
before(:each) do
|
||
12 years ago
|
set_attribute_journalized @story, :status_id=, issue_closed.id, Time.now - 6.days
|
||
|
set_attribute_journalized @story, :status_id=, issue_open.id, Time.now - 3.days
|
||
14 years ago
|
|
||
|
@burndown = Burndown.new(sprint, project)
|
||
|
end
|
||
|
|
||
11 years ago
|
it { expect(@burndown.story_points).to eql [9.0, 0.0, 0.0, 0.0, 9.0, 9.0] }
|
||
|
it { expect(@burndown.story_points.unit).to eql :points }
|
||
9 years ago
|
it { expect(@burndown.days).to eql(sprint.days) }
|
||
11 years ago
|
it { expect(@burndown.max[:hours]).to eql 0.0 }
|
||
|
it { expect(@burndown.max[:points]).to eql 9.0 }
|
||
|
it { expect(@burndown.story_points_ideal).to eql [9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0] }
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
|
describe "WITH the story marked as resolved and consequently 'done'" do
|
||
|
before(:each) do
|
||
12 years ago
|
set_attribute_journalized @story, :status_id=, issue_resolved.id, Time.now - 6.days
|
||
|
set_attribute_journalized @story, :status_id=, issue_open.id, Time.now - 3.days
|
||
11 years ago
|
project.done_statuses << issue_resolved
|
||
14 years ago
|
@burndown = Burndown.new(sprint, project)
|
||
|
end
|
||
|
|
||
11 years ago
|
it { expect(@story.done?).to eql false }
|
||
|
it { expect(@burndown.story_points).to eql [9.0, 0.0, 0.0, 0.0, 9.0, 9.0] }
|
||
14 years ago
|
end
|
||
14 years ago
|
end
|
||
14 years ago
|
end
|
||
|
|
||
9 years ago
|
describe 'WITH 10 stories assigned to the sprint' do
|
||
14 years ago
|
before(:each) do
|
||
|
@stories = []
|
||
|
|
||
|
(0..9).each do |i|
|
||
7 years ago
|
@stories[i] = FactoryBot.create(:story, subject: "Story #{i}",
|
||
9 years ago
|
project: project,
|
||
|
fixed_version: version,
|
||
|
type: type_feature,
|
||
|
status: issue_open,
|
||
|
priority: issue_priority,
|
||
|
created_at: Date.today - (20 - i).days,
|
||
|
updated_at: Date.today - (20 - i).days)
|
||
11 years ago
|
@stories[i].current_journal.update_attribute(:created_at, @stories[i].created_at)
|
||
14 years ago
|
end
|
||
|
end
|
||
|
|
||
9 years ago
|
describe 'WITH each story having story points defined at start' do
|
||
14 years ago
|
before(:each) do
|
||
9 years ago
|
@stories.each_with_index do |s, _i|
|
||
14 years ago
|
set_attribute_journalized s, :story_points=, 10, version.start_date - 3.days
|
||
14 years ago
|
end
|
||
|
end
|
||
|
|
||
9 years ago
|
describe 'WITH 5 stories having been reduced to 0 story points, one story per day' do
|
||
14 years ago
|
before(:each) do
|
||
|
@finished_hours
|
||
|
(0..4).each do |i|
|
||
14 years ago
|
set_attribute_journalized @stories[i], :story_points=, nil, version.start_date + i.days + 1.hour
|
||
14 years ago
|
end
|
||
|
end
|
||
|
|
||
9 years ago
|
describe 'THEN' do
|
||
14 years ago
|
before(:each) do
|
||
|
@burndown = Burndown.new(sprint, project)
|
||
|
end
|
||
|
|
||
11 years ago
|
it { expect(@burndown.story_points).to eql [90.0, 80.0, 70.0, 60.0, 50.0, 50.0] }
|
||
|
it { expect(@burndown.story_points.unit).to eql :points }
|
||
9 years ago
|
it { expect(@burndown.days).to eql(sprint.days) }
|
||
11 years ago
|
it { expect(@burndown.max[:hours]).to eql 0.0 }
|
||
|
it { expect(@burndown.max[:points]).to eql 90.0 }
|
||
|
it { expect(@burndown.story_points_ideal).to eql [90.0, 80.0, 70.0, 60.0, 50.0, 40.0, 30.0, 20.0, 10.0, 0.0] }
|
||
14 years ago
|
end
|
||
|
end
|
||
14 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
14 years ago
|
end
|