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

Send out mail when recurring meeting template completed (#17492)

Oliver Günther156794fa6755
diff --git a/modules/meeting/app/components/meetings/header_component.html.erb b/modules/meeting/app/components/meetings/header_component.html.erb
index ee89a02dd97..0d74c0b80e7 100644
--- a/modules/meeting/app/components/meetings/header_component.html.erb
+++ b/modules/meeting/app/components/meetings/header_component.html.erb
@@ -68,7 +68,7 @@
end
menu.with_item(label: t(:label_icalendar_download),
- href: download_ics_meeting_path(@meeting)) do |item|
+ href: ics_download_path) do |item|
item.with_leading_visual_icon(icon: :download)
end
diff --git a/modules/meeting/app/components/meetings/header_component.rb b/modules/meeting/app/components/meetings/header_component.rb
index 38c7cf45bc2..918390ed497 100644
--- a/modules/meeting/app/components/meetings/header_component.rb
+++ b/modules/meeting/app/components/meetings/header_component.rb
@@ -52,6 +52,14 @@ module Meetings
10_000
end
+ def ics_download_path
+ if @series
+ download_ics_recurring_meeting_path(@series, occurrence_id: @meeting.id)
+ else
+ download_ics_meeting_path(@meeting)
+ end
+ end
+
private
def delete_enabled?
diff --git a/modules/meeting/app/components/recurring_meetings/row_component.rb b/modules/meeting/app/components/recurring_meetings/row_component.rb
index 8a958c87171..5056956be62 100644
--- a/modules/meeting/app/components/recurring_meetings/row_component.rb
+++ b/modules/meeting/app/components/recurring_meetings/row_component.rb
@@ -163,7 +163,7 @@ module RecurringMeetings
return unless instantiated? && !cancelled?
menu.with_item(label: I18n.t(:label_icalendar_download),
- href: download_ics_meeting_path(meeting),
+ href: download_ics_recurring_meeting_path(model.recurring_meeting, occurrence_id: model.id),
content_arguments: {
data: { turbo: false }
}) do |item|
diff --git a/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb b/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb
index 998c20bc9bc..2727f774173 100644
--- a/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb
+++ b/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb
@@ -30,12 +30,24 @@
},
'aria-label': t(:label_recurring_meeting_series_edit),
test_selector: "edit-meeting-details-button",
- )
+ ) do |item|
+ item.with_leading_visual_icon(icon: :pencil)
+ end
menu.with_item(
label: t(:label_icalendar_download),
href: download_ics_recurring_meeting_path(@meeting)
- )
+ ) do |item|
+ item.with_leading_visual_icon(icon: :calendar)
+ end
+
+ menu.with_item(
+ label: t('meeting.label_mail_all_participants'),
+ href: notify_recurring_meeting_path(@meeting),
+ form_arguments: { method: :post }
+ ) do |item|
+ item.with_leading_visual_icon(icon: :mail)
+ end
menu.with_item(
label: I18n.t(:label_recurring_meeting_series_delete),
@@ -44,7 +56,9 @@
form_arguments: {
method: :delete, data: { confirm: t("text_are_you_sure"), turbo: 'false' }
}
- )
+ ) do |item|
+ item.with_leading_visual_icon(icon: :trash)
+ end
end
end
end %>
diff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rb
index cbf5d1daa16..573b8b16cd9 100644
--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb
+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb
@@ -7,8 +7,10 @@ class RecurringMeetingsController < ApplicationController
include OpTurbo::DialogStreamHelper
before_action :find_meeting,
- only: %i[show update details_dialog destroy edit init delete_scheduled template_completed download_ics]
- before_action :find_optional_project, only: %i[index show new create update details_dialog destroy edit delete_scheduled]
+ only: %i[show update details_dialog destroy edit init
+ delete_scheduled template_completed download_ics notify]
+ before_action :find_optional_project,
+ only: %i[index show new create update details_dialog destroy edit delete_scheduled notify]
before_action :authorize_global, only: %i[index new create]
before_action :authorize, except: %i[index new create]
before_action :get_scheduled_meeting, only: %i[delete_scheduled]
@@ -150,6 +152,7 @@ class RecurringMeetingsController < ApplicationController
.call(start_time: @first_occurrence.to_time)
if call.success?
+ deliver_invitation_mails
flash[:success] = I18n.t("recurring_meeting.occurrence.first_created")
else
flash[:error] = call.message
@@ -168,18 +171,46 @@ class RecurringMeetingsController < ApplicationController
redirect_to polymorphic_path([@project, @recurring_meeting]), status: :see_other
end
- def download_ics
- ::RecurringMeetings::ICalService
- .new(user: current_user, series: @recurring_meeting)
- .call
+ def download_ics # rubocop:disable Metrics/AbcSize
+ service = ::RecurringMeetings::ICalService.new(user: current_user, series: @recurring_meeting)
+ filename, result =
+ if params[:occurrence_id].present?
+ occurrence = @recurring_meeting.meetings.find_by(id: params[:occurrence_id])
+ ["#{@recurring_meeting.title} - #{occurrence.start_time.to_date.iso8601}",
+ service.generate_occurrence(occurrence)]
+ else
+ [@recurring_meeting.title, service.generate_series]
+ end
+
+ result
.on_failure { |call| render_500(message: call.message) }
.on_success do |call|
- send_data call.result, filename: filename_for_content_disposition("#{@recurring_meeting.title}.ics")
+ send_data call.result, filename: filename_for_content_disposition("#{filename}.ics")
end
end
+ def notify
+ deliver_invitation_mails
+ flash[:notice] = I18n.t(:notice_successful_notification)
+ redirect_to action: :show
+ end
+
private
+ def deliver_invitation_mails
+ @recurring_meeting
+ .template
+ .participants
+ .invited
+ .find_each do |participant|
+ MeetingSeriesMailer.template_completed(
+ @recurring_meeting,
+ participant.user,
+ User.current
+ ).deliver_later
+ end
+ end
+
def upcoming_meetings(count:)
meetings = @recurring_meeting
.scheduled_instances(upcoming: true)
diff --git a/modules/meeting/app/mailers/meeting_mailer.rb b/modules/meeting/app/mailers/meeting_mailer.rb
index fa026b3eb58..30e452131d2 100644
--- a/modules/meeting/app/mailers/meeting_mailer.rb
+++ b/modules/meeting/app/mailers/meeting_mailer.rb
@@ -72,9 +72,7 @@ class MeetingMailer < UserMailer
def with_attached_ics(meeting, user)
User.execute_as(user) do
- call = ::Meetings::ICalService
- .new(user:, meeting: @meeting)
- .call
+ call = ics_service_call(meeting, user)
call.on_success do
attachments["meeting.ics"] = call.result
@@ -88,6 +86,18 @@ class MeetingMailer < UserMailer
end
end
+ def ics_service_call(meeting, user)
+ if meeting.recurring?
+ ::RecurringMeetings::ICalService
+ .new(user:, series: meeting.recurring_meeting)
+ .generate_occurrence(meeting.scheduled_meeting)
+ else
+ ::Meetings::ICalService
+ .new(user:, meeting:)
+ .call
+ end
+ end
+
def set_headers(meeting)
open_project_headers "Project" => meeting.project.identifier, "Meeting-Id" => meeting.id
headers["Content-Type"] = 'text/calendar; charset=utf-8; method="PUBLISH"; name="meeting.ics"'
diff --git a/modules/meeting/app/mailers/meeting_series_mailer.rb b/modules/meeting/app/mailers/meeting_series_mailer.rb
new file mode 100644
index 00000000000..0eafbab385b
--- /dev/null
+++ b/modules/meeting/app/mailers/meeting_series_mailer.rb
@@ -0,0 +1,70 @@
+#-- 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.
+#++
+
+class MeetingSeriesMailer < UserMailer
+ def template_completed(series, user, actor)
+ @actor = actor
+ @series = series
+ @template = series.template
+ @next_occurrence = series.next_occurrence&.to_time
+ @user = user
+
+ set_headers(series)
+
+ with_attached_ics(series, user) do
+ subject = I18n.t("meeting.email.series.title", title: series.title, project_name: series.project.name)
+ mail(to: user, subject:)
+ end
+ end
+
+ private
+
+ def with_attached_ics(series, user)
+ User.execute_as(user) do
+ call = ::RecurringMeetings::ICalService
+ .new(user:, series: series)
+ .generate_series
+
+ call.on_success do
+ attachments["meeting.ics"] = call.result
+
+ yield
+ end
+
+ call.on_failure do
+ Rails.logger.error { "Failed to create ICS attachment for meeting #{series.id}: #{call.message}" }
+ end
+ end
+ end
+
+ def set_headers(series)
+ open_project_headers "Project" => series.project.identifier, "Meeting-Id" => series.id
+ headers["Content-Type"] = 'text/calendar; charset=utf-8; method="PUBLISH"; name="meeting.ics"'
+ headers["Content-Transfer-Encoding"] = "8bit"
+ end
+end
diff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rb
index 8f38e8a6aea..284df15be1a 100644
--- a/modules/meeting/app/models/meeting.rb
+++ b/modules/meeting/app/models/meeting.rb
@@ -117,6 +117,10 @@ class Meeting < ApplicationRecord
closed: 5
}
+ def recurring?
+ recurring_meeting_id.present?
+ end
+
##
# Cache key for detecting changes to be shown to the user
def changed_hash
diff --git a/modules/meeting/app/services/recurring_meetings/ical_service.rb b/modules/meeting/app/services/recurring_meetings/ical_service.rb
index b68633d16b4..dd3c6c80173 100644
--- a/modules/meeting/app/services/recurring_meetings/ical_service.rb
+++ b/modules/meeting/app/services/recurring_meetings/ical_service.rb
@@ -43,23 +43,45 @@ module RecurringMeetings
def initialize(series:, user:)
@user = user
@series = series
+ @schedule = series.schedule
@url_helpers = OpenProject::StaticRouting::StaticUrlHelpers.new
end
- def call # rubocop:disable Metrics/AbcSize
- User.execute_as(user) do
- @timezone = Time.zone || Time.zone_default
- @calendar = build_icalendar(series.start_time)
- @schedule = series.schedule
- ServiceResult.success(result: generate_ical)
+ def generate_series
+ ical_result(series) do
+ series_event
+ occurrences_events
end
rescue StandardError => e
- Rails.logger.error("Failed to generate ICS for meeting series #{@series.id}: #{e.message}")
+ Rails.logger.error("Failed to generate ICS for meeting series #{series.id}: #{e.message}")
+ ServiceResult.failure(message: e.message)
+ end
+
+ def generate_occurrence(meeting)
+ # Get the time the meeting was scheduled to take place
+ scheduled_meeting = meeting.scheduled_meeting
+ ical_result(scheduled_meeting) do
+ occurrence_event(scheduled_meeting.start_time, meeting)
+ end
+ rescue StandardError => e
+ Rails.logger.error("Failed to generate ICS for meeting #{meeting.id}: #{e.message}")
ServiceResult.failure(message: e.message)
end
private
+ def ical_result(meeting)
+ User.execute_as(user) do
+ @timezone = Time.zone || Time.zone_default
+ @calendar = build_icalendar(meeting.start_time)
+
+ yield
+
+ calendar.publish
+ ServiceResult.success(result: calendar.to_ical)
+ end
+ end
+
def tzinfo
timezone.tzinfo
end
@@ -68,18 +90,11 @@ module RecurringMeetings
tzinfo.canonical_identifier
end
- def generate_ical
- series_event
- occurrences_events
-
- calendar.publish
- calendar.to_ical
- end
-
def series_event # rubocop:disable Metrics/AbcSize
calendar.event do |e|
base_series_attributes(e)
+ e.rrule = schedule.rrules.first.to_ical # We currently only have one recurrence rule
e.dtstart = ical_datetime template.start_time, tzid
e.dtend = ical_datetime template.end_time, tzid
e.url = url_helpers.project_recurring_meeting_url(series.project, series)
@@ -105,6 +120,7 @@ module RecurringMeetings
e.dtend = ical_datetime meeting.end_time, tzid
e.url = url_helpers.project_meeting_url(meeting.project, meeting)
e.location = meeting.location.presence
+ e.sequence = meeting.lock_version
add_attendees(e, meeting)
end
@@ -120,7 +136,6 @@ module RecurringMeetings
def base_series_attributes(event) # rubocop:disable Metrics/AbcSize
event.uid = ical_uid("meeting-series-#{series.id}")
- event.rrule = schedule.rrules.first.to_ical # We currently only have one recurrence rule
event.summary = "[#{series.project.name}] #{series.title}"
event.description = "[#{series.project.name}] #{I18n.t(:label_meeting_series)}: #{series.title}"
event.organizer = ical_organizer(series)
diff --git a/modules/meeting/app/views/meeting_series_mailer/template_completed.html.erb b/modules/meeting/app/views/meeting_series_mailer/template_completed.html.erb
new file mode 100644
index 00000000000..fb9726fd4f1
--- /dev/null
+++ b/modules/meeting/app/views/meeting_series_mailer/template_completed.html.erb
@@ -0,0 +1,115 @@
+<%#-- 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.series.summary', 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%') %>">
+ <%= I18n.t(:label_recurring_meeting_schedule) %>
+ </td>
+ <td style="<%= placeholder_text_styles %>">
+ <%= @series.full_schedule_in_words %> (<%= formatted_time_zone_offset %>)
+ </td>
+ </tr>
+ <% if @next_occurrence %>
+ <tr>
+ <td style="<%= placeholder_text_styles(width: '30%') %>">
+ <%= I18n.t(:label_recurring_meeting_next_occurrence) %>
+ </td>
+ <td style="<%= placeholder_text_styles %>">
+ <%= format_time_as_date @next_occurrence %> <%= format_time @next_occurrence, include_date: false %>
+ (<%= formatted_time_zone_offset %>)
+ </td>
+ </tr>
+ <% end %>
+ <% if @template.location.present? %>
+ <tr>
+ <td style="<%= placeholder_text_styles(width: '30%') %>">
+ <%= Meeting.human_attribute_name(:location) %>
+ </td>
+ <td style="<%= placeholder_text_styles %>">
+ <%= auto_link @template.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 @series.project.name, project_url(@series.project) %>
+ </td>
+ </tr>
+ <tr>
+ <td style="<%= placeholder_text_styles(width: '30%') %>">
+ <%= Meeting.human_attribute_name(:author) %>
+ </td>
+ <td style="<%= placeholder_text_styles %>">
+ <%= @series.author %>
+ </td>
+ </tr>
+ <% if @template.participants.exists? %>
+ <tr>
+ <td style="<%= placeholder_text_styles(width: '30%') %>">
+ <%= Meeting.human_attribute_name(:participants_invited) %>
+ </td>
+ <td style="<%= placeholder_text_styles %>">
+ <%= @template.participants.invited.sort.join("; ") %>
+ </td>
+ </tr>
+ <% end %>
+ </table>
+ </td>
+ </tr>
+ <% end %>
+
+ <table>
+ <tr>
+ <%= placeholder_cell('20px', vertical: false) %>
+ </tr>
+ </table>
+
+ <%= action_button do %>
+ <%= link_to I18n.t(:'meeting.email.open_meeting_link'),
+ recurring_meeting_url(@series),
+ target: '_blank',
+ style: "color: #333333; text-decoration: none; font-size: 14px;white-space: nowrap;" %>
+ <% end %>
+<% end %>
diff --git a/modules/meeting/app/views/meeting_series_mailer/template_completed.text.erb b/modules/meeting/app/views/meeting_series_mailer/template_completed.text.erb
new file mode 100644
index 00000000000..c86fa4bece0
--- /dev/null
+++ b/modules/meeting/app/views/meeting_series_mailer/template_completed.text.erb
@@ -0,0 +1,37 @@
+<%#-- 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.series.summary', title: @series.title, actor: @actor) %>
+
+<%= @series.project.name %>: <%= @series.title %> (<%= meeting_url(@series) %>)
+<%= @series.author %>
+
+<%=t :label_meeting_date_time %>: <%= format_time_as_date @template.start_time %> <%= format_time @template.start_time, include_date: false %>-<%= format_time @template.end_time, include_date: false %> (<%= formatted_time_zone_offset %>)
+<%= Meeting.human_attribute_name(:location) %>: <%= @template.location %>
+<%= Meeting.human_attribute_name(:participants_invited) %>: <%= @template.participants.invited.sort.join("; ") %>
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index 58a296ee62e..3a055257032 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -144,6 +144,8 @@ en:
Any meeting information not in the template will be lost.
Do you want to continue?
label_recurring_meeting_restore: "Restore this occurrence"
+ label_recurring_meeting_schedule: "Schedule"
+ label_recurring_meeting_next_occurrence: "Next occurrence"
label_recurring_meeting_more: "There are %{count} more scheduled meetings (%{schedule})."
label_recurring_meeting_more_singular: "There is %{count} more scheduled meeting (%{schedule})."
label_recurring_meeting_more_past: "There are %{count} more past meetings."
@@ -195,6 +197,9 @@ 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"
+ 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}"
rescheduled:
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index 4d6b4b84570..a87305227bf 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -63,6 +63,7 @@ Rails.application.routes.draw do
post :init
post :delete_scheduled
post :template_completed
+ post :notify
end
collection do
get :humanize_schedule, controller: "recurring_meetings/schedule", action: :humanize_schedule
diff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rb
index 4668c82dc4c..7f2a0816d9f 100644
--- a/modules/meeting/lib/open_project/meeting/engine.rb
+++ b/modules/meeting/lib/open_project/meeting/engine.rb
@@ -62,7 +62,8 @@ module OpenProject::Meeting
permission :edit_meetings,
{
meetings: %i[edit cancel_edit update update_title details_dialog update_details update_participants],
- recurring_meetings: %i[edit cancel_edit update update_title details_dialog update_details],
+ recurring_meetings: %i[edit cancel_edit update update_title details_dialog update_details
+ notify],
work_package_meetings_tab: %i[add_work_package_to_meeting_dialog add_work_package_to_meeting]
},
permissible_on: :project,
diff --git a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_create_spec.rb b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_create_spec.rb
index f2daa6ed7a9..14e56f2b8fe 100644
--- a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_create_spec.rb
+++ b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_create_spec.rb
@@ -61,6 +61,7 @@ RSpec.describe "Recurring meetings creation",
let(:current_user) { user }
let(:meeting) { RecurringMeeting.last }
let(:show_page) { Pages::RecurringMeeting::Show.new(meeting) }
+ let(:template_page) { Pages::StructuredMeeting::Show.new(meeting.template) }
let(:meetings_page) { Pages::Meetings::Index.new(project:) }
before do
@@ -96,13 +97,36 @@ RSpec.describe "Recurring meetings creation",
# Use is redirected to the template
expect(page).to have_current_path(project_meeting_path(project, meeting.template))
expect(page).to have_content(I18n.t("recurring_meeting.template.description"))
+
+ # Add participants
+ template_page.open_participant_form
+ template_page.in_participant_form do
+ template_page.expect_participant_invited(user, invited: true)
+ template_page.expect_participant_invited(other_user, invited: false)
+ template_page.expect_available_participants(count: 2)
+ expect(page).to have_button("Save")
+
+ template_page.invite_participant(other_user)
+
+ template_page.expect_participant_invited(user, invited: true)
+ template_page.expect_participant_invited(other_user, invited: true)
+
+ click_on("Save")
+ end
+ wait_for_network_idle
+
+ expect(page).to have_css("#meetings-side-panel-participants-component", text: 2)
+
expect(page).to have_link("Finish template")
click_link_or_button "Finish template"
+ wait_for_network_idle
- # Does not send invitation mails by default
+ # Sends out an invitation to the series
perform_enqueued_jobs
- expect(ActionMailer::Base.deliveries.size).to eq 0
+ expect(ActionMailer::Base.deliveries.size).to eq 2
+ title = ActionMailer::Base.deliveries.map(&:subject).uniq.first
+ expect(title).to eq "[#{project.name}] Meeting series Some title"
show_page.visit!
expect(page).to have_css(".start_time", count: 3)
diff --git a/modules/meeting/spec/services/recurring_meetings/ical_service_spec.rb b/modules/meeting/spec/services/recurring_meetings/ical_service_spec.rb
index e8554a1c631..026a28729bf 100644
--- a/modules/meeting/spec/services/recurring_meetings/ical_service_spec.rb
+++ b/modules/meeting/spec/services/recurring_meetings/ical_service_spec.rb
@@ -48,7 +48,7 @@ RSpec.describe RecurringMeetings::ICalService, type: :model do # rubocop:disable
let(:template) { series.template }
let(:service) { described_class.new(user:, series:) }
- let(:result) { service.call.result }
+ let(:result) { service.generate_series.result }
let(:parsed_ical) { Icalendar::Calendar.parse(result).first }
let(:parsed_events) { parsed_ical.events }
@@ -73,7 +73,6 @@ RSpec.describe RecurringMeetings::ICalService, type: :model do # rubocop:disable
expect(parsed_events.count).to eq(1)
expect(series_ical).to include("LOCATION:https://example.com/meet/important-meeting")
expect(series_ical).to include("SUMMARY:[My Project] Weekly")
- expect(series_ical).to include("UID:#{Setting.app_title}-#{Setting.host_name}-meeting-series-#{series.id}")
expect(series_ical).to include("ATTENDEE;CN=Bob Barker;[email protected];PARTSTAT=NEEDS-ACTION;RSVP=TRU")
expect(series_ical).to include("ATTENDEE;CN=Foo Fooer;[email protected];PARTSTAT=NEEDS-ACTION;RSVP=TRUE")
end
@@ -144,5 +143,18 @@ RSpec.describe RecurringMeetings::ICalService, type: :model do # rubocop:disable
expect(moved).to include("DTEND;TZID=America/New_York:20241216T073000")
expect(moved).to include("URL:http://#{Setting.host_name}/projects/my-project/meetings/#{moved_schedule.meeting_id}")
end
+
+ context "when passing a specific occurrence" do
+ let(:result) { service.generate_occurrence(schedule.meeting).result }
+
+ it "creates the specific event when requested" do
+ expect(parsed_events.count).to eq(1)
+ occurrence = parsed_events.first.to_ical
+
+ expect(occurrence).to include("DTSTART;TZID=America/New_York:20241208T050000")
+ expect(occurrence).to include("DTEND;TZID=America/New_York:20241208T060000")
+ expect(occurrence).to include("URL:http://#{Setting.host_name}/projects/my-project/meetings/#{schedule.meeting_id}")
+ end
+ end
end
end
diff --git a/modules/meeting/spec/support/pages/structured_meeting/show.rb b/modules/meeting/spec/support/pages/structured_meeting/show.rb
index 34e531761a9..ed23fd69072 100644
--- a/modules/meeting/spec/support/pages/structured_meeting/show.rb
+++ b/modules/meeting/spec/support/pages/structured_meeting/show.rb
@@ -217,8 +217,17 @@ module Pages::StructuredMeeting
expect(page).to have_field(id: "checkbox_attended_#{participant.id}", checked: attended, disabled: !editable)
end
+ def expect_participant_invited(participant, invited: true)
+ expect(page).to have_text(participant.name)
+ expect(page).to have_field(id: "checkbox_invited_#{participant.id}", checked: invited)
+ end
+
def invite_participant(participant)
- check(id: "checkbox_invited_#{participant.id}")
+ id = "checkbox_invited_#{participant.id}"
+ retry_block do
+ check(id:)
+ raise "Expected #{participant.id} to be invited now" unless page.has_checked_field?(id:)
+ end
end
def expect_available_participants(count:)
diff --git a/spec/mailers/previews/meeting_series_mailer_preview.rb b/spec/mailers/previews/meeting_series_mailer_preview.rb
new file mode 100644
index 00000000000..569af0b2123
--- /dev/null
+++ b/spec/mailers/previews/meeting_series_mailer_preview.rb
@@ -0,0 +1,40 @@
+#-- 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.
+#++
+
+class MeetingSeriesMailerPreview < ActionMailer::Preview
+ # Preview emails at http://localhost:3000/rails/mailers/meeting_series_mailer
+
+ def template_completed
+ language = params["locale"] || I18n.default_locale
+ actor = FactoryBot.build_stubbed(:user, lastname: "Actor")
+ user = FactoryBot.build_stubbed(:user, language:)
+ meeting = RecurringMeeting.last
+
+ MeetingSeriesMailer.template_completed(meeting, user, actor)
+ end
+end