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

Never assign builtin users when copyiong

Oliver Günther6f0d800f61b6
diff --git a/modules/meeting/app/services/meetings/copy_service.rb b/modules/meeting/app/services/meetings/copy_service.rb
index f351e61b363..544530ecb5a 100644
--- a/modules/meeting/app/services/meetings/copy_service.rb
+++ b/modules/meeting/app/services/meetings/copy_service.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -82,10 +84,12 @@ module Meetings
end
def copied_participants
- if meeting.allowed_participants.empty?
+ if meeting.allowed_participants.present?
+ meeting.allowed_participants.collect(&:copy_attributes)
+ elsif !user.builtin?
[{ "user_id" => user.id, "invited" => true }]
else
- meeting.allowed_participants.collect(&:copy_attributes)
+ []
end
end
diff --git a/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb b/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb
index d9a125c1c48..00bddb71226 100644
--- a/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb
+++ b/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -92,6 +94,33 @@ RSpec.describe Meetings::CopyService, "integration", type: :model do
end
end
+ describe "copying a system's user meeting" do
+ it "sets the copier as participant when empty" do
+ meeting.participants.destroy_all
+ meeting.author = User.system
+ meeting.save!
+
+ expect(service_result).to be_success
+ expect(copy.participants.count).to eq(1)
+ expect(copy.author).to eq(user)
+ invited = copy.participants.find_by(user:)
+ expect(invited).to be_invited
+ end
+ end
+
+ describe "copying as the system user" do
+ let(:instance) { described_class.new(model: meeting, user: User.system) }
+
+ it "does not add it as a participant" do
+ meeting.participants.destroy_all
+ meeting.save!
+
+ expect(service_result).to be_success
+ expect(copy.participants.count).to eq(0)
+ expect(copy.author).to eq(User.system)
+ end
+ end
+
describe "when not saving" do
let(:params) { { save: false } }