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
Ensure we send an email when meetings get cancelled
Oliver Günther73200f0fd031
diff --git a/modules/meeting/app/contracts/meetings/base_contract.rb b/modules/meeting/app/contracts/meetings/base_contract.rbindex 229ca51a34a..12df2b732c8 100644--- a/modules/meeting/app/contracts/meetings/base_contract.rb+++ b/modules/meeting/app/contracts/meetings/base_contract.rb@@ -41,5 +41,16 @@ module Meetingsattribute :start_dateattribute :start_timeattribute :start_time_hour+ attribute :template++ validate :template_requires_series++ private++ def template_requires_series+ if model.template && model.recurring_meeting_id.nil?+ errors.add(:template, :invalid)+ end+ endendenddiff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rbindex d0aaa38d64b..94eaaf774e8 100644--- a/modules/meeting/app/controllers/meetings_controller.rb+++ b/modules/meeting/app/controllers/meetings_controller.rb@@ -402,9 +402,13 @@ class MeetingsController < ApplicationControllerenddef build_meeting- @meeting = meeting_class.new- @meeting.project = @project- @meeting.author = User.current+ meeting = meeting_class.new++ call = ::Meetings::SetAttributesService+ .new(user: current_user, model: meeting, contract_class: EmptyContract)+ .call(project: @project)++ @meeting = call.resultenddef meeting_classdiff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rbindex a58102c9a4c..256ef04e8e9 100644--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb@@ -160,11 +160,13 @@ class RecurringMeetingsController < ApplicationControllerenddef destroy- if @recurring_meeting.destroy- flash[:notice] = I18n.t(:notice_successful_delete)- else- flash[:error] = I18n.t(:error_failed_to_delete_entry)- end+ # rubocop:disable Rails/ActionControllerFlashBeforeRender+ RecurringMeetings::DeleteService+ .new(model: @recurring_meeting, user: User.current)+ .call+ .on_success { flash[:notice] = I18n.t(:notice_successful_delete) }+ .on_failure { flash[:error] = I18n.t(:error_failed_to_delete_entry) }+ # rubocop:enable Rails/ActionControllerFlashBeforeRenderrespond_to do |format|format.html dodiff --git a/modules/meeting/app/mailers/meeting_mailer.rb b/modules/meeting/app/mailers/meeting_mailer.rbindex 30e452131d2..d7a37826f2b 100644--- a/modules/meeting/app/mailers/meeting_mailer.rb+++ b/modules/meeting/app/mailers/meeting_mailer.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -57,6 +59,36 @@ class MeetingMailer < UserMailerendend+ def cancelled(meeting, user, actor)+ @actor = actor+ @user = user+ @meeting = meeting++ open_project_headers "Project" => @meeting.project.identifier,+ "Meeting-Id" => @meeting.id++ with_attached_ics(meeting, user, cancelled: true) do+ subject = I18n.t("meeting.email.cancelled.header", title: @meeting.title)++ mail(to: user, subject: "[#{@meeting.project.name}] #{subject}")+ end+ end++ def cancelled_series(series, user, actor)+ @actor = actor+ @user = user+ @series = series++ open_project_headers "Project" => @series.project.identifier,+ "Meeting-Id" => @series.id++ with_attached_ics(@series, user, cancelled: true) do+ subject = I18n.t("meeting.email.cancelled.header", title: @series.title)++ mail(to: user, subject: "[#{@series.project.name}] #{subject}")+ end+ end+def icalendar_notification(meeting, user, _actor, **)@meeting = meeting@@ -70,9 +102,9 @@ class MeetingMailer < UserMailerprivate- def with_attached_ics(meeting, user)+ def with_attached_ics(meeting, user, **args)User.execute_as(user) do- call = ics_service_call(meeting, user)+ call = ics_service_call(meeting, user, **args)call.on_success doattachments["meeting.ics"] = call.result@@ -86,15 +118,19 @@ class MeetingMailer < UserMailerendend- def ics_service_call(meeting, user)- if meeting.recurring?+ def ics_service_call(meeting, user, **args)+ if meeting.is_a?(RecurringMeeting)+ ::RecurringMeetings::ICalService+ .new(user:, series: meeting)+ .generate_series(**args)+ elsif meeting.recurring?::RecurringMeetings::ICalService.new(user:, series: meeting.recurring_meeting)- .generate_occurrence(meeting.scheduled_meeting)+ .generate_occurrence(meeting, **args)else::Meetings::ICalService.new(user:, meeting:)- .call+ .call(**args)endenddiff --git a/modules/meeting/app/models/meeting/virtual_start_time.rb b/modules/meeting/app/models/meeting/virtual_start_time.rbindex 68bbdf198e8..b64f388277b 100644--- a/modules/meeting/app/models/meeting/virtual_start_time.rb+++ b/modules/meeting/app/models/meeting/virtual_start_time.rb@@ -92,7 +92,6 @@ module Meeting::VirtualStartTime# set defaults# Start date is set to tomorrow at 10 AM (Current users local time)write_attribute(:start_time, User.current.time_zone.now.at_midnight + 34.hours) if start_time.nil?- self.duration ||= 1update_derived_fieldsenddiff --git a/modules/meeting/app/services/meetings/delete_service.rb b/modules/meeting/app/services/meetings/delete_service.rbindex 55642242f49..01cfcd8ab39 100644--- a/modules/meeting/app/services/meetings/delete_service.rb+++ b/modules/meeting/app/services/meetings/delete_service.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,10 +33,25 @@ module Meetingsprotecteddef after_validate(_, call)- schedule = model.scheduled_meeting- schedule.update_column(:cancelled, true) if schedule.present?+ send_cancellation_mail(model)+ cancel_scheduled_meeting(model)callend++ def send_cancellation_mail(meeting)+ meeting.participants.where(invited: true).find_each do |participant|+ MeetingMailer+ .cancelled(meeting, participant.user, User.current)+ .deliver_now+ end+ end++ def cancel_scheduled_meeting(meeting)+ schedule = meeting.scheduled_meeting+ return if schedule.nil?++ schedule.update_column(:cancelled, true)+ endendenddiff --git a/modules/meeting/app/services/meetings/ical_helpers.rb b/modules/meeting/app/services/meetings/ical_helpers.rbindex 9812c612a18..fa6ebdc841d 100644--- a/modules/meeting/app/services/meetings/ical_helpers.rb+++ b/modules/meeting/app/services/meetings/ical_helpers.rb@@ -30,13 +30,27 @@ require "icalendar/tzinfo"module Meetingsmodule ICalHelpers- def ical_event(start_time, &)+ def ical_event(start_time, cancelled:, &)calendar = build_icalendar(start_time)calendar.event(&)- calendar.publish++ if cancelled+ calendar.cancel+ else+ calendar.publish+ endcalendar.to_icalend+ def set_status(cancelled, event)+ event.status =+ if cancelled+ "CANCELLED"+ else+ "CONFIRMED"+ end+ end+def build_icalendar(start_time)::Icalendar::Calendar.new.tap do |calendar|calendar.prodid = "-//OpenProject GmbH//#{OpenProject::VERSION}//Meeting//EN"diff --git a/modules/meeting/app/services/meetings/ical_service.rb b/modules/meeting/app/services/meetings/ical_service.rbindex dbdaa99958e..9d0519b19a2 100644--- a/modules/meeting/app/services/meetings/ical_service.rb+++ b/modules/meeting/app/services/meetings/ical_service.rb@@ -39,10 +39,10 @@ module Meetings@url_helpers = OpenProject::StaticRouting::StaticUrlHelpers.newend- def call+ def call(cancelled: false)User.execute_as(user) do@timezone = Time.zone || Time.zone_default- ServiceResult.success(result: generate_ical)+ ServiceResult.success(result: generate_ical(cancelled:))endrescue StandardError => eRails.logger.error("Failed to generate ICS for meeting #{@meeting.id}: #{e.message}")@@ -52,8 +52,8 @@ module Meetingsprivate# rubocop:disable Metrics/AbcSize- def generate_ical- ical_event(meeting.start_time) do |e|+ def generate_ical(cancelled:)+ ical_event(meeting.start_time, cancelled:) do |e|tzinfo = timezone.tzinfotzid = tzinfo.canonical_identifier@@ -66,6 +66,7 @@ module Meetingse.organizer = ical_organizer(meeting)e.location = meeting.location.presence+ set_status(cancelled, e)add_attendees(e, meeting)endenddiff --git a/modules/meeting/app/services/meetings/set_attributes_service.rb b/modules/meeting/app/services/meetings/set_attributes_service.rbindex abe44c0d3a9..bf32b7e8cd9 100644--- a/modules/meeting/app/services/meetings/set_attributes_service.rb+++ b/modules/meeting/app/services/meetings/set_attributes_service.rb@@ -39,6 +39,7 @@ module Meetingsdef set_default_attributes(_params)model.change_by_system domodel.author = user+ model.duration ||= 1endenddiff --git a/modules/meeting/app/services/recurring_meetings/create_service.rb b/modules/meeting/app/services/recurring_meetings/create_service.rbindex 2a37d196239..d80734ff3ae 100644--- a/modules/meeting/app/services/recurring_meetings/create_service.rb+++ b/modules/meeting/app/services/recurring_meetings/create_service.rb@@ -42,13 +42,16 @@ module RecurringMeetingsenddef create_meeting_template(recurring_meeting)- template = StructuredMeeting.new(@template_params)- template.project = recurring_meeting.project- template.template = true- template.recurring_meeting = recurring_meeting- template.author = user+ params = @template_params.merge(+ type: "StructuredMeeting",+ template: true,+ recurring_meeting:,+ project: recurring_meeting.project+ )- ServiceResult.new(success: template.save, errors: template.errors)+ Meetings::CreateService+ .new(user: user)+ .call(params)endendenddiff --git a/modules/meeting/app/services/recurring_meetings/delete_service.rb b/modules/meeting/app/services/recurring_meetings/delete_service.rbnew file mode 100644index 00000000000..4287dcffa65--- /dev/null+++ b/modules/meeting/app/services/recurring_meetings/delete_service.rb@@ -0,0 +1,53 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module RecurringMeetings+ class DeleteService < ::BaseServices::Delete+ protected++ def default_contract_class+ Meetings::DeleteContract+ end++ def after_validate(_, call)+ send_cancellation_mail(model)++ call+ end++ def send_cancellation_mail(meeting)+ meeting.template.participants.where(invited: true).find_each do |participant|+ MeetingMailer+ .cancelled_series(meeting, participant.user, User.current)+ .deliver_now+ end+ end+ end+enddiff --git a/modules/meeting/app/services/recurring_meetings/ical_service.rb b/modules/meeting/app/services/recurring_meetings/ical_service.rbindex dd3c6c80173..edde6bf7217 100644--- a/modules/meeting/app/services/recurring_meetings/ical_service.rb+++ b/modules/meeting/app/services/recurring_meetings/ical_service.rb@@ -47,21 +47,23 @@ module RecurringMeetings@url_helpers = OpenProject::StaticRouting::StaticUrlHelpers.newend- def generate_series+ def generate_series(cancelled: false)ical_result(series) do- series_event+ series_event(cancelled:)occurrences_events+ calendar_status(cancelled:)endrescue StandardError => eRails.logger.error("Failed to generate ICS for meeting series #{series.id}: #{e.message}")ServiceResult.failure(message: e.message)end- def generate_occurrence(meeting)+ def generate_occurrence(meeting, cancelled: false)# Get the time the meeting was scheduled to take placescheduled_meeting = meeting.scheduled_meetingical_result(scheduled_meeting) do- occurrence_event(scheduled_meeting.start_time, meeting)+ occurrence_event(scheduled_meeting.start_time, meeting, cancelled:)+ calendar_status(cancelled:)endrescue StandardError => eRails.logger.error("Failed to generate ICS for meeting #{meeting.id}: #{e.message}")@@ -70,6 +72,14 @@ module RecurringMeetingsprivate+ def calendar_status(cancelled:)+ if cancelled+ calendar.cancel+ else+ calendar.publish+ end+ end+def ical_result(meeting)User.execute_as(user) do@timezone = Time.zone || Time.zone_default@@ -77,7 +87,6 @@ module RecurringMeetingsyield- calendar.publishServiceResult.success(result: calendar.to_ical)endend@@ -90,7 +99,7 @@ module RecurringMeetingstzinfo.canonical_identifierend- def series_event # rubocop:disable Metrics/AbcSize+ def series_event(cancelled:) # rubocop:disable Metrics/AbcSizecalendar.event do |e|base_series_attributes(e)@@ -102,16 +111,18 @@ module RecurringMeetingsadd_attendees(e, template)e.exdate = cancelled_schedules++ set_status(cancelled, e)endenddef occurrences_eventsupcoming_instantiated_schedules.find_each do |schedule|- occurrence_event(schedule.start_time, schedule.meeting)+ occurrence_event(schedule.start_time, schedule.meeting, cancelled: false)endend- def occurrence_event(schedule_start_time, meeting) # rubocop:disable Metrics/AbcSize+ def occurrence_event(schedule_start_time, meeting, cancelled:) # rubocop:disable Metrics/AbcSizecalendar.event do |e|base_series_attributes(e)@@ -123,6 +134,7 @@ module RecurringMeetingse.sequence = meeting.lock_versionadd_attendees(e, meeting)+ set_status(cancelled, e)endenddiff --git a/modules/meeting/app/services/recurring_meetings/set_attributes_service.rb b/modules/meeting/app/services/recurring_meetings/set_attributes_service.rbindex 9f232da2b30..e8c71f00475 100644--- a/modules/meeting/app/services/recurring_meetings/set_attributes_service.rb+++ b/modules/meeting/app/services/recurring_meetings/set_attributes_service.rb@@ -43,6 +43,7 @@ module RecurringMeetingsdef set_default_attributes(_params)model.change_by_system domodel.author = user+ model.duration ||= 1endendenddiff --git a/modules/meeting/app/views/meeting_mailer/cancelled.html.erb b/modules/meeting/app/views/meeting_mailer/cancelled.html.erbnew file mode 100644index 00000000000..60b556e7820--- /dev/null+++ b/modules/meeting/app/views/meeting_mailer/cancelled.html.erb@@ -0,0 +1,103 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) the OpenProject GmbH++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License version 3.++OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+Copyright (C) 2006-2013 Jean-Philippe Lang+Copyright (C) 2010-2013 the ChiliProject Team++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License+as published by the Free Software Foundation; either version 2+of the License, or (at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.++See COPYRIGHT and LICENSE files for more details.++++#%>++<%+ summary =+ if @meeting.recurring?+ I18n.t("meeting.email.cancelled.summary_occurrence",+ title: @meeting.title,+ actor: @actor)+ else+ I18n.t("meeting.email.cancelled.summary",+ title: @meeting.title,+ actor: @actor)+ end+%>++<%= render layout: "mailer/spacer_table" do %>+ <%= render partial: "mailer/mailer_header",+ locals: {+ user: @user,+ summary:,+ bottom_spacing: false+ } %>++ <%= render layout: "mailer/border_table" do %>+ <tr>+ <%= placeholder_cell("24px", vertical: true) %>+ <td>+ <table>+ <tr>+ <td style="<%= placeholder_text_styles(width: "30%") %>">+ <%= t("meeting.email.cancelled.date_time") %>+ </td>+ <td style="<%= placeholder_text_styles %>">+ <s>+ <%= format_time_as_date @meeting.start_time %> <%= format_time @meeting.start_time, include_date: false %>+ -+ <%= format_time @meeting.end_time, include_date: false %> (<%= formatted_time_zone_offset %>)+ </s>+ </td>+ </tr>+ <% if @meeting.location.present? %>+ <tr>+ <td style="<%= placeholder_text_styles(width: "30%") %>">+ <%= Meeting.human_attribute_name(:location) %>+ </td>+ <td style="<%= placeholder_text_styles %>">+ <%= auto_link @meeting.location %>+ </td>+ </tr>+ <% end %>+ <tr>+ <td style="<%= placeholder_text_styles(width: "30%") %>">+ <%= Meeting.human_attribute_name(:project) %>+ </td>+ <td style="<%= placeholder_text_styles %>">+ <%= link_to @meeting.project.name, project_url(@meeting.project) %>+ </td>+ </tr>+ </table>+ </td>+ </tr>+ <% end %>++ <table>+ <tr>+ <%= placeholder_cell("20px", vertical: false) %>+ </tr>+ </table>++ <%= action_button do %>+ <%= link_to I18n.t(:"meeting.email.open_my_meetings_link"),+ meetings_url,+ target: "_blank",+ style: "color: #333333; text-decoration: none; font-size: 14px;white-space: nowrap;", rel: "noopener" %>+ <% end %>+<% end %>diff --git a/modules/meeting/app/views/meeting_mailer/cancelled.text.erb b/modules/meeting/app/views/meeting_mailer/cancelled.text.erbnew file mode 100644index 00000000000..8e2a05f3f3e--- /dev/null+++ b/modules/meeting/app/views/meeting_mailer/cancelled.text.erb@@ -0,0 +1,47 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) the OpenProject GmbH++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License version 3.++OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+Copyright (C) 2006-2013 Jean-Philippe Lang+Copyright (C) 2010-2013 the ChiliProject Team++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License+as published by the Free Software Foundation; either version 2+of the License, or (at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.++See COPYRIGHT and LICENSE files for more details.++++#%>++<%+ summary =+ if @meeting.recurring?+ I18n.t("meeting.email.cancelled.summary_occurrence",+ title: @meeting.title,+ actor: @actor)+ else+ I18n.t("meeting.email.cancelled.summary",+ title: @meeting.title,+ actor: @actor)+ end+%>++<%= summary %>++<%= @meeting.project.name %>: <%= @meeting.title %>+<%= @meeting.author %>+<%= t :label_meeting_date_time %>: <%= format_time_as_date @meeting.start_time %> <%= format_time @meeting.start_time, include_date: false %>-<%= format_time @meeting.end_time, include_date: false %> (<%= formatted_time_zone_offset %>)diff --git a/modules/meeting/app/views/meeting_mailer/cancelled_series.html.erb b/modules/meeting/app/views/meeting_mailer/cancelled_series.html.erbnew file mode 100644index 00000000000..4144daf8c3f--- /dev/null+++ b/modules/meeting/app/views/meeting_mailer/cancelled_series.html.erb@@ -0,0 +1,78 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) the OpenProject GmbH++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License version 3.++OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+Copyright (C) 2006-2013 Jean-Philippe Lang+Copyright (C) 2010-2013 the ChiliProject Team++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License+as published by the Free Software Foundation; either version 2+of the License, or (at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.++See COPYRIGHT and LICENSE files for more details.++++#%>++<%= render layout: "mailer/spacer_table" do %>+ <%= render partial: "mailer/mailer_header",+ locals: {+ user: @user,+ summary: I18n.t("meeting.email.cancelled.summary_series", title: @series.title, actor: @actor),+ bottom_spacing: false+ } %>++ <%= render layout: "mailer/border_table" do %>+ <tr>+ <%= placeholder_cell("24px", vertical: true) %>+ <td>+ <table>+ <tr>+ <td style="<%= placeholder_text_styles(width: "30%") %>">+ <%= t(:label_recurring_meeting_schedule) %>+ </td>+ <td style="<%= placeholder_text_styles %>">+ <s>+ <%= @series.full_schedule_in_words %> (<%= formatted_time_zone_offset %>)+ </s>+ </td>+ </tr>+ <tr>+ <td style="<%= placeholder_text_styles(width: "30%") %>">+ <%= Meeting.human_attribute_name(:project) %>+ </td>+ <td style="<%= placeholder_text_styles %>">+ <%= link_to @series.project.name, project_url(@series.project) %>+ </td>+ </tr>+ </table>+ </td>+ </tr>+ <% end %>++ <table>+ <tr>+ <%= placeholder_cell("20px", vertical: false) %>+ </tr>+ </table>++ <%= action_button do %>+ <%= link_to I18n.t(:"meeting.email.open_my_meetings_link"),+ meetings_url,+ target: "_blank",+ style: "color: #333333; text-decoration: none; font-size: 14px;white-space: nowrap;", rel: "noopener" %>+ <% end %>+<% end %>diff --git a/modules/meeting/app/views/meeting_mailer/cancelled_series.text.erb b/modules/meeting/app/views/meeting_mailer/cancelled_series.text.erbnew file mode 100644index 00000000000..4d85d63df08--- /dev/null+++ b/modules/meeting/app/views/meeting_mailer/cancelled_series.text.erb@@ -0,0 +1,36 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) the OpenProject GmbH++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License version 3.++OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+Copyright (C) 2006-2013 Jean-Philippe Lang+Copyright (C) 2010-2013 the ChiliProject Team++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License+as published by the Free Software Foundation; either version 2+of the License, or (at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.++See COPYRIGHT and LICENSE files for more details.++++#%>++<%= I18n.t("meeting.email.cancelled.summary_series",+ title: @series.title,+ actor: @actor) %>++<%= @series.project.name %>: <%= @series.title %>+<%= @series.author %>+<%= t :label_recurring_meeting_schedule %>: <%= @series.full_schedule_in_words %> (<%= formatted_time_zone_offset %>)diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.ymlindex 80704b25893..e08617f39f9 100644--- a/modules/meeting/config/locales/en.yml+++ b/modules/meeting/config/locales/en.yml@@ -196,11 +196,20 @@ en:Send an email invitation immediately to the participants selected above. You can also do this manually at any time later.send_invitation_emails_structured: "Send an email invitation immediately to all participants. You can also do this manually at any time later."open_meeting_link: "Open meeting"+ open_my_meetings_link: "Go to My meetings"series:title: "[%{project_name}] Meeting series %{title}"summary: "%{actor} has set up a new meeting series %{title}"invited:summary: "%{actor} has sent you an invitation for the meeting %{title}"+ cancelled:+ header: "Cancelled: Meeting '%{title}'"+ header_occurrence: "Cancelled: Meeting occurrence '%{title}'"+ header_series: "Cancelled: Meeting series '%{title}'"+ summary_occurrence: "An occurrence of '%{title}' has been cancelled by %{actor}."+ summary_series: "Meeting series '%{title}' has been cancelled by %{actor}."+ summary: "'%{title}' has been cancelled by %{actor}."+ date_time: "Scheduled date/time"rescheduled:header: "Meeting %{title} has been rescheduled"summary: "Meeting %{title} has been rescheduled by %{actor}"diff --git a/modules/meeting/spec/factories/meeting_factory.rb b/modules/meeting/spec/factories/meeting_factory.rbindex 3ec2041df7d..7d8821325ae 100644--- a/modules/meeting/spec/factories/meeting_factory.rb+++ b/modules/meeting/spec/factories/meeting_factory.rb@@ -31,6 +31,7 @@ FactoryBot.define doauthor factory: :userprojectstart_time { Date.tomorrow + 10.hours }+ recurring_meeting { nil }duration { 1.0 }location { "https://some-url.com" }m.sequence(:title) { |n| "Meeting #{n}" }diff --git a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rbindex f13ab2327f0..672c8f2fc2c 100644--- a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb+++ b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb@@ -88,10 +88,11 @@ RSpec.describe "Recurring meetings CRUD",show_page.visit!show_page.delete_meeting_series- show_page.within_modal "Delete meeting series" do- check "I understand that this deletion cannot be reversed", allow_label_click: true-- click_on "Delete permanently"+ retry_block do+ show_page.within_modal "Delete meeting series" do+ check "I understand that this deletion cannot be reversed", allow_label_click: true+ click_on "Delete permanently"+ endendexpect(page).to have_current_path project_meetings_path(project)diff --git a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_global_crud_spec.rb b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_global_crud_spec.rbindex 9ab07fdd7aa..62c5970abb3 100644--- a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_global_crud_spec.rb+++ b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_global_crud_spec.rb@@ -89,10 +89,12 @@ RSpec.describe "Recurring meetings global CRUD", :js doshow_page.visit!show_page.delete_meeting_series- show_page.within_modal "Delete meeting series" do- check "I understand that this deletion cannot be reversed", allow_label_click: true- click_on "Delete permanently"+ retry_block do+ show_page.within_modal "Delete meeting series" do+ check "I understand that this deletion cannot be reversed", allow_label_click: true+ click_on "Delete permanently"+ endendexpect(page).to have_current_path meetings_pathdiff --git a/modules/meeting/spec/requests/meetings_delete_spec.rb b/modules/meeting/spec/requests/meetings_delete_spec.rbnew file mode 100644index 00000000000..a765c21aa26--- /dev/null+++ b/modules/meeting/spec/requests/meetings_delete_spec.rb@@ -0,0 +1,93 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require "spec_helper"++RSpec.describe "DELETE /meetings/:id",+ :skip_csrf,+ type: :rails_request do+ include Redmine::I18n++ shared_let(:project) { create(:project, enabled_module_names: %i[meetings]) }+ shared_let(:user) do+ create(:user,+ firstname: "Bob",+ lastname: "User",+ member_with_permissions: { project => %i[view_meetings delete_meetings] })+ end++ shared_let(:meeting) do+ create :meeting,+ project:,+ title: "My one-off meeting",+ author: user,+ start_time: Time.zone.today - 10.days + 10.hours+ end++ let(:current_user) { user }+ let(:request) { delete meeting_path(meeting) }++ subject do+ request+ response+ end++ before do+ login_as(current_user)+ end++ context "when user has permissions to access" do+ it "deletes the meeting" do+ expect(subject).to have_http_status(:see_other)++ expect { meeting.reload }.to raise_error(ActiveRecord::RecordNotFound)++ perform_enqueued_jobs+ expect(ActionMailer::Base.deliveries.size).to eq(1)+ mail = ActionMailer::Base.deliveries.first+ expect(mail.body.parts.first.parts.first.body.to_s)+ .to include "'My one-off meeting' has been cancelled by #{user.name}"+ end+ end++ context "when user has no permissions to access" do+ let(:current_user) { create(:user) }++ it "does not delete the meeting" do+ delete meeting_path(meeting)+ expect(response).to have_http_status(:forbidden)+ end++ it "does not delete project meeting" do+ delete project_meeting_path(project, meeting)+ expect(response).to have_http_status(:forbidden)+ end+ end+enddiff --git a/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_delete_spec.rb b/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_delete_spec.rbnew file mode 100644index 00000000000..42bccc05331--- /dev/null+++ b/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_delete_spec.rb@@ -0,0 +1,115 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require "spec_helper"+require_relative "../../support/pages/recurring_meeting/show"++RSpec.describe "DELETE /recurring_meetings/:id",+ :skip_csrf,+ type: :rails_request do+ include Redmine::I18n++ shared_let(:project) { create(:project, enabled_module_names: %i[meetings]) }+ shared_let(:user) do+ create(:user,+ firstname: "Bob",+ lastname: "User",+ member_with_permissions: { project => %i[view_meetings delete_meetings] })+ end++ shared_let(:recurring_meeting) do+ create :recurring_meeting,+ project:,+ author: user,+ start_time: Time.zone.today - 10.days + 10.hours,+ frequency: "daily"+ end++ let(:current_user) { user }+ let(:show_page) { Pages::RecurringMeeting::Show.new(recurring_meeting).with_capybara_page(page) }+ let(:request) { delete recurring_meeting_path(recurring_meeting) }++ subject do+ request+ response+ end++ before do+ login_as(current_user)++ # Assuming the first init job has run+ RecurringMeetings::InitNextOccurrenceJob.perform_now(recurring_meeting, recurring_meeting.first_occurrence.to_time)+ end++ context "when user has permissions to access" do+ it "deletes the series" do+ title = recurring_meeting.title+ expect(subject).to have_http_status(:found)++ expect { recurring_meeting.reload }.to raise_error(ActiveRecord::RecordNotFound)++ perform_enqueued_jobs+ expect(ActionMailer::Base.deliveries.size).to eq(1)+ mail = ActionMailer::Base.deliveries.first+ expect(mail.body.parts.first.parts.first.body.to_s)+ .to include "Meeting series '#{title}' has been cancelled by #{user.name}."+ end++ context "when deleting an occurrence" do+ let(:request) { delete meeting_path(recurring_meeting.meetings.not_templated.last) }++ it "deletes the occurrence" do+ title = recurring_meeting.template.title+ expect { subject }.to change(recurring_meeting.meetings, :count).by(-1)+ expect(subject).to have_http_status(:see_other)++ expect(recurring_meeting.reload).to be_present+ expect(ActionMailer::Base.deliveries.size).to eq(1)+ mail = ActionMailer::Base.deliveries.first+ expect(mail.body.parts.first.parts.first.body.to_s)+ .to include "An occurrence of '#{title}' has been cancelled by #{user.name}."+ end+ end+ end++ context "when user has no permissions to access" do+ let(:current_user) { create(:user) }++ it "does not show the recurring meetings" do+ delete recurring_meeting_path(recurring_meeting)+ expect(response).to have_http_status(:not_found)+ end++ it "does not show project recurring meetings" do+ delete project_recurring_meeting_path(project, recurring_meeting)+ expect(response).to have_http_status(:not_found)+ end+ end+enddiff --git a/spec/mailers/previews/meeting_mailer_preview.rb b/spec/mailers/previews/meeting_mailer_preview.rbindex f97912c6318..3be6f213b68 100644--- a/spec/mailers/previews/meeting_mailer_preview.rb+++ b/spec/mailers/previews/meeting_mailer_preview.rb@@ -45,6 +45,40 @@ class MeetingMailerPreview < ActionMailer::PreviewMeetingMailer.rescheduled(meeting, user, actor, changes:)end+ def cancelled+ language = params["locale"] || I18n.default_locale+ actor = FactoryBot.build_stubbed(:user, lastname: "Actor")+ user = FactoryBot.build_stubbed(:user, language:)+ meeting = FactoryBot.build_stubbed(:meeting, start_time: 1.day.from_now, duration: 1.0)++ MeetingMailer.cancelled(meeting, user, actor)+ end++ def cancelled_occurrence+ language = params["locale"] || I18n.default_locale+ actor = FactoryBot.build_stubbed(:user, lastname: "Actor")+ user = FactoryBot.build_stubbed(:user, language:)++ recurring_meeting = RecurringMeeting.last+ raise "Need to have a recurring meeting in your dev db" unless recurring_meeting++ schedule = recurring_meeting.scheduled_meetings.first+ raise "Need to have a recurring meeting with at least a schedule meeting" unless schedule++ MeetingMailer.cancelled(schedule.meeting, user, actor)+ end++ def cancelled_series+ language = params["locale"] || I18n.default_locale+ actor = FactoryBot.build_stubbed(:user, lastname: "Actor")+ user = FactoryBot.build_stubbed(:user, language:)++ recurring_meeting = RecurringMeeting.last+ raise "Need to have a recurring meeting in your dev db" unless recurring_meeting++ MeetingMailer.cancelled_series(recurring_meeting, user, actor)+ end+def invitedlanguage = params["locale"] || I18n.default_localeactor = FactoryBot.build_stubbed(:user, lastname: "Actor")