2025-05-05 09:29:55 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2013-09-30 15:29:36 +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-09-30 15:29:36 +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-09-30 15:29:36 +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-09-30 15:29:36 +02:00
|
|
|
#++
|
|
|
|
|
|
|
|
|
|
require "spec_helper"
|
|
|
|
|
|
2023-05-31 12:15:15 +02:00
|
|
|
RSpec.describe WorkPackages::ReportsController do
|
2022-01-24 19:22:35 +01:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
let(:project) { create(:project) }
|
2021-02-11 16:02:18 +01:00
|
|
|
let(:role) do
|
2023-10-05 15:28:31 +02:00
|
|
|
create(:project_role,
|
2022-02-02 21:48:06 +01:00
|
|
|
permissions: [:view_work_packages])
|
2021-02-11 16:02:18 +01:00
|
|
|
end
|
|
|
|
|
let(:member) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:member,
|
2022-02-02 21:48:06 +01:00
|
|
|
project:,
|
|
|
|
|
principal: user,
|
|
|
|
|
roles: [role])
|
2021-02-11 16:02:18 +01:00
|
|
|
end
|
|
|
|
|
let(:work_package_1) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:work_package,
|
2022-02-02 21:48:06 +01:00
|
|
|
id: 21,
|
|
|
|
|
subject: "Can't print recipes",
|
|
|
|
|
project:)
|
2021-02-11 16:02:18 +01:00
|
|
|
end
|
|
|
|
|
let(:work_package_2) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:work_package,
|
2022-02-02 21:48:06 +01:00
|
|
|
id: 2101,
|
|
|
|
|
subject: "Error 281 when updating a recipe",
|
|
|
|
|
project:)
|
2021-02-11 16:02:18 +01:00
|
|
|
end
|
|
|
|
|
let(:work_package_3) do
|
2022-01-24 19:22:35 +01:00
|
|
|
create(:work_package,
|
2022-02-02 21:48:06 +01:00
|
|
|
id: 2102,
|
|
|
|
|
project:)
|
2021-02-11 16:02:18 +01:00
|
|
|
end
|
2013-09-30 15:29:36 +02:00
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
member
|
|
|
|
|
|
2014-03-29 14:50:29 +01:00
|
|
|
allow(User).to receive(:current).and_return user
|
2013-09-30 15:29:36 +02:00
|
|
|
|
|
|
|
|
work_package_1
|
|
|
|
|
work_package_2
|
|
|
|
|
work_package_3
|
|
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#report" do
|
2014-11-03 23:43:33 +01:00
|
|
|
describe "w/o details" do
|
2016-10-17 10:21:42 +02:00
|
|
|
before do
|
|
|
|
|
get :report,
|
|
|
|
|
params: { project_id: project.id }
|
|
|
|
|
end
|
2013-09-30 15:29:36 +02:00
|
|
|
|
|
|
|
|
subject { response }
|
|
|
|
|
|
2018-11-23 15:06:32 +01:00
|
|
|
it { is_expected.to be_successful }
|
2013-09-30 15:29:36 +02:00
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to render_template("report") }
|
2013-09-30 15:29:36 +02:00
|
|
|
|
|
|
|
|
it { assigns :work_packages_by_type }
|
|
|
|
|
|
|
|
|
|
it { assigns :work_packages_by_version }
|
|
|
|
|
|
|
|
|
|
it { assigns :work_packages_by_category }
|
|
|
|
|
|
|
|
|
|
it { assigns :work_packages_by_assigned_to }
|
|
|
|
|
|
2014-02-03 11:12:35 +01:00
|
|
|
it { assigns :work_packages_by_responsible }
|
|
|
|
|
|
2013-09-30 15:29:36 +02:00
|
|
|
it { assigns :work_packages_by_author }
|
|
|
|
|
|
|
|
|
|
it { assigns :work_packages_by_subproject }
|
|
|
|
|
end
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
describe "with details" do
|
|
|
|
|
shared_examples_for "details view" do
|
2016-10-17 10:21:42 +02:00
|
|
|
before do
|
|
|
|
|
get :report_details,
|
|
|
|
|
params: { project_id: project.id, detail: }
|
|
|
|
|
end
|
2013-09-30 15:29:36 +02:00
|
|
|
|
|
|
|
|
subject { response }
|
|
|
|
|
|
2018-11-23 15:06:32 +01:00
|
|
|
it { is_expected.to be_successful }
|
2013-09-30 15:29:36 +02:00
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to render_template("report_details") }
|
2013-09-30 15:29:36 +02:00
|
|
|
|
|
|
|
|
it { assigns :field }
|
|
|
|
|
|
|
|
|
|
it { assigns :rows }
|
|
|
|
|
|
|
|
|
|
it { assigns :data }
|
|
|
|
|
|
|
|
|
|
it { assigns :report_title }
|
|
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#type" do
|
2013-09-30 15:29:36 +02:00
|
|
|
let(:detail) { "type" }
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
it_behaves_like "details view"
|
2013-09-30 15:29:36 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#version" do
|
2013-09-30 15:29:36 +02:00
|
|
|
let(:detail) { "version" }
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
it_behaves_like "details view"
|
2013-09-30 15:29:36 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#priority" do
|
2013-09-30 15:29:36 +02:00
|
|
|
let(:detail) { "priority" }
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
it_behaves_like "details view"
|
2013-09-30 15:29:36 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#category" do
|
2013-09-30 15:29:36 +02:00
|
|
|
let(:detail) { "category" }
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
it_behaves_like "details view"
|
2013-09-30 15:29:36 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#assigned_to" do
|
2013-09-30 15:29:36 +02:00
|
|
|
let(:detail) { "assigned_to" }
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
it_behaves_like "details view"
|
2013-09-30 15:29:36 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#responsible" do
|
2014-02-03 11:12:35 +01:00
|
|
|
let(:detail) { "responsible" }
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
it_behaves_like "details view"
|
2014-02-03 11:12:35 +01:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#author" do
|
2013-09-30 15:29:36 +02:00
|
|
|
let(:detail) { "author" }
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
it_behaves_like "details view"
|
2013-09-30 15:29:36 +02:00
|
|
|
end
|
|
|
|
|
|
2015-02-03 22:16:25 +01:00
|
|
|
describe "#subproject" do
|
2013-09-30 15:29:36 +02:00
|
|
|
let(:detail) { "subproject" }
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
it_behaves_like "details view"
|
2013-09-30 15:29:36 +02:00
|
|
|
end
|
|
|
|
|
|
2014-11-03 23:43:33 +01:00
|
|
|
context "invalid detail" do
|
2016-10-17 10:21:42 +02:00
|
|
|
before do
|
|
|
|
|
get :report_details,
|
|
|
|
|
params: { project_id: project.id, detail: "invalid" }
|
|
|
|
|
end
|
2013-09-30 15:29:36 +02:00
|
|
|
|
|
|
|
|
subject { response }
|
|
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to be_redirect }
|
2013-09-30 15:29:36 +02:00
|
|
|
|
2014-04-17 23:35:32 +02:00
|
|
|
it { is_expected.to redirect_to(report_project_work_packages_path(project.identifier)) }
|
2013-09-30 15:29:36 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|