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

tests[Op#55507]: ensure only active projects are mapped

Kabiru Mwenjae7a43433ca4e
diff --git a/spec/services/project_custom_field_project_mappings/bulk_create_service_spec.rb b/spec/services/project_custom_field_project_mappings/bulk_create_service_spec.rb
index a8ec9fee4cd..8bb137c4ae6 100644
--- a/spec/services/project_custom_field_project_mappings/bulk_create_service_spec.rb
+++ b/spec/services/project_custom_field_project_mappings/bulk_create_service_spec.rb
@@ -138,4 +138,21 @@ RSpec.describe ProjectCustomFieldProjectMappings::BulkCreateService do
expect(service_result.errors).to eq("not found")
end
end
+
+ context "with archived projects" do
+ let(:user) { create(:admin) }
+ let(:archived_project) { create(:project, active: false) }
+ let(:active_project) { create(:project) }
+
+ let(:instance) { described_class.new(user:, projects: [archived_project, active_project], project_custom_field:) }
+
+ it "only creates mappins for the active project" do
+ expect { instance.call }.to change(ProjectCustomFieldProjectMapping, :count).by(1)
+
+ aggregate_failures "creates the mapping for the correct project and custom field" do
+ expect(ProjectCustomFieldProjectMapping.where(project_custom_field:).pluck(:project_id))
+ .to contain_exactly(active_project.id)
+ end
+ end
+ end
end