Files

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

126 lines
3.6 KiB
Ruby
Raw Permalink Normal View History

2025-05-05 09:29:55 +02:00
# frozen_string_literal: true
#-- copyright
2020-01-15 11:31:26 +01:00
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
#
# 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
# 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.
#++
require "spec_helper"
2023-05-31 12:15:15 +02:00
RSpec.describe Projects::Settings::ModulesController, "menu" do
let(:current_user) { create(:admin) }
2021-11-01 13:58:57 +01:00
let(:project) do
# project contains wiki by default
2022-01-24 19:22:35 +01:00
create(:project, enabled_module_names: enabled_modules).tap(&:reload)
2021-11-01 13:58:57 +01:00
end
let(:enabled_modules) { %w[wiki] }
let(:params) { { project_id: project.id } }
before do
login_as(current_user)
2021-11-01 13:58:57 +01:00
end
2021-11-01 13:58:57 +01:00
shared_examples_for "renders the modules show page" do
it "renders show" do
2023-03-07 15:07:44 +01:00
get("show", params:)
2021-11-01 13:58:57 +01:00
expect(response).to be_successful
expect(response).to render_template "projects/settings/modules/show"
end
end
2021-11-01 13:58:57 +01:00
shared_examples_for "has selector" do |selector|
render_views
2021-11-01 13:58:57 +01:00
it do
2023-03-07 15:07:44 +01:00
get("show", params:)
2021-11-01 13:58:57 +01:00
expect(response.body).to have_selector selector
end
end
2021-11-01 13:58:57 +01:00
shared_examples_for "has no selector" do |selector|
render_views
2021-11-01 13:58:57 +01:00
it do
2023-03-07 15:07:44 +01:00
get("show", params:)
2021-11-01 13:58:57 +01:00
2024-01-04 17:01:17 +01:00
expect(response.body).to have_no_selector selector
end
2021-11-01 13:58:57 +01:00
end
2021-11-01 13:58:57 +01:00
describe "show" do
describe "without wiki" do
before do
2021-11-01 13:58:57 +01:00
project.wiki.destroy
project.reload
end
2021-11-01 13:58:57 +01:00
it_behaves_like "renders the modules show page"
2021-11-01 13:58:57 +01:00
it_behaves_like "has no selector", "#main-menu a.wiki-wiki-menu-item"
end
2021-11-01 13:58:57 +01:00
describe "with wiki" do
describe "without custom wiki menu items" do
it_behaves_like "has selector", "#main-menu a.wiki-wiki-menu-item"
end
describe "with custom wiki menu item" do
before do
2022-01-24 19:22:35 +01:00
main_item = create(:wiki_menu_item,
navigatable_id: project.wiki.id,
name: "example",
title: "Example Title")
2022-01-24 19:22:35 +01:00
create(:wiki_menu_item,
navigatable_id: project.wiki.id,
name: "sub",
title: "Sub Title",
parent_id: main_item.id)
end
2021-11-01 13:58:57 +01:00
it_behaves_like "renders the modules show page"
2021-11-01 13:58:57 +01:00
it_behaves_like "has selector", "#main-menu a.wiki-example-menu-item"
end
end
describe "with activated activity module" do
2021-11-01 13:58:57 +01:00
let(:enabled_modules) { %w[activity] }
2021-11-01 13:58:57 +01:00
it_behaves_like "renders the modules show page"
2021-11-01 13:58:57 +01:00
it_behaves_like "has selector", "#main-menu a.activity-menu-item"
end
describe "without activated activity module" do
2021-11-01 13:58:57 +01:00
it_behaves_like "renders the modules show page"
2021-11-01 13:58:57 +01:00
it_behaves_like "has no selector", "#main-menu a.activity-menu-item"
end
end
end