Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

187 lines
4.4 KiB
Ruby
Raw Permalink Normal View History

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.
# 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.
#
# 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,
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,
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,
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,
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,
id: 2102,
project:)
2021-02-11 16:02:18 +01:00
end
2013-09-30 15:29:36 +02:00
before do
member
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
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 }
it { is_expected.to be_successful }
2013-09-30 15:29:36 +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 }
it { is_expected.to be_successful }
2013-09-30 15:29:36 +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
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
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
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
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
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
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
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
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 }
it { is_expected.to be_redirect }
2013-09-30 15:29:36 +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