Skip to content

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

[#55505] Exclude archived projects from "Enabled in Projects" project attributes page (#15845)

Kabiru Mwenja7376a446a054
diff --git a/app/controllers/admin/settings/project_custom_fields_controller.rb b/app/controllers/admin/settings/project_custom_fields_controller.rb
index 91477b145d8..ffcb43b7d77 100644
--- a/app/controllers/admin/settings/project_custom_fields_controller.rb
+++ b/app/controllers/admin/settings/project_custom_fields_controller.rb
@@ -167,6 +167,7 @@ module Admin::Settings
name: "project-custom-field-mappings-#{@custom_field.id}"
) do |query|
query.where(:available_project_attributes, "=", [@custom_field.id])
+ query.where("active", "=", OpenProject::Database::DB_VALUE_TRUE)
query.select(:name)
query.order("lft" => "asc")
end
diff --git a/spec/features/admin/project_custom_fields/project_mappings_spec.rb b/spec/features/admin/project_custom_fields/project_mappings_spec.rb
index 93f226dd3f5..10a71e94345 100644
--- a/spec/features/admin/project_custom_fields/project_mappings_spec.rb
+++ b/spec/features/admin/project_custom_fields/project_mappings_spec.rb
@@ -32,9 +32,14 @@ RSpec.describe "Project Custom Field Mappings", :js do
shared_let(:admin) { create(:admin) }
shared_let(:non_admin) { create(:user) }
shared_let(:project) { create(:project) }
+ shared_let(:archived_project) { create(:project, active: false) }
shared_let(:project_custom_field) { create(:project_custom_field) }
shared_let(:project_custom_field_mapping) { create(:project_custom_field_project_mapping, project_custom_field:, project:) }
+ shared_let(:archived_project_custom_field_mapping) do
+ create(:project_custom_field_project_mapping, project_custom_field:, project: archived_project)
+ end
+
let(:project_custom_field_mappings_page) { Pages::Admin::Settings::ProjectCustomFields::ProjectCustomFieldMappingsIndex.new }
context "with insufficient permissions" do
@@ -72,6 +77,7 @@ RSpec.describe "Project Custom Field Mappings", :js do
aggregate_failures "shows the correct project mappings" do
within "#project-table" do
expect(page).to have_text(project.name)
+ expect(page).to have_no_text(archived_project.name)
end
end
@@ -90,6 +96,9 @@ RSpec.describe "Project Custom Field Mappings", :js do
within_test_selector("settings--new-project-custom-field-mapping-component") do
autocompleter = page.find(".op-project-autocompleter")
autocompleter.fill_in with: project.name
+
+ expect(page).to have_no_text(archived_project.name)
+
find(".ng-option-label", text: project.name).click
check "Include sub-projects"