OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Move project_settings_path to ApplicationHelper to be globally available and start adapting tests to new structure
Henriette Dingercbc530ca9db0
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rbindex b55292988a6..45a4bc28316 100644--- a/app/controllers/application_controller.rb+++ b/app/controllers/application_controller.rb@@ -43,6 +43,7 @@ class ApplicationController < ActionController::Baseinclude Redmine::I18ninclude HookHelperinclude ErrorsHelper+ include ApplicationHelperinclude ::OpenProject::Authentication::SessionExpiryinclude AdditionalUrlHelpersinclude OpenProjectErrorHelperdiff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rbindex db6342cc6fa..8d8eea83977 100644--- a/app/controllers/categories_controller.rb+++ b/app/controllers/categories_controller.rb@@ -47,7 +47,7 @@ class CategoriesController < ApplicationControllerrespond_to do |format|format.html doflash[:notice] = l(:notice_successful_create)- redirect_to controller: '/project_settings', action: 'show', tab: 'categories', id: @project+ redirect_to settings_project_path(@project, tab: 'categories')endformat.js dorender locals: { project: @project, category: @category }@@ -69,7 +69,7 @@ class CategoriesController < ApplicationController@category.attributes = permitted_params.categoryif @category.saveflash[:notice] = l(:notice_successful_update)- redirect_to controller: '/project_settings', action: 'show', tab: 'categories', id: @project+ redirect_to settings_project_path(@project, tab: 'categories')elserender action: 'edit'end@@ -80,12 +80,12 @@ class CategoriesController < ApplicationControllerif @issue_count == 0# No issue assigned to this category@category.destroy- redirect_to controller: '/project_settings', action: 'show', id: @project, tab: 'categories'+ redirect_to settings_project_path(@project, tab: 'categories')returnelsif params[:todo]reassign_to = @project.categories.find_by(id: params[:reassign_to_id]) if params[:todo] == 'reassign'@category.destroy(reassign_to)- redirect_to controller: '/project_settings', action: 'show', id: @project, tab: 'categories'+ redirect_to settings_project_path(@project, tab: 'categories')returnend@categories = @project.categories - [@category]diff --git a/app/controllers/project_enumerations_controller.rb b/app/controllers/project_enumerations_controller.rbindex 9a35834c477..45b331bba06 100644--- a/app/controllers/project_enumerations_controller.rb+++ b/app/controllers/project_enumerations_controller.rb@@ -42,7 +42,7 @@ class ProjectEnumerationsController < ApplicationControllerflash[:notice] = l(:notice_successful_update)end- redirect_to settings_project_path(id: @project, tab: 'activities')+ redirect_to settings_project_path(@project, tab: 'activities')enddef destroy@@ -50,6 +50,6 @@ class ProjectEnumerationsController < ApplicationControllerflash[:notice] = l(:notice_successful_update)- redirect_to settings_project_path(id: @project, tab: 'activities')+ redirect_to settings_project_path(@project, tab: 'activities')endenddiff --git a/app/controllers/project_settings_controller.rb b/app/controllers/project_settings_controller.rbindex bf668033fcb..bbd3b8b594d 100644--- a/app/controllers/project_settings_controller.rb+++ b/app/controllers/project_settings_controller.rb@@ -34,6 +34,7 @@ class ProjectSettingsController < ApplicationControllerdef show; endprivate+def find_project@project = Project.find(params[:id])rescue ActiveRecord::RecordNotFounddiff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rbindex 84f0bf20f91..9257bb612a7 100644--- a/app/controllers/versions_controller.rb+++ b/app/controllers/versions_controller.rb@@ -103,7 +103,7 @@ class VersionsController < ApplicationControllerif request.put?@project.close_completed_versionsend- redirect_to settings_project_path(tab: 'versions', id: @project)+ redirect_to settings_project_path(@project, tab: 'versions')enddef destroy@@ -116,13 +116,13 @@ class VersionsController < ApplicationControllerflash[:error] = call.errors.full_messagesend- redirect_to settings_project_path(tab: 'versions', id: @project)+ redirect_to settings_project_path(@project, tab: 'versions')endprivatedef redirect_back_or_version_settings- redirect_back_or_default(settings_project_path(tab: 'versions', id: @project))+ redirect_back_or_default(settings_project_path(@project, tab: 'versions'))enddef find_projectdiff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex 271307ce1a6..a53c4c8f37b 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -527,4 +527,12 @@ module ApplicationHelpers += raw '<br /><em>' + rules + '</em>' unless rules.empty?send++ def settings_project_path(project, opts = {})+ if opts[:tab]+ url_for controller: "project_settings/#{opts[:tab]}", action: 'show', only_path: true, id: project+ else+ url_for controller: "project_settings/generic", action: 'show', only_path: true, id: project+ end+ endenddiff --git a/app/helpers/project_settings_helper.rb b/app/helpers/project_settings_helper.rbindex 2427b4a79ad..0a1b5d6428a 100644--- a/app/helpers/project_settings_helper.rb+++ b/app/helpers/project_settings_helper.rb@@ -31,7 +31,7 @@module ProjectSettingsHelperextend selfdef project_settings_tabs- tabs = [+ [{name: 'generic',action: { controller: '/project_settings/generic', action: 'show' },@@ -74,5 +74,4 @@ module ProjectSettingsHelper}]end-enddiff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rbindex 2e8c3296682..730f42e4ffb 100644--- a/app/helpers/projects_helper.rb+++ b/app/helpers/projects_helper.rb@@ -41,14 +41,6 @@ module ProjectsHelperhtml_optionsend- def settings_project_path(project, opts = {})- if opts[:tab]- url_for controller: "project_settings/#{opts[:tab]}", action: 'show', only_path: true, id: project- else- url_for controller: "project_settings", action: 'show', only_path: true, id: project- end- end-# Returns a set of options for a select field, grouped by project.def version_options_for_select(versions, selected = nil)grouped = Hash.new { |h, k| h[k] = [] }@@ -115,9 +107,9 @@ module ProjectsHelperenddef project_more_menu_settings_item(project)- if User.current.allowed_to?({ controller: '/project_settings', action: 'show' }, project)+ if User.current.allowed_to?({ controller: '/project_settings/generic', action: 'show' }, project)[t(:label_project_settings),- { controller: '/project_settings', action: 'show', id: project },+ { controller: '/project_settings/generic', action: 'show', id: project },class: 'icon-context icon-settings',title: t(:label_project_settings)]enddiff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rbindex 690d6009d10..dfd69cee82e 100644--- a/app/helpers/repositories_helper.rb+++ b/app/helpers/repositories_helper.rb@@ -249,10 +249,9 @@ module RepositoriesHelperscm_options(repository),class: 'form--select repositories--remote-select',data: {- url: url_for(controller: '/project_settings',+ url: url_for(controller: '/project_settings/repository',action: 'show',- tab: 'repository',- project_id: @project.id),+ id: @project.id),},disabled: (repository && !repository.new_record?))diff --git a/config/routes.rb b/config/routes.rbindex 422836deaee..1d52449062e 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -175,8 +175,6 @@ OpenProject::Application.routes.draw doget "settings/#{tab[:name]}", controller: "project_settings/#{tab[:name]}", action: 'show', as: "settings_#{tab[:name]}"end- get 'settings', controller: 'project_settings/generic', action: 'show', as: :settings-get 'identifier', action: 'identifier'patch 'identifier', action: 'update_identifier'diff --git a/lib/api/v3/work_packages/create_form_representer.rb b/lib/api/v3/work_packages/create_form_representer.rbindex 7ec252c28b5..93674552ab0 100644--- a/lib/api/v3/work_packages/create_form_representer.rb+++ b/lib/api/v3/work_packages/create_form_representer.rb@@ -31,6 +31,7 @@ module APImodule V3module WorkPackagesclass CreateFormRepresenter < FormRepresenter+ include ApplicationHelperlink :self do{href: api_v3_paths.create_work_package_form,diff --git a/lib/api/v3/work_packages/create_project_form_representer.rb b/lib/api/v3/work_packages/create_project_form_representer.rbindex d70922e0608..073f00500d9 100644--- a/lib/api/v3/work_packages/create_project_form_representer.rb+++ b/lib/api/v3/work_packages/create_project_form_representer.rb@@ -31,6 +31,7 @@ module APImodule V3module WorkPackagesclass CreateProjectFormRepresenter < FormRepresenter+ include ApplicationHelperlink :self do{href: api_v3_paths.create_project_work_package_form(represented.project_id),diff --git a/lib/api/v3/work_packages/work_package_collection_representer.rb b/lib/api/v3/work_packages/work_package_collection_representer.rbindex 5b951309b22..915150492ed 100644--- a/lib/api/v3/work_packages/work_package_collection_representer.rb+++ b/lib/api/v3/work_packages/work_package_collection_representer.rb@@ -32,6 +32,7 @@ module APImodule V3module WorkPackagesclass WorkPackageCollectionRepresenter < ::API::Decorators::OffsetPaginatedCollection+ include ApplicationHelperelement_decorator ::API::V3::WorkPackages::WorkPackageRepresenterdef initialize(models,diff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rbindex cfef6d35f65..4ac9339bc15 100644--- a/lib/api/v3/work_packages/work_package_representer.rb+++ b/lib/api/v3/work_packages/work_package_representer.rb@@ -37,6 +37,7 @@ module APIinclude API::Decorators::FormattablePropertyinclude API::Caching::CachedRepresenterinclude ::API::V3::Attachments::AttachableRepresenterMixin+ include ApplicationHelperextend ::API::V3::Utilities::CustomFieldInjector::RepresenterClasscached_representer key_parts: %i(project),diff --git a/modules/backlogs/lib/open_project/backlogs/engine.rb b/modules/backlogs/lib/open_project/backlogs/engine.rbindex b550a7e0209..da63734611f 100644--- a/modules/backlogs/lib/open_project/backlogs/engine.rb+++ b/modules/backlogs/lib/open_project/backlogs/engine.rb@@ -121,16 +121,16 @@ module OpenProject::Backlogs# We still override version and project settings views from the core! URHoverride_core_views!- patches [:PermittedParams,- :WorkPackage,- :Status,- :Type,- :Project,- :ProjectsController,- :ProjectSettingsHelper,- :User,- :VersionsController,- :Version]+ patches %i[PermittedParams+ WorkPackage+ Status+ Type+ Project+ ProjectsController+ ProjectSettingsHelper+ User+ VersionsController+ Version]patch_with_namespace :API, :V3, :WorkPackages, :Schema, :SpecificWorkPackageSchemapatch_with_namespace :BasicData, :SettingSeederdiff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rbindex 59291d4aaab..c70a42511f1 100644--- a/spec/controllers/projects_controller_spec.rb+++ b/spec/controllers/projects_controller_spec.rb@@ -159,7 +159,7 @@ describe ProjectsController, type: :controller doendit 'redirects to settings#types' do- expect(response).to redirect_to(settings_project_path(project.identifier, tab: 'types'))+ expect(response).to redirect_to(controller: '/project_settings/types', id: project, action: 'show')endend@@ -179,7 +179,7 @@ describe ProjectsController, type: :controller doendit 'redirects to settings#types' do- expect(response).to redirect_to(settings_project_path(project.identifier, tab: 'types'))+ expect(response).to redirect_to(controller: '/project_settings/types', id: project, action: 'show')endendend@@ -237,7 +237,7 @@ describe ProjectsController, type: :controller dorequestend- it { expect(response).to redirect_to(settings_project_path(project, 'custom_fields')) }+ it { expect(response).to redirect_to(controller: '/project_settings/custom_fields', id: project, action: 'show') }it 'sets flash[:notice]' doexpect(flash[:notice]).to eql(I18n.t(:notice_successful_update))@@ -250,7 +250,7 @@ describe ProjectsController, type: :controller dorequestend- it { expect(response).to redirect_to(settings_project_path(project, 'custom_fields')) }+ it { expect(response).to redirect_to(controller: '/project_settings/custom_fields', id: project, action: 'show') }it 'sets flash[:error]' doexpect(flash[:error]).to include(diff --git a/spec/controllers/repositories_controller_spec.rb b/spec/controllers/repositories_controller_spec.rbindex e46c4fc2039..bd963e19a7e 100644--- a/spec/controllers/repositories_controller_spec.rb+++ b/spec/controllers/repositories_controller_spec.rb@@ -75,7 +75,7 @@ describe RepositoriesController, type: :controller doendit 'redirects to settings' do- expect(response).to redirect_to(settings_project_path(project, tab: 'repository'))+ expect(response).to redirect_to(controller: '/project_settings/repository', id: project.identifier, action: 'show')endend@@ -85,7 +85,7 @@ describe RepositoriesController, type: :controller doendit 'redirects to settings' do- expect(response).to redirect_to(controller: '/project_settings', id: project.identifier, action: 'show', tab: 'repository')+ expect(response).to redirect_to(controller: '/project_settings/repository', id: project.identifier, action: 'show')endend@@ -101,7 +101,7 @@ describe RepositoriesController, type: :controller doendit 'redirects to settings' do- expect(response).to redirect_to(controller: '/project_settings', id: project.identifier, action: 'show', tab: 'repository')+ expect(response).to redirect_to(controller: '/project_settings/repository', id: project.identifier, action: 'show')endendenddiff --git a/spec/features/categories/categories_page.rb b/spec/features/categories/categories_page.rbindex a511e4e1d75..7d12148da20 100644--- a/spec/features/categories/categories_page.rb+++ b/spec/features/categories/categories_page.rb@@ -35,6 +35,6 @@ class CategoriesPageenddef visit_settings- visit(settings_project_path(@project) + '/categories')+ visit(settings_project_path(@project, tab: 'categories'))endenddiff --git a/spec/features/projects/projects_custom_fields_spec.rb b/spec/features/projects/projects_custom_fields_spec.rbindex 3f9674cce89..4517e743aa7 100644--- a/spec/features/projects/projects_custom_fields_spec.rb+++ b/spec/features/projects/projects_custom_fields_spec.rb@@ -61,7 +61,7 @@ describe 'Projects custom fields', type: :feature dolet(:editor) { ::Components::WysiwygEditor.new ".form--field.custom_field_#{custom_field.id}" }scenario 'allows settings the project boolean CF (regression #26313)', js: true do- visit settings_project_path(id: project.id)+ visit settings_project_path(project.id)# expect CF, description and status description ckeditorexpect(page).to have_selector('.op-ckeditor--wrapper', count: 3)@@ -88,7 +88,7 @@ describe 'Projects custom fields', type: :feature doendscenario 'allows settings the project boolean CF (regression #26313)', js: true do- visit settings_project_path(id: project.id)+ visit settings_project_path(project.id)expect(page).to have_no_checked_field identifiercheck identifierdiff --git a/spec/features/projects/projects_spec.rb b/spec/features/projects/projects_spec.rbindex d70f9a73d1b..fe06c2fae2e 100644--- a/spec/features/projects/projects_spec.rb+++ b/spec/features/projects/projects_spec.rb@@ -29,6 +29,7 @@require 'spec_helper'describe 'Projects', type: :feature do+ include ApplicationHelperlet(:current_user) { FactoryBot.create(:admin) }before do@@ -159,7 +160,7 @@ describe 'Projects', type: :feature doclick_on 'Update'expect(page).to have_content 'Successful update.'- expect(current_path).to eq '/projects/foo-bar/settings'+ expect(current_path).to eq '/projects/foo-bar/settings/generic'expect(Project.first.identifier).to eq 'foo-bar'end@@ -205,7 +206,7 @@ describe 'Projects', type: :feature doproject.custom_field_values.last.value = 'FOO'project.save!- visit settings_project_path(id: project.id, tab: 'info')+ visit settings_project_path(project.id)expect(page).to have_content 'Required Foo'expect(page).to have_content 'Optional Foo'diff --git a/spec/features/repositories/repository_settings_page.rb b/spec/features/repositories/repository_settings_page.rbindex 1edf0c43111..ebda47ce2d8 100644--- a/spec/features/repositories/repository_settings_page.rb+++ b/spec/features/repositories/repository_settings_page.rb@@ -27,6 +27,7 @@#++class RepositorySettingsPage+ include ApplicationHelperinclude Rails.application.routes.url_helpersinclude Capybara::DSL@@ -35,7 +36,7 @@ class RepositorySettingsPageenddef repository_settings_path- settings_project_path(id: @project.id, tab: 'repository')+ settings_project_path(@project.id, tab: 'repository')enddef visit_repository_settingsdiff --git a/spec/support/pages/projects/settings.rb b/spec/support/pages/projects/settings.rbindex ac6698601ad..be8a9ab942a 100644--- a/spec/support/pages/projects/settings.rb+++ b/spec/support/pages/projects/settings.rb@@ -31,6 +31,7 @@ require 'support/pages/page'module Pagesmodule Projectsclass Settings < Pages::Page+ include ApplicationHelperattr_accessor :projectdef initialize(project)diff --git a/spec/views/projects/settings.html.erb_spec.rb b/spec/views/projects/settings.html.erb_spec.rbindex 19898e09b9c..dc63b326a97 100644--- a/spec/views/projects/settings.html.erb_spec.rb+++ b/spec/views/projects/settings.html.erb_spec.rb@@ -28,13 +28,13 @@require 'spec_helper'-describe 'project_settings/show', type: :view do+describe 'project_settings/generic', type: :view dolet(:project) { FactoryBot.build_stubbed(:project) }describe 'project copy permission' dobefore doassign(:project, project)- allow(view).to receive(:render_tabs).and_return('')+ allow(view).to receive(:labelled_tabular_form_for).and_return('')endcontext 'when project copy is allowed' do@@ -67,7 +67,7 @@ describe 'project_settings/show', type: :view doassign(:project, project)allow(project).to receive(:copy_allowed?).and_return(true)allow(User).to receive(:current).and_return(admin)- allow(view).to receive(:render_tabs).and_return('')+ allow(view).to receive(:labelled_tabular_form_for).and_return('')renderend@@ -84,7 +84,7 @@ describe 'project_settings/show', type: :view doassign(:project, project)allow(project).to receive(:copy_allowed?).and_return(true)allow(User).to receive(:current).and_return(non_admin)- allow(view).to receive(:render_tabs).and_return('')+ allow(view).to receive(:labelled_tabular_form_for).and_return('')renderenddiff --git a/spec_legacy/functional/projects_controller_spec.rb b/spec_legacy/functional/projects_controller_spec.rbindex 78bbb92e533..82056acbea9 100644--- a/spec_legacy/functional/projects_controller_spec.rb+++ b/spec_legacy/functional/projects_controller_spec.rb@@ -292,7 +292,7 @@ describe ProjectsController, type: :controller doissue_custom_field_ids: ['']}}- assert_redirected_to '/projects/ecookbook/settings'+ assert_redirected_to '/projects/ecookbook/settings/generic'project = Project.find(1)assert_equal 'Test changed name', project.nameend