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
Only select current members as copied members
Oliver Güntherb3568c6443dd
diff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rbindex b03fc714959..64837b77d68 100644--- a/modules/meeting/app/models/meeting.rb+++ b/modules/meeting/app/models/meeting.rb@@ -157,7 +157,7 @@ class Meeting < ApplicationRecordcopy.set_initial_valuescopy.participants.clear- copy.participants_attributes = participants.collect(&:copy_attributes)+ copy.participants_attributes = allowed_participants.collect(&:copy_attributes)copyend@@ -212,6 +212,17 @@ class Meeting < ApplicationRecordprotected+ # Participants of older meetings+ # might contain users no longer in the project+ #+ # This returns the set currently allowed to view the meeting+ def allowed_participants+ available_members = User.allowed_members(:view_meetings, project).select(:id)++ participants+ .where(user_id: available_members)+ end+def set_initial_values# set defaultswrite_attribute(:start_time, Date.tomorrow + 10.hours) if start_time.nil?diff --git a/modules/meeting/spec/models/meeting_spec.rb b/modules/meeting/spec/models/meeting_spec.rbindex b18039072a2..e3c89f45135 100644--- a/modules/meeting/spec/models/meeting_spec.rb+++ b/modules/meeting/spec/models/meeting_spec.rb@@ -222,5 +222,16 @@ describe Meeting, type: :model docopy = meeting.copy({})expect(copy.participants.all? { |p| p.id.nil? && !p.attended }).to be_truthyend++ context 'when old meeting as user no longer in project' do+ before do+ user2.memberships.destroy_all+ end++ it 'does not copy that user' do+ copy = meeting.copy({})+ expect(copy.participants.map(&:user_id)).to eq [user1.id]+ end+ endendend