2025-05-05 09:29:55 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2013-10-02 11:45:03 +02:00
|
|
|
#-- copyright
|
2020-01-15 11:31:26 +01:00
|
|
|
# OpenProject is an open source project management software.
|
2024-07-30 13:42:36 +02:00
|
|
|
# Copyright (C) the OpenProject GmbH
|
2013-10-02 11:45:03 +02:00
|
|
|
#
|
|
|
|
|
# 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 is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
2021-01-13 17:47:45 +01:00
|
|
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
2013-10-02 11:45:03 +02:00
|
|
|
# Copyright (C) 2010-2013 the ChiliProject Team
|
|
|
|
|
#
|
|
|
|
|
# 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.
|
|
|
|
|
#
|
2021-09-02 21:49:06 +02:00
|
|
|
# See COPYRIGHT and LICENSE files for more details.
|
2013-10-02 11:45:03 +02:00
|
|
|
#++
|
|
|
|
|
|
|
|
|
|
require "spec_helper"
|
|
|
|
|
|
2023-05-31 12:15:15 +02:00
|
|
|
RSpec.describe WorkPackages::BulkController, with_settings: { journal_aggregation_time_minutes: 0 } do
|
2025-02-24 15:07:44 +01:00
|
|
|
shared_let(:user) { create(:user) }
|
|
|
|
|
shared_let(:custom_field2) { create(:work_package_custom_field) }
|
|
|
|
|
shared_let(:user2) { create(:user) }
|
|
|
|
|
shared_let(:custom_field_value) { "125" }
|
|
|
|
|
shared_let(:custom_field1) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:work_package_custom_field,
|
2022-02-02 21:48:06 +01:00
|
|
|
field_format: "string",
|
|
|
|
|
is_for_all: true)
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2025-02-24 15:07:44 +01:00
|
|
|
|
|
|
|
|
shared_let(:custom_field_user) { create(:issue_custom_field, :user) }
|
|
|
|
|
shared_let(:status) { create(:status) }
|
|
|
|
|
shared_let(:type) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:type_standard,
|
2023-03-07 15:47:03 +01:00
|
|
|
custom_fields: [custom_field1, custom_field2, custom_field_user])
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2025-02-24 15:07:44 +01:00
|
|
|
shared_let(:project1) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:project,
|
2022-02-02 21:48:06 +01:00
|
|
|
types: [type],
|
2023-03-07 15:47:03 +01:00
|
|
|
work_package_custom_fields: [custom_field2])
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2025-02-24 15:07:44 +01:00
|
|
|
shared_let(:project2) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:project,
|
2022-02-02 21:48:06 +01:00
|
|
|
types: [type])
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2025-02-24 15:07:44 +01:00
|
|
|
shared_let(:role) do
|
2023-10-05 15:28:31 +02:00
|
|
|
create(:project_role,
|
2022-02-02 21:48:06 +01:00
|
|
|
permissions: %i[edit_work_packages
|
2025-02-24 17:46:59 +01:00
|
|
|
delete_work_packages
|
2022-02-02 21:48:06 +01:00
|
|
|
view_work_packages
|
|
|
|
|
manage_subtasks
|
2022-03-02 14:59:51 +01:00
|
|
|
assign_versions
|
|
|
|
|
work_package_assigned])
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2025-02-24 15:07:44 +01:00
|
|
|
shared_let(:member1_p1) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:member,
|
2023-03-07 15:47:03 +01:00
|
|
|
project: project1,
|
2022-02-02 21:48:06 +01:00
|
|
|
principal: user,
|
|
|
|
|
roles: [role])
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2025-02-24 15:07:44 +01:00
|
|
|
shared_let(:member2_p1) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:member,
|
2023-03-07 15:47:03 +01:00
|
|
|
project: project1,
|
2022-02-02 21:48:06 +01:00
|
|
|
principal: user2,
|
|
|
|
|
roles: [role])
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2025-02-24 15:07:44 +01:00
|
|
|
shared_let(:member1_p2) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:member,
|
2023-03-07 15:47:03 +01:00
|
|
|
project: project2,
|
2022-02-02 21:48:06 +01:00
|
|
|
principal: user,
|
|
|
|
|
roles: [role])
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2025-05-09 17:27:37 +02:00
|
|
|
shared_let(:work_package1, refind: true) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:work_package,
|
2022-02-02 21:48:06 +01:00
|
|
|
author: user,
|
|
|
|
|
assigned_to: user,
|
|
|
|
|
responsible: user2,
|
|
|
|
|
type:,
|
|
|
|
|
status:,
|
2023-03-07 15:47:03 +01:00
|
|
|
custom_field_values: { custom_field1.id => custom_field_value },
|
|
|
|
|
project: project1)
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2025-05-09 17:27:37 +02:00
|
|
|
shared_let(:work_package2, refind: true) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:work_package,
|
2022-02-02 21:48:06 +01:00
|
|
|
author: user,
|
|
|
|
|
assigned_to: user,
|
|
|
|
|
responsible: user2,
|
|
|
|
|
type:,
|
|
|
|
|
status:,
|
2023-03-07 15:47:03 +01:00
|
|
|
custom_field_values: { custom_field1.id => custom_field_value },
|
|
|
|
|
project: project1)
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2025-05-09 17:27:37 +02:00
|
|
|
shared_let(:work_package3, refind: true) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:work_package,
|
2022-02-02 21:48:06 +01:00
|
|
|
author: user,
|
|
|
|
|
type:,
|
|
|
|
|
status:,
|
2023-03-07 15:47:03 +01:00
|
|
|
custom_field_values: { custom_field1.id => custom_field_value },
|
|
|
|
|
project: project2)
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2013-10-02 11:45:03 +02:00
|
|
|
|
2022-01-24 19:22:35 +01:00
|
|
|
let(:stub_work_package) { build_stubbed(:work_package) }
|
2013-10-24 13:34:34 +02:00
|
|
|
|
2013-10-02 11:45:03 +02:00
|
|
|
before do
|
2014-03-29 14:50:29 +01:00
|
|
|
allow(User).to receive(:current).and_return user
|
2013-10-02 11:45:03 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#edit" do
|
2013-10-02 11:45:03 +02:00
|
|
|
shared_examples_for "response" do
|
|
|
|
|
subject { response }
|
|
|
|
|
|
2018-11-23 15:06:32 +01:00
|
|
|
it { is_expected.to be_successful }
|
2013-10-02 11:45:03 +02:00
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to render_template("edit") }
|
2013-10-02 11:45:03 +02:00
|
|
|
end
|
|
|
|
|
|
2025-02-24 15:07:44 +01:00
|
|
|
context "within same project" do
|
2023-03-07 15:47:03 +01:00
|
|
|
before { get :edit, params: { ids: [work_package1.id, work_package2.id] } }
|
2013-10-02 11:45:03 +02:00
|
|
|
|
|
|
|
|
it_behaves_like "response"
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#view" do
|
2013-10-02 11:45:03 +02:00
|
|
|
render_views
|
|
|
|
|
|
|
|
|
|
subject { response }
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#parent" do
|
2015-10-02 21:43:05 +01:00
|
|
|
it { assert_select "input", attributes: { name: "work_package[parent_id]" } }
|
2013-10-02 11:45:03 +02:00
|
|
|
end
|
|
|
|
|
|
2026-05-26 23:15:27 +02:00
|
|
|
context "with work package list" do
|
|
|
|
|
context "with classic (numeric) identifiers" do
|
|
|
|
|
it "displays a hash-prefixed numeric id link for each work package" do
|
|
|
|
|
assert_select "ul li a", text: /\A#{Regexp.escape(work_package1.type.to_s)} ##{work_package1.id}\z/
|
|
|
|
|
assert_select "ul li a", text: /\A#{Regexp.escape(work_package2.type.to_s)} ##{work_package2.id}\z/
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "with semantic identifiers" do
|
|
|
|
|
let(:semantic_prefix) { "TESTPROJ" }
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
allow(Setting::WorkPackageIdentifier).to receive_messages(semantic?: true, classic?: false)
|
|
|
|
|
work_package1.update_columns(identifier: "#{semantic_prefix}-1", sequence_number: 1)
|
|
|
|
|
work_package2.update_columns(identifier: "#{semantic_prefix}-2", sequence_number: 2)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "displays the semantic identifier in each link" do
|
|
|
|
|
get :edit, params: { ids: [work_package1.id, work_package2.id] }
|
|
|
|
|
|
|
|
|
|
assert_select "ul li a", text: /#{semantic_prefix}-1/
|
|
|
|
|
assert_select "ul li a", text: /#{semantic_prefix}-2/
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "does not display a bare numeric id in the links" do
|
|
|
|
|
get :edit, params: { ids: [work_package1.id, work_package2.id] }
|
|
|
|
|
|
|
|
|
|
assert_select "ul li a", text: /##{work_package1.id}/, count: 0
|
|
|
|
|
assert_select "ul li a", text: /##{work_package2.id}/, count: 0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
context "custom_field" do
|
|
|
|
|
describe "#type" do
|
2023-03-07 15:47:03 +01:00
|
|
|
it { assert_select "input", attributes: { name: "work_package[custom_field_values][#{custom_field1.id}]" } }
|
2013-10-02 11:45:03 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#project" do
|
2023-03-07 15:47:03 +01:00
|
|
|
it { assert_select "select", attributes: { name: "work_package[custom_field_values][#{custom_field2.id}]" } }
|
2013-10-02 11:45:03 +02:00
|
|
|
end
|
2016-02-09 09:10:52 +01:00
|
|
|
|
|
|
|
|
describe "#user" do
|
|
|
|
|
it { assert_select "select", attributes: { name: "work_package[custom_field_values][#{custom_field_user.id}]" } }
|
|
|
|
|
end
|
2013-10-02 11:45:03 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-02-24 15:07:44 +01:00
|
|
|
context "with different projects" do
|
2013-10-02 11:45:03 +02:00
|
|
|
before do
|
2014-01-30 09:58:25 +01:00
|
|
|
member1_p2
|
2013-10-02 11:45:03 +02:00
|
|
|
|
2023-03-07 15:47:03 +01:00
|
|
|
get :edit, params: { ids: [work_package1.id, work_package2.id, work_package3.id] }
|
2013-10-02 11:45:03 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it_behaves_like "response"
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#view" do
|
2013-10-02 11:45:03 +02:00
|
|
|
render_views
|
|
|
|
|
|
|
|
|
|
subject { response }
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#parent" do
|
2020-08-18 08:24:34 +02:00
|
|
|
it { assert_select "input", { attributes: { name: "work_package[parent_id]" } }, false }
|
2013-10-02 11:45:03 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
context "custom_field" do
|
|
|
|
|
describe "#type" do
|
2023-03-07 15:47:03 +01:00
|
|
|
it { assert_select "input", attributes: { name: "work_package[custom_field_values][#{custom_field1.id}]" } }
|
2013-10-02 11:45:03 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#project" do
|
2021-02-11 16:02:18 +01:00
|
|
|
it {
|
2023-03-07 15:47:03 +01:00
|
|
|
assert_select "select", { attributes: { name: "work_package[custom_field_values][#{custom_field2.id}]" } }, false
|
2021-02-11 16:02:18 +01:00
|
|
|
}
|
2013-10-02 11:45:03 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#update" do
|
2023-03-07 15:47:03 +01:00
|
|
|
let(:work_package_ids) { [work_package1.id, work_package2.id] }
|
2015-06-26 11:23:13 +02:00
|
|
|
let(:work_packages) { WorkPackage.where(id: work_package_ids) }
|
2022-01-24 19:22:35 +01:00
|
|
|
let(:priority) { create(:priority_immediate) }
|
2013-10-08 12:26:11 +02:00
|
|
|
let(:group_id) { "" }
|
2014-11-03 23:43:33 +01:00
|
|
|
let(:responsible_id) { "" }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#redirect" do
|
2014-11-03 23:43:33 +01:00
|
|
|
context "in host" do
|
2013-10-08 12:26:11 +02:00
|
|
|
let(:url) { "/work_packages" }
|
|
|
|
|
|
2019-05-31 10:27:07 +02:00
|
|
|
before { put :update, params: { ids: work_package_ids, back_url: url } }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
|
|
|
|
subject { response }
|
|
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to be_redirect }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to redirect_to(url) }
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
context "of host" do
|
2013-10-08 12:26:11 +02:00
|
|
|
let(:url) { "http://google.com" }
|
|
|
|
|
|
2019-05-31 10:27:07 +02:00
|
|
|
before { put :update, params: { ids: work_package_ids, back_url: url } }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
|
|
|
|
subject { response }
|
|
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to be_redirect }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2023-03-07 15:47:03 +01:00
|
|
|
it { is_expected.to redirect_to(project_work_packages_path(project1)) }
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
end
|
2013-10-22 22:16:45 +02:00
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
shared_context "update_request" do
|
2013-10-08 12:26:11 +02:00
|
|
|
before do
|
2013-10-09 13:08:06 +02:00
|
|
|
put :update,
|
2016-10-17 10:21:42 +02:00
|
|
|
params: {
|
|
|
|
|
ids: work_package_ids,
|
|
|
|
|
work_package: { priority_id: priority.id,
|
|
|
|
|
assigned_to_id: group_id,
|
|
|
|
|
responsible_id:,
|
2021-12-22 14:18:11 +01:00
|
|
|
send_notification:,
|
|
|
|
|
journal_notes: "Bulk editing" }
|
2016-10-17 10:21:42 +02:00
|
|
|
}
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
shared_examples_for "delivered" do
|
|
|
|
|
subject { ActionMailer::Base.deliveries.size }
|
|
|
|
|
|
|
|
|
|
it { delivery_size }
|
|
|
|
|
end
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
context "with notification" do
|
2013-10-08 12:26:11 +02:00
|
|
|
let(:send_notification) { "1" }
|
|
|
|
|
let(:delivery_size) { 2 }
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
shared_examples_for "updated work package" do
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#priority" do
|
2015-06-26 11:23:13 +02:00
|
|
|
subject { WorkPackage.where(priority_id: priority.id).map(&:id) }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to match_array(work_package_ids) }
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#custom_fields" do
|
2013-10-08 12:26:11 +02:00
|
|
|
let(:result) { [custom_field_value] }
|
|
|
|
|
|
2019-05-31 10:27:07 +02:00
|
|
|
subject do
|
2015-06-26 11:23:13 +02:00
|
|
|
WorkPackage.where(id: work_package_ids)
|
2025-11-06 16:05:45 +02:00
|
|
|
.map { |w| w.custom_value_for(custom_field1).value }
|
2014-11-03 23:43:33 +01:00
|
|
|
.uniq
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to match_array(result) }
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#journal" do
|
|
|
|
|
describe "#notes" do
|
2013-10-08 12:26:11 +02:00
|
|
|
let(:result) { ["Bulk editing"] }
|
|
|
|
|
|
2019-05-31 10:27:07 +02:00
|
|
|
subject do
|
2015-06-26 11:23:13 +02:00
|
|
|
WorkPackage.where(id: work_package_ids)
|
2014-11-04 11:12:44 +01:00
|
|
|
.map { |w| w.last_journal.notes }
|
2014-11-03 23:43:33 +01:00
|
|
|
.uniq
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to match_array(result) }
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#details" do
|
2013-10-08 12:26:11 +02:00
|
|
|
let(:result) { [1] }
|
|
|
|
|
|
2019-05-31 10:27:07 +02:00
|
|
|
subject do
|
2015-06-26 11:23:13 +02:00
|
|
|
WorkPackage.where(id: work_package_ids)
|
2014-11-04 11:12:44 +01:00
|
|
|
.map { |w| w.last_journal.details.size }
|
2014-11-03 23:43:33 +01:00
|
|
|
.uniq
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to match_array(result) }
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-02-24 15:07:44 +01:00
|
|
|
context "with a single project" do
|
2015-02-03 22:16:25 +01:00
|
|
|
include_context "update_request"
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2014-03-29 14:50:29 +01:00
|
|
|
it { expect(response.response_code).to eq(302) }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
|
|
|
|
it_behaves_like "delivered"
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
it_behaves_like "updated work package"
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2025-02-24 15:07:44 +01:00
|
|
|
context "with different projects" do
|
2023-03-07 15:47:03 +01:00
|
|
|
let(:work_package_ids) { [work_package1.id, work_package2.id, work_package3.id] }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
context "with permission" do
|
2015-02-03 22:16:25 +01:00
|
|
|
include_context "update_request"
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2014-03-29 14:50:29 +01:00
|
|
|
it { expect(response.response_code).to eq(302) }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
|
|
|
|
it_behaves_like "delivered"
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
it_behaves_like "updated work package"
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2025-02-24 15:07:44 +01:00
|
|
|
context "without permission" do
|
2015-02-03 22:16:25 +01:00
|
|
|
include_context "update_request"
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2025-02-24 15:07:44 +01:00
|
|
|
before_all do
|
|
|
|
|
member1_p2.destroy
|
|
|
|
|
end
|
|
|
|
|
|
2014-03-29 14:50:29 +01:00
|
|
|
it { expect(response.response_code).to eq(403) }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#journal" do
|
2022-12-01 11:03:19 +01:00
|
|
|
subject { Journal.for_work_package.count }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to eq(work_package_ids.count) }
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#properties" do
|
|
|
|
|
describe "#groups" do
|
2022-01-24 19:22:35 +01:00
|
|
|
let(:group) { create(:group) }
|
2013-10-08 12:26:11 +02:00
|
|
|
let(:group_id) { group.id }
|
2022-05-31 11:55:27 +02:00
|
|
|
|
2018-11-01 09:30:15 +01:00
|
|
|
subject { work_packages.map(&:assigned_to_id).uniq }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2025-02-24 15:07:44 +01:00
|
|
|
context "when allowed" do
|
2019-05-31 10:27:07 +02:00
|
|
|
let!(:member_group_p1) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:member,
|
2023-03-07 15:47:03 +01:00
|
|
|
project: project1,
|
2022-02-02 21:48:06 +01:00
|
|
|
principal: group,
|
|
|
|
|
roles: [role])
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2018-11-01 09:30:15 +01:00
|
|
|
include_context "update_request"
|
|
|
|
|
it "does succeed" do
|
|
|
|
|
expect(flash[:error]).to be_nil
|
2023-09-27 17:53:04 +02:00
|
|
|
expect(subject).to contain_exactly(group.id)
|
2018-11-01 09:30:15 +01:00
|
|
|
end
|
|
|
|
|
end
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2025-02-24 15:07:44 +01:00
|
|
|
context "when not allowed" do
|
2021-12-22 14:18:11 +01:00
|
|
|
render_views
|
|
|
|
|
|
2018-11-01 09:30:15 +01:00
|
|
|
include_context "update_request"
|
|
|
|
|
|
|
|
|
|
it "does not succeed" do
|
2021-12-22 14:18:11 +01:00
|
|
|
expect(flash[:error])
|
|
|
|
|
.to include(I18n.t(:"work_packages.bulk.none_could_be_saved",
|
|
|
|
|
total: 2))
|
2023-09-27 17:53:04 +02:00
|
|
|
expect(subject).to contain_exactly(user.id)
|
2018-11-01 09:30:15 +01:00
|
|
|
end
|
|
|
|
|
end
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#responsible" do
|
2014-01-30 09:58:25 +01:00
|
|
|
let(:responsible_id) { user.id }
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
include_context "update_request"
|
2014-01-30 09:58:25 +01:00
|
|
|
|
2014-11-04 11:12:44 +01:00
|
|
|
subject { work_packages.map(&:responsible_id).uniq }
|
2014-01-30 09:58:25 +01:00
|
|
|
|
2023-09-27 17:53:04 +02:00
|
|
|
it { is_expected.to contain_exactly(responsible_id) }
|
2014-01-30 09:58:25 +01:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#status" do
|
2022-01-24 19:22:35 +01:00
|
|
|
let(:closed_status) { create(:closed_status) }
|
2019-05-31 10:27:07 +02:00
|
|
|
let(:workflow) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:workflow,
|
2022-02-02 21:48:06 +01:00
|
|
|
role:,
|
|
|
|
|
type_id: type.id,
|
|
|
|
|
old_status: status,
|
|
|
|
|
new_status: closed_status)
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2013-10-08 12:26:11 +02:00
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
workflow
|
|
|
|
|
|
2013-10-09 13:08:06 +02:00
|
|
|
put :update,
|
2016-10-17 10:21:42 +02:00
|
|
|
params: {
|
|
|
|
|
ids: work_package_ids,
|
|
|
|
|
work_package: { status_id: closed_status.id }
|
|
|
|
|
}
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2014-11-04 11:12:44 +01:00
|
|
|
subject { work_packages.map(&:status_id).uniq }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2023-09-27 17:53:04 +02:00
|
|
|
it { is_expected.to contain_exactly(closed_status.id) }
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#parent" do
|
2019-05-31 10:27:07 +02:00
|
|
|
let(:parent) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:work_package,
|
2022-02-02 21:48:06 +01:00
|
|
|
author: user,
|
2023-03-07 15:47:03 +01:00
|
|
|
project: project1)
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2013-10-08 12:26:11 +02:00
|
|
|
|
|
|
|
|
before do
|
2013-10-09 13:08:06 +02:00
|
|
|
put :update,
|
2016-10-17 10:21:42 +02:00
|
|
|
params: {
|
|
|
|
|
ids: work_package_ids,
|
|
|
|
|
work_package: { parent_id: parent.id }
|
|
|
|
|
}
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2014-11-04 11:12:44 +01:00
|
|
|
subject { work_packages.map(&:parent_id).uniq }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2023-09-27 17:53:04 +02:00
|
|
|
it { is_expected.to contain_exactly(parent.id) }
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#custom_fields" do
|
2013-10-08 12:26:11 +02:00
|
|
|
let(:result) { "777" }
|
|
|
|
|
|
|
|
|
|
before do
|
2013-10-09 13:08:06 +02:00
|
|
|
put :update,
|
2016-09-26 14:20:19 +02:00
|
|
|
params: {
|
|
|
|
|
ids: work_package_ids,
|
|
|
|
|
work_package: {
|
2023-03-07 15:47:03 +01:00
|
|
|
custom_field_values: { custom_field1.id.to_s => result }
|
2016-09-26 14:20:19 +02:00
|
|
|
}
|
|
|
|
|
}
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2019-05-31 10:27:07 +02:00
|
|
|
subject do
|
2025-11-06 16:05:45 +02:00
|
|
|
work_packages.map { |w| w.custom_value_for(custom_field1).value }
|
2016-09-09 14:15:50 +02:00
|
|
|
.uniq
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2023-09-27 17:53:04 +02:00
|
|
|
it { is_expected.to contain_exactly(result) }
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#unassign" do
|
2013-10-08 12:26:11 +02:00
|
|
|
before do
|
2013-10-09 13:08:06 +02:00
|
|
|
put :update,
|
2016-10-17 10:21:42 +02:00
|
|
|
params: {
|
|
|
|
|
ids: work_package_ids,
|
|
|
|
|
work_package: { assigned_to_id: "none" }
|
|
|
|
|
}
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2014-11-04 11:12:44 +01:00
|
|
|
subject { work_packages.map(&:assigned_to_id).uniq }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2023-09-27 17:53:04 +02:00
|
|
|
it { is_expected.to contain_exactly(nil) }
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#delete_responsible" do
|
2014-01-30 09:58:25 +01:00
|
|
|
before do
|
|
|
|
|
put :update,
|
2016-10-17 10:21:42 +02:00
|
|
|
params: {
|
|
|
|
|
ids: work_package_ids,
|
|
|
|
|
work_package: { responsible_id: "none" }
|
|
|
|
|
}
|
2014-01-30 09:58:25 +01:00
|
|
|
end
|
|
|
|
|
|
2014-11-04 11:12:44 +01:00
|
|
|
subject { work_packages.map(&:responsible_id).uniq }
|
2014-01-30 09:58:25 +01:00
|
|
|
|
2023-09-27 17:53:04 +02:00
|
|
|
it { is_expected.to contain_exactly(nil) }
|
2014-01-30 09:58:25 +01:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#version" do
|
2020-03-26 15:37:24 +01:00
|
|
|
describe "set version_id attribute to some version" do
|
2025-02-24 15:07:44 +01:00
|
|
|
shared_let(:subproject) do
|
|
|
|
|
create(:project,
|
|
|
|
|
parent: project1,
|
|
|
|
|
types: [type])
|
|
|
|
|
end
|
|
|
|
|
shared_let(:version) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:version,
|
2022-02-02 21:48:06 +01:00
|
|
|
status: "open",
|
|
|
|
|
sharing: "tree",
|
|
|
|
|
project: subproject)
|
2019-05-31 10:27:07 +02:00
|
|
|
end
|
2013-11-13 12:21:29 +01:00
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
put :update,
|
2016-10-17 10:21:42 +02:00
|
|
|
params: {
|
|
|
|
|
ids: work_package_ids,
|
2020-03-26 15:37:24 +01:00
|
|
|
work_package: { version_id: version.id.to_s }
|
2016-10-17 10:21:42 +02:00
|
|
|
}
|
2013-11-13 12:21:29 +01:00
|
|
|
end
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2013-11-13 12:21:29 +01:00
|
|
|
subject { response }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to be_redirect }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#work_package" do
|
2020-03-26 15:37:24 +01:00
|
|
|
describe "#version" do
|
|
|
|
|
subject { work_packages.map(&:version_id).uniq }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2023-09-27 17:53:04 +02:00
|
|
|
it { is_expected.to contain_exactly(version.id) }
|
2013-11-13 12:21:29 +01:00
|
|
|
end
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#project" do
|
2014-11-04 11:12:44 +01:00
|
|
|
subject { work_packages.map(&:project_id).uniq }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2023-09-27 17:53:04 +02:00
|
|
|
it { is_expected.not_to contain_exactly(subproject.id) }
|
2013-11-13 12:21:29 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2022-05-31 11:55:27 +02:00
|
|
|
|
2020-03-26 15:37:24 +01:00
|
|
|
describe "set version_id to nil" do
|
2013-11-13 12:21:29 +01:00
|
|
|
before do
|
2020-03-26 15:37:24 +01:00
|
|
|
# 'none' is a magic value, setting version_id to nil
|
2013-11-13 12:21:29 +01:00
|
|
|
# will make the controller ignore that param
|
|
|
|
|
put :update,
|
2016-10-17 10:21:42 +02:00
|
|
|
params: {
|
|
|
|
|
ids: work_package_ids,
|
2020-03-26 15:37:24 +01:00
|
|
|
work_package: { version_id: "none" }
|
2016-10-17 10:21:42 +02:00
|
|
|
}
|
2013-11-13 12:21:29 +01:00
|
|
|
end
|
2022-05-31 11:55:27 +02:00
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#work_package" do
|
2020-03-26 15:37:24 +01:00
|
|
|
describe "#version" do
|
|
|
|
|
subject { work_packages.map(&:version_id).uniq }
|
2013-10-08 12:26:11 +02:00
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to eq([nil]) }
|
2013-11-13 12:21:29 +01:00
|
|
|
end
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2025-08-29 11:45:27 +02:00
|
|
|
|
|
|
|
|
describe "#done_ratio" do
|
|
|
|
|
before do
|
|
|
|
|
put :update,
|
|
|
|
|
params: {
|
|
|
|
|
ids: work_package_ids,
|
|
|
|
|
work_package: { done_ratio: }
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "with a valid done_ratio" do
|
|
|
|
|
let(:done_ratio) { 55 }
|
|
|
|
|
|
|
|
|
|
subject { work_packages.map(&:done_ratio).uniq }
|
|
|
|
|
|
|
|
|
|
it { is_expected.to contain_exactly(55) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "with an invalid done_ratio" do
|
|
|
|
|
let(:done_ratio) { 150 }
|
|
|
|
|
|
|
|
|
|
subject { work_packages.map(&:done_ratio).uniq }
|
|
|
|
|
|
|
|
|
|
it "does not succeed" do
|
|
|
|
|
expect(flash[:error])
|
|
|
|
|
.to include(I18n.t(:"work_packages.bulk.none_could_be_saved",
|
|
|
|
|
total: 2))
|
|
|
|
|
|
|
|
|
|
expect(subject).to contain_exactly(nil)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2013-10-08 12:26:11 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-02-24 15:07:44 +01:00
|
|
|
context "without notification" do
|
2013-10-08 12:26:11 +02:00
|
|
|
let(:send_notification) { "0" }
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#delivery" do
|
|
|
|
|
include_context "update_request"
|
2013-10-08 12:26:11 +02:00
|
|
|
|
|
|
|
|
let(:delivery_size) { 0 }
|
|
|
|
|
|
2014-03-29 14:50:29 +01:00
|
|
|
it { expect(response.response_code).to eq(302) }
|
2022-05-31 11:55:27 +02:00
|
|
|
|
2013-10-08 12:26:11 +02:00
|
|
|
it_behaves_like "delivered"
|
|
|
|
|
end
|
|
|
|
|
end
|
2026-05-26 22:52:38 +02:00
|
|
|
|
|
|
|
|
context "with semantic identifiers",
|
|
|
|
|
with_settings: { work_packages_identifier: "semantic" } do
|
|
|
|
|
before do
|
|
|
|
|
work_package1.update_columns(identifier: "PROJ-1", sequence_number: 1)
|
|
|
|
|
work_package2.update_columns(identifier: "PROJ-2", sequence_number: 2)
|
|
|
|
|
put :update,
|
|
|
|
|
params: {
|
|
|
|
|
ids: work_package_ids,
|
|
|
|
|
work_package: { done_ratio: 150 }
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "shows semantic identifiers in the error flash" do
|
|
|
|
|
expect(flash[:error]).to include("PROJ-1")
|
|
|
|
|
expect(flash[:error]).to include("PROJ-2")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "does not show bare numeric ids in the error flash" do
|
|
|
|
|
expect(flash[:error]).not_to include("##{work_package1.id}")
|
|
|
|
|
expect(flash[:error]).not_to include("##{work_package2.id}")
|
|
|
|
|
end
|
|
|
|
|
end
|
2018-11-01 09:30:15 +01:00
|
|
|
|
|
|
|
|
describe "updating two children with dates to a new parent (Regression #28670)" do
|
|
|
|
|
let(:task1) do
|
2023-03-07 15:04:32 +01:00
|
|
|
create(:work_package,
|
2023-03-07 15:47:03 +01:00
|
|
|
project: project1,
|
|
|
|
|
start_date: 5.days.ago,
|
|
|
|
|
due_date: Date.current)
|
2018-11-01 09:30:15 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
let(:task2) do
|
2023-03-07 15:04:32 +01:00
|
|
|
create(:work_package,
|
2023-03-07 15:47:03 +01:00
|
|
|
project: project1,
|
|
|
|
|
start_date: 2.days.ago,
|
|
|
|
|
due_date: 1.day.from_now)
|
2018-11-01 09:30:15 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
let(:new_parent) do
|
2024-11-28 16:56:20 +01:00
|
|
|
create(:work_package, schedule_manually: false, project: project1)
|
2018-11-01 09:30:15 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
put :update,
|
|
|
|
|
params: {
|
|
|
|
|
ids: [task1.id, task2.id],
|
|
|
|
|
notes: "Bulk editing",
|
|
|
|
|
work_package: { parent_id: new_parent.id }
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
2022-03-19 23:26:32 +01:00
|
|
|
it "updates the parent dates as well" do
|
2018-11-01 09:30:15 +01:00
|
|
|
expect(response.response_code).to eq(302)
|
|
|
|
|
|
|
|
|
|
task1.reload
|
|
|
|
|
task2.reload
|
|
|
|
|
new_parent.reload
|
|
|
|
|
|
|
|
|
|
expect(task1.parent_id).to eq(new_parent.id)
|
|
|
|
|
expect(task2.parent_id).to eq(new_parent.id)
|
|
|
|
|
|
2023-03-07 15:47:03 +01:00
|
|
|
expect(new_parent.start_date).to eq(task1.start_date)
|
|
|
|
|
expect(new_parent.due_date).to eq(task2.due_date)
|
2018-11-01 09:30:15 +01:00
|
|
|
end
|
|
|
|
|
end
|
2026-05-22 17:46:08 +02:00
|
|
|
|
|
|
|
|
describe "bulk parent assignment with semantic identifiers",
|
|
|
|
|
with_settings: { work_packages_identifier: "semantic" } do
|
|
|
|
|
let(:sem_project) do
|
|
|
|
|
create(:project, identifier: "SEMPROJ", types: [type]).tap do |p|
|
|
|
|
|
create(:member, project: p, principal: user, roles: [role])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
let(:parent_wp) { create(:work_package, project: sem_project).reload }
|
|
|
|
|
let(:child1) { create(:work_package, project: sem_project).reload }
|
|
|
|
|
let(:child2) { create(:work_package, project: sem_project).reload }
|
|
|
|
|
|
|
|
|
|
it "accepts a semantic identifier and assigns the parent" do
|
|
|
|
|
put :update,
|
|
|
|
|
params: {
|
|
|
|
|
ids: [child1.id, child2.id],
|
|
|
|
|
work_package: { parent_id: parent_wp.identifier }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expect(response).to have_http_status(:found)
|
|
|
|
|
expect(child1.reload.parent_id).to eq(parent_wp.id)
|
|
|
|
|
expect(child2.reload.parent_id).to eq(parent_wp.id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "reports an error for an unknown semantic identifier" do
|
|
|
|
|
put :update,
|
|
|
|
|
params: {
|
|
|
|
|
ids: [child1.id, child2.id],
|
|
|
|
|
work_package: { parent_id: "SEMPROJ-9999" }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expect(flash[:error]).to be_present
|
|
|
|
|
expect(child1.reload.parent_id).to be_nil
|
|
|
|
|
expect(child2.reload.parent_id).to be_nil
|
|
|
|
|
end
|
|
|
|
|
end
|
2013-10-02 11:45:03 +02:00
|
|
|
end
|
2013-10-24 13:34:34 +02:00
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#destroy" do
|
2025-02-24 17:46:59 +01:00
|
|
|
def send_destroy_request
|
|
|
|
|
as_logged_in_user(user) do
|
|
|
|
|
delete :destroy, params:
|
2013-10-24 13:34:34 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-02-24 15:07:44 +01:00
|
|
|
describe "with the cleanup being successful" do
|
2025-02-24 17:46:59 +01:00
|
|
|
let(:params) { { "ids" => [work_package1.id, work_package2.id] } }
|
2018-04-12 07:22:17 +02:00
|
|
|
|
2025-02-24 17:46:59 +01:00
|
|
|
it "deletes the work packages and redirects to the project" do
|
|
|
|
|
send_destroy_request
|
|
|
|
|
expect(WorkPackage.find_by(id: [work_package1.id, work_package2.id])).to be_nil
|
|
|
|
|
expect(response).to redirect_to(project_work_packages_path(work_package1.project))
|
|
|
|
|
end
|
|
|
|
|
end
|
2018-04-12 07:22:17 +02:00
|
|
|
|
2025-02-24 17:46:59 +01:00
|
|
|
describe "with the cleanup being unsuccessful" do
|
|
|
|
|
let(:params) { { "ids" => [work_package1.id, work_package2.id], "to_do" => "blubs" } }
|
2013-10-24 13:34:34 +02:00
|
|
|
|
2025-02-24 17:46:59 +01:00
|
|
|
before do
|
|
|
|
|
allow(WorkPackage).to receive(:cleanup_associated_before_destructing_if_required)
|
|
|
|
|
.with([work_package1, work_package2], user, params["to_do"])
|
|
|
|
|
.and_return false
|
2013-10-24 13:34:34 +02:00
|
|
|
end
|
|
|
|
|
|
2026-02-02 10:30:14 +01:00
|
|
|
it "does not delete the work packages and redirects to the reassign action" do
|
2025-02-24 17:46:59 +01:00
|
|
|
send_destroy_request
|
|
|
|
|
expect(WorkPackage.find_by(id: work_package1.id)).to be_present
|
|
|
|
|
expect(WorkPackage.find_by(id: work_package2.id)).to be_present
|
2026-02-02 10:30:14 +01:00
|
|
|
expect(response).to redirect_to(reassign_work_packages_bulk_path(ids: [work_package1.id, work_package2.id]))
|
2013-10-24 13:34:34 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-02-24 17:46:59 +01:00
|
|
|
context "with work packages being related (parent, child, and successor)" do
|
|
|
|
|
let(:params) { { "ids" => [work_package1.id, work_package2.id, work_package3.id] } }
|
2013-10-24 13:34:34 +02:00
|
|
|
|
2025-02-24 17:46:59 +01:00
|
|
|
before do
|
|
|
|
|
work_package1.update(subject: "wp", schedule_manually: false)
|
|
|
|
|
work_package2.update(subject: "child of wp", parent: work_package1)
|
|
|
|
|
work_package3.update(subject: "successor of wp")
|
|
|
|
|
create(:follows_relation, predecessor: work_package1, successor: work_package3)
|
2013-10-24 13:34:34 +02:00
|
|
|
end
|
|
|
|
|
|
2025-02-24 17:46:59 +01:00
|
|
|
it "deletes them all without errors" do
|
|
|
|
|
send_destroy_request
|
|
|
|
|
expect(WorkPackage.count).to eq(0)
|
|
|
|
|
expect(response).to redirect_to(project_work_packages_path(work_package1.project))
|
2013-10-24 13:34:34 +02:00
|
|
|
end
|
|
|
|
|
end
|
2025-05-09 17:27:37 +02:00
|
|
|
|
|
|
|
|
context "with children work packages following each other" do
|
|
|
|
|
before_all do
|
|
|
|
|
work_package1.update(subject: "parent", schedule_manually: false)
|
|
|
|
|
work_package2.update(subject: "predecessor child", parent: work_package1, schedule_manually: true)
|
|
|
|
|
work_package3.update(subject: "successor child", parent: work_package1, schedule_manually: false)
|
|
|
|
|
create(:follows_relation, predecessor: work_package2, successor: work_package3)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
let(:params) { { "ids" => [work_package1.id, work_package2.id, work_package3.id] } }
|
|
|
|
|
|
|
|
|
|
it "deletes them all without errors" do
|
2025-05-12 10:13:34 +02:00
|
|
|
expect { send_destroy_request }.not_to raise_error
|
2025-05-09 17:27:37 +02:00
|
|
|
|
|
|
|
|
expect(WorkPackage.count).to eq(0)
|
|
|
|
|
expect(response).to redirect_to(project_work_packages_path(project1))
|
|
|
|
|
end
|
|
|
|
|
end
|
2013-10-24 13:34:34 +02:00
|
|
|
end
|
2013-10-02 11:45:03 +02:00
|
|
|
end
|