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.
209 lines
7.7 KiB
209 lines
7.7 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 Story, type: :model do
|
||
7 years ago
|
let(:user) { @user ||= FactoryBot.create(:user) }
|
||
|
let(:role) { @role ||= FactoryBot.create(:role) }
|
||
|
let(:status1) { @status1 ||= FactoryBot.create(:status, name: 'status 1', is_default: true) }
|
||
|
let(:type_feature) { @type_feature ||= FactoryBot.create(:type_feature) }
|
||
|
let(:version) { @version ||= FactoryBot.create(:version, project: project) }
|
||
|
let(:version2) { FactoryBot.create(:version, project: project) }
|
||
|
let(:sprint) { @sprint ||= FactoryBot.create(:sprint, project: project) }
|
||
|
let(:issue_priority) { @issue_priority ||= FactoryBot.create(:priority) }
|
||
|
let(:task_type) { FactoryBot.create(:type_task) }
|
||
9 years ago
|
let(:task) {
|
||
7 years ago
|
FactoryBot.create(:story, fixed_version: version,
|
||
9 years ago
|
project: project,
|
||
|
status: status1,
|
||
|
type: task_type,
|
||
|
priority: issue_priority)
|
||
|
}
|
||
|
let(:story1) {
|
||
7 years ago
|
FactoryBot.create(:story, fixed_version: version,
|
||
9 years ago
|
project: project,
|
||
|
status: status1,
|
||
|
type: type_feature,
|
||
|
priority: issue_priority)
|
||
|
}
|
||
|
|
||
|
let(:story2) {
|
||
7 years ago
|
FactoryBot.create(:story, fixed_version: version,
|
||
9 years ago
|
project: project,
|
||
|
status: status1,
|
||
|
type: type_feature,
|
||
|
priority: issue_priority)
|
||
|
}
|
||
14 years ago
|
|
||
|
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
|
end
|
||
|
@project
|
||
|
end
|
||
|
|
||
|
before(:each) do
|
||
12 years ago
|
ActionController::Base.perform_caching = false
|
||
13 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' => task_type.id.to_s })
|
||
11 years ago
|
project.types << task_type
|
||
14 years ago
|
end
|
||
|
|
||
9 years ago
|
describe 'Class methods' do
|
||
10 years ago
|
describe '#backlogs' do
|
||
12 years ago
|
describe "WITH one sprint
|
||
|
WITH the sprint having 1 story" do
|
||
|
before(:each) do
|
||
|
story1
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it { expect(Story.backlogs(project, [version.id])[version.id]).to match_array([story1]) }
|
||
12 years ago
|
end
|
||
12 years ago
|
|
||
12 years ago
|
describe "WITH two sprints
|
||
|
WITH two stories
|
||
|
WITH one story per sprint
|
||
|
WITH querying for the two sprints" do
|
||
|
before do
|
||
|
version2
|
||
|
story1
|
||
|
story2.fixed_version_id = version2.id
|
||
|
story2.save!
|
||
14 years ago
|
end
|
||
|
|
||
11 years ago
|
it { expect(Story.backlogs(project, [version.id, version2.id])[version.id]).to match_array([story1]) }
|
||
|
it { expect(Story.backlogs(project, [version.id, version2.id])[version2.id]).to match_array([story2]) }
|
||
12 years ago
|
end
|
||
|
|
||
|
describe "WITH two sprints
|
||
|
WITH two stories
|
||
|
WITH one story per sprint
|
||
|
WITH querying one sprints" do
|
||
|
before do
|
||
|
version2
|
||
|
story1
|
||
|
|
||
|
story2.fixed_version_id = version2.id
|
||
|
story2.save!
|
||
|
end
|
||
|
|
||
11 years ago
|
it { expect(Story.backlogs(project, [version.id])[version.id]).to match_array([story1]) }
|
||
|
it { expect(Story.backlogs(project, [version.id])[version2.id]).to be_empty }
|
||
12 years ago
|
end
|
||
|
|
||
|
describe "WITH two sprints
|
||
|
WITH two stories
|
||
|
WITH one story per sprint
|
||
|
WITH querying for the two sprints
|
||
|
WITH one sprint beeing in another project" do
|
||
|
before do
|
||
|
story1
|
||
14 years ago
|
|
||
7 years ago
|
other_project = FactoryBot.create(:project)
|
||
9 years ago
|
version2.update! project_id: other_project.id
|
||
|
|
||
12 years ago
|
story2.fixed_version_id = version2.id
|
||
|
story2.project = other_project
|
||
9 years ago
|
# reset memoized versions to reflect changes above
|
||
|
story2.instance_variable_set('@assignable_versions', nil)
|
||
12 years ago
|
story2.save!
|
||
14 years ago
|
end
|
||
|
|
||
11 years ago
|
it { expect(Story.backlogs(project, [version.id, version2.id])[version.id]).to match_array([story1]) }
|
||
|
it { expect(Story.backlogs(project, [version.id, version2.id])[version2.id]).to be_empty }
|
||
12 years ago
|
end
|
||
14 years ago
|
|
||
12 years ago
|
describe "WITH one sprint
|
||
|
WITH the sprint having one story in this project and one story in another project" do
|
||
|
before(:each) do
|
||
9 years ago
|
version.sharing = 'system'
|
||
12 years ago
|
version.save!
|
||
12 years ago
|
|
||
7 years ago
|
another_project = FactoryBot.create(:project)
|
||
12 years ago
|
|
||
12 years ago
|
story1
|
||
|
story2.project = another_project
|
||
|
story2.save!
|
||
12 years ago
|
end
|
||
|
|
||
11 years ago
|
it { expect(Story.backlogs(project, [version.id])[version.id]).to match_array([story1]) }
|
||
12 years ago
|
end
|
||
14 years ago
|
|
||
12 years ago
|
describe "WITH one sprint
|
||
|
WITH the sprint having two storys
|
||
|
WITH one beeing the child of the other" do
|
||
|
before(:each) do
|
||
11 years ago
|
story1.parent_id = story2.id
|
||
12 years ago
|
|
||
12 years ago
|
story1.save
|
||
12 years ago
|
end
|
||
|
|
||
11 years ago
|
it { expect(Story.backlogs(project, [version.id])[version.id]).to match_array([story1, story2]) }
|
||
12 years ago
|
end
|
||
12 years ago
|
|
||
12 years ago
|
describe "WITH one sprint
|
||
|
WITH the sprint having one story
|
||
|
WITH the story having a child task" do
|
||
|
before(:each) do
|
||
11 years ago
|
task.parent_id = story1.id
|
||
12 years ago
|
|
||
12 years ago
|
task.save
|
||
12 years ago
|
end
|
||
|
|
||
11 years ago
|
it { expect(Story.backlogs(project, [version.id])[version.id]).to match_array([story1]) }
|
||
12 years ago
|
end
|
||
12 years ago
|
|
||
12 years ago
|
describe "WITH one sprint
|
||
|
WITH the sprint having one story and one task
|
||
|
WITH the two having no connection" do
|
||
|
before(:each) do
|
||
|
task
|
||
|
story1
|
||
14 years ago
|
end
|
||
12 years ago
|
|
||
11 years ago
|
it { expect(Story.backlogs(project, [version.id])[version.id]).to match_array([story1]) }
|
||
14 years ago
|
end
|
||
|
end
|
||
|
end
|
||
13 years ago
|
end
|