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
Update toggle_notifications method to send email
Mir Bhatia4ab8195e2fd6
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rbindex 65a199efba8..baa4c07308e 100644--- a/modules/meeting/app/controllers/meetings_controller.rb+++ b/modules/meeting/app/controllers/meetings_controller.rb@@ -313,15 +313,7 @@ class MeetingsController < ApplicationControllerenddef notify- service = MeetingNotificationService.new(@meeting)- result = service.call(:invited)-- if result.success?- flash[:notice] = I18n.t(:notice_successful_notification)- else- flash[:error] = I18n.t(:error_notification_with_errors,- recipients: result.errors.map(&:name).join("; "))- end+ handle_notification(type: :notify)redirect_to action: :show, id: @meetingend@@ -355,6 +347,10 @@ class MeetingsController < ApplicationControllerdef toggle_notifications@meeting.update!(notify: [email protected])+ if @meeting.notify?+ handle_notification(type: :toggle_notifications)+ end+update_sidebar_component_via_turbo_streamupdate_header_component_via_turbo_stream@@ -573,4 +569,24 @@ class MeetingsController < ApplicationControllerredirect_to job_status_path(job.job_id)endend++ def handle_notification(type:)+ service = MeetingNotificationService.new(@meeting)+ result = service.call(:invited)++ message = if result.success?+ I18n.t(:notice_successful_notification)+ else+ I18n.t(:error_notification_with_errors,+ recipients: result.errors.map(&:name).join("; "))+ end++ if type == :notify+ flash[result.success? ? :notice : :error] = message+ elsif result.success?+ render_success_flash_message_via_turbo_stream(message:)+ else+ render_error_flash_message_via_turbo_stream(message:)+ end+ endenddiff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.ymlindex cf47223a922..86ffd41d2ad 100644--- a/modules/meeting/config/locales/en.yml+++ b/modules/meeting/config/locales/en.yml@@ -301,6 +301,7 @@ en:message:enable: >All participants will receive updated calendar invites via email every time there is a change to the meeting date, time, location or participants.+ Once enabled, an email will be sent out immediately to all participants.disable: >Participants will no longer receive updated calendar invites via email when there are changes to the meeting date, time, location or participants.If they already had an invite for this meeting, it might no longer be accurate.@@ -436,7 +437,7 @@ en:end_series_dialog:title: "End meeting series"- notice_successful_notification: "Notification sent successfully"+ notice_successful_notification: "Email calendar update sent to all participants"notice_timezone_missing: No time zone is set and %{zone} is assumed. To choose your time zone, please click here.notice_meeting_updated: "This page has been updated by someone else. Reload to view changes."diff --git a/modules/meeting/spec/features/meeting_notifications_spec.rb b/modules/meeting/spec/features/meeting_notifications_spec.rbindex da200106b18..fc955a2565c 100644--- a/modules/meeting/spec/features/meeting_notifications_spec.rb+++ b/modules/meeting/spec/features/meeting_notifications_spec.rb@@ -159,7 +159,36 @@ RSpec.describe "Meeting notifications", :js dowait_for_network_idle- # check that no mails are sent on edit/delete+ # enable updates and check that an email is sent out immediately+ page.within("[data-test-selector='notifications-button']") do+ click_on "Enable"+ end++ show_page.expect_modal "Enable email calendar updates?"+ show_page.within_modal "Enable email calendar updates?" do+ click_on "Enable email updates"+ end++ wait_for_network_idle++ expect_flash(message: "Email calendar update sent to all participants")++ perform_enqueued_jobs+ expect(ActionMailer::Base.deliveries.size).to eq 1+ ActionMailer::Base.deliveries.clear++ # check that no mails are sent on edit/delete when disabled+ page.within("[data-test-selector='notifications-button']") do+ click_on "Disable"+ end++ show_page.expect_modal "Disable email calendar updates?"+ show_page.within_modal "Disable email calendar updates?" do+ click_on "Disable email updates"+ end++ wait_for_network_idle+perform_enqueued_jobsexpect(ActionMailer::Base.deliveries.size).to eq 0