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
prevent access to new page unless feature flag is active
ulferts44d73d15637c
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rbindex e1836392639..6199906f51c 100644--- a/app/controllers/projects_controller.rb+++ b/app/controllers/projects_controller.rb@@ -39,6 +39,11 @@ class ProjectsController < ApplicationControllerbefore_action :authorize, only: %i[copy_form copy deactivate_work_package_attachments]before_action :authorize_global, only: %i[new create]before_action :require_admin, only: %i[destroy destroy_info]+ before_action :not_authorized_on_feature_flag_inactive,+ only: %i[new create],+ if: -> {+ params.dig(:project, :workspace_type) == Project.workspace_types[:portfolio]+ }before_action :find_optional_template, only: %i[new create]before_action :find_optional_parent, only: :new@@ -270,5 +275,9 @@ class ProjectsController < ApplicationController::Exports::Register.list_formats(Project).map(&:to_s)end+ def not_authorized_on_feature_flag_inactive(flag)+ render_403 unless OpenProject::FeatureDecisions.active.include?(flag)+ end+helper_method :supported_export_formatsenddiff --git a/spec/features/portfolios/create_spec.rb b/spec/features/portfolios/create_spec.rbindex e1c13bfd6e2..eb703544b7f 100644--- a/spec/features/portfolios/create_spec.rb+++ b/spec/features/portfolios/create_spec.rb@@ -42,9 +42,7 @@ RSpec.describe "Portfolios",current_user { user_with_permissions }- let(:projects_page) { Pages::Projects::Index.new }-- it "can create a project", with_flag: { portfolio_models: true } do+ it "can create a portfolio", with_flag: { portfolio_models: true } do# TODO: trigger this from a button# e.g. on the project index pagevisit new_portfolio_path@@ -59,4 +57,10 @@ RSpec.describe "Portfolios",expect(page).to have_current_path /\/projects\/foo-bar\/?/expect(page).to have_content "Foo bar"end++ it "cannot create the portfolio without the feature flag being active", with_flag: { portfolio_models: false } do+ visit new_portfolio_path++ expect(page).to have_content "[Error 403] You are not authorized to access this page."+ endend