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.
265 lines
8.8 KiB
265 lines
8.8 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.dirname(__FILE__) + '/../../spec_helper'
|
||
|
|
||
9 years ago
|
describe 'rb_taskboards/show', type: :view do
|
||
7 years ago
|
let(:user1) { FactoryBot.create(:user) }
|
||
|
let(:user2) { FactoryBot.create(:user) }
|
||
9 years ago
|
let(:role_allowed) {
|
||
7 years ago
|
FactoryBot.create(:role,
|
||
7 years ago
|
permissions: [:add_work_packages, :edit_work_packages, :manage_subtasks])
|
||
12 years ago
|
}
|
||
7 years ago
|
let(:role_forbidden) { FactoryBot.create(:role) }
|
||
11 years ago
|
# We need to create these as some view helpers access the database
|
||
9 years ago
|
let(:statuses) {
|
||
7 years ago
|
[FactoryBot.create(:status),
|
||
|
FactoryBot.create(:status),
|
||
|
FactoryBot.create(:status)]
|
||
9 years ago
|
}
|
||
14 years ago
|
|
||
7 years ago
|
let(:type_task) { FactoryBot.create(:type_task) }
|
||
|
let(:type_feature) { FactoryBot.create(:type_feature) }
|
||
|
let(:issue_priority) { FactoryBot.create(:priority) }
|
||
12 years ago
|
let(:project) do
|
||
7 years ago
|
project = FactoryBot.create(:project, types: [type_feature, type_task])
|
||
|
project.members = [FactoryBot.create(:member, principal: user1, project: project, roles: [role_allowed]),
|
||
|
FactoryBot.create(:member, principal: user2, project: project, roles: [role_forbidden])]
|
||
12 years ago
|
project
|
||
|
end
|
||
|
|
||
9 years ago
|
let(:story_a) {
|
||
7 years ago
|
FactoryBot.create(:story, status: statuses[0],
|
||
9 years ago
|
project: project,
|
||
|
type: type_feature,
|
||
|
fixed_version: sprint,
|
||
|
priority: issue_priority
|
||
|
)
|
||
|
}
|
||
|
let(:story_b) {
|
||
7 years ago
|
FactoryBot.create(:story, status: statuses[1],
|
||
9 years ago
|
project: project,
|
||
|
type: type_feature,
|
||
|
fixed_version: sprint,
|
||
|
priority: issue_priority
|
||
|
)
|
||
|
}
|
||
|
let(:story_c) {
|
||
7 years ago
|
FactoryBot.create(:story, status: statuses[2],
|
||
9 years ago
|
project: project,
|
||
|
type: type_feature,
|
||
|
fixed_version: sprint,
|
||
|
priority: issue_priority
|
||
|
)
|
||
|
}
|
||
12 years ago
|
let(:stories) { [story_a, story_b, story_c] }
|
||
7 years ago
|
let(:sprint) { FactoryBot.create(:sprint, project: project) }
|
||
12 years ago
|
let(:task) do
|
||
7 years ago
|
task = FactoryBot.create(:task, project: project, status: statuses[0], fixed_version: sprint, type: type_task)
|
||
11 years ago
|
# This is necessary as for some unknown reason passing the parent directly
|
||
|
# leads to the task searching for the parent with 'root_id' is NULL, which
|
||
|
# is not the case as the story has its own id as root_id
|
||
12 years ago
|
task.parent_id = story_a.id
|
||
|
task
|
||
|
end
|
||
7 years ago
|
let(:impediment) { FactoryBot.create(:impediment, project: project, status: statuses[0], fixed_version: sprint, blocks_ids: task.id.to_s, type: type_task) }
|
||
14 years ago
|
|
||
14 years ago
|
before :each do
|
||
9 years ago
|
allow(Setting).to receive(:plugin_openproject_backlogs).and_return({ 'story_types' => [type_feature.id], 'task_type' => type_task.id })
|
||
12 years ago
|
view.extend RbCommonHelper
|
||
|
view.extend TaskboardsHelper
|
||
14 years ago
|
|
||
12 years ago
|
assign(:project, project)
|
||
|
assign(:sprint, sprint)
|
||
|
assign(:statuses, statuses)
|
||
12 years ago
|
|
||
11 years ago
|
# We directly force the creation of stories by calling the method
|
||
12 years ago
|
stories
|
||
14 years ago
|
end
|
||
|
|
||
|
describe 'story blocks' do
|
||
|
it 'contains the story id' do
|
||
|
render
|
||
14 years ago
|
|
||
|
stories.each do |story|
|
||
11 years ago
|
expect(rendered).to have_selector "#story_#{story.id}" do
|
||
9 years ago
|
with_selector '.id', Regexp.new(story.id.to_s)
|
||
14 years ago
|
end
|
||
|
end
|
||
14 years ago
|
end
|
||
|
|
||
14 years ago
|
it 'has a title containing the story subject' do
|
||
|
render
|
||
|
|
||
|
stories.each do |story|
|
||
11 years ago
|
expect(rendered).to have_selector "#story_#{story.id}" do
|
||
9 years ago
|
with_selector '.subject', story.subject
|
||
14 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
it 'contains the story status' do
|
||
|
render
|
||
|
|
||
|
stories.each do |story|
|
||
11 years ago
|
expect(rendered).to have_selector "#story_#{story.id}" do
|
||
9 years ago
|
with_selector '.status', story.status.name
|
||
14 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
it 'contains the user it is assigned to' do
|
||
|
render
|
||
|
|
||
|
stories.each do |story|
|
||
11 years ago
|
expect(rendered).to have_selector "#story_#{story.id}" do
|
||
9 years ago
|
with_selector '.assigned_to_id', assignee.name
|
||
14 years ago
|
end
|
||
|
end
|
||
|
end
|
||
14 years ago
|
end
|
||
12 years ago
|
|
||
|
describe 'create buttons' do
|
||
12 years ago
|
it 'renders clickable + buttons for all stories with the right permissions' do
|
||
11 years ago
|
allow(User).to receive(:current).and_return(user1)
|
||
12 years ago
|
|
||
|
render
|
||
|
|
||
|
stories.each do |story|
|
||
|
assert_select "tr.story_#{story.id} td.add_new" do |td|
|
||
11 years ago
|
expect(td.count).to eq 1
|
||
|
expect(td.first).to have_content '+'
|
||
|
expect(td.first).to have_css '.clickable'
|
||
12 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
12 years ago
|
it 'does not render a clickable + buttons for all stories without the right permissions' do
|
||
11 years ago
|
allow(User).to receive(:current).and_return(user2)
|
||
12 years ago
|
|
||
|
render
|
||
|
|
||
|
stories.each do |story|
|
||
|
assert_select "tr.story_#{story.id} td.add_new" do |td|
|
||
11 years ago
|
expect(td.count).to eq 1
|
||
|
expect(td.first).not_to have_content '+'
|
||
|
expect(td.first).not_to have_css '.clickable'
|
||
12 years ago
|
end
|
||
|
end
|
||
|
end
|
||
12 years ago
|
|
||
|
it 'renders clickable + buttons for impediments with the right permissions' do
|
||
11 years ago
|
allow(User).to receive(:current).and_return(user1)
|
||
12 years ago
|
|
||
|
render
|
||
|
|
||
9 years ago
|
stories.each do |_story|
|
||
12 years ago
|
assert_select '#impediments td.add_new' do |td|
|
||
11 years ago
|
expect(td.count).to eq 1
|
||
|
expect(td.first).to have_content '+'
|
||
|
expect(td.first).to have_css '.clickable'
|
||
12 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
it 'does not render a clickable + buttons for impediments without the right permissions' do
|
||
11 years ago
|
allow(User).to receive(:current).and_return(user2)
|
||
12 years ago
|
|
||
|
render
|
||
|
|
||
9 years ago
|
stories.each do |_story|
|
||
12 years ago
|
assert_select '#impediments td.add_new' do |td|
|
||
11 years ago
|
expect(td.count).to eq 1
|
||
|
expect(td.first).not_to have_content '+'
|
||
|
expect(td.first).not_to have_css '.clickable'
|
||
12 years ago
|
end
|
||
|
end
|
||
|
end
|
||
12 years ago
|
end
|
||
12 years ago
|
|
||
|
describe 'update tasks or impediments' do
|
||
|
it 'allows edit and drag for all tasks with the right permissions' do
|
||
11 years ago
|
allow(User).to receive(:current).and_return(user1)
|
||
12 years ago
|
task
|
||
|
impediment
|
||
|
render
|
||
|
|
||
9 years ago
|
assert_select '.model.work_package.task' do |task|
|
||
11 years ago
|
expect(task.count).to eq 1
|
||
|
expect(task.first).not_to have_css '.task.prevent_edit'
|
||
12 years ago
|
end
|
||
|
end
|
||
|
|
||
|
it 'does not allow to edit and drag for all tasks without the right permissions' do
|
||
11 years ago
|
allow(User).to receive(:current).and_return(user2)
|
||
12 years ago
|
task
|
||
|
impediment
|
||
|
|
||
|
render
|
||
|
|
||
9 years ago
|
assert_select '.model.work_package.task' do |task|
|
||
11 years ago
|
expect(task.count).to eq 1
|
||
|
expect(task.first).to have_css '.task.prevent_edit'
|
||
12 years ago
|
end
|
||
|
end
|
||
|
|
||
|
it 'allows edit and drag for all impediments with the right permissions' do
|
||
11 years ago
|
allow(User).to receive(:current).and_return(user1)
|
||
12 years ago
|
task
|
||
|
impediment
|
||
|
|
||
|
render
|
||
|
|
||
9 years ago
|
assert_select '.model.work_package.impediment' do |impediment|
|
||
11 years ago
|
expect(impediment.count).to eq 3 # 2 additional for the task and the invisible form
|
||
|
expect(impediment.first).not_to have_css '.impediment.prevent_edit'
|
||
12 years ago
|
end
|
||
|
end
|
||
|
|
||
|
it 'does not allow to edit and drag for all impediments without the right permissions' do
|
||
11 years ago
|
allow(User).to receive(:current).and_return(user2)
|
||
12 years ago
|
task
|
||
|
impediment
|
||
|
|
||
|
render
|
||
|
|
||
9 years ago
|
assert_select '.model.work_package.impediment' do |impediment|
|
||
11 years ago
|
expect(impediment.count).to eq 3 # 2 additional for the task and the invisible form
|
||
|
expect(impediment.first).to have_css '.impediment.prevent_edit'
|
||
12 years ago
|
end
|
||
|
end
|
||
|
end
|
||
12 years ago
|
end
|