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
Replace content specific notify and icalendar
Oliver Günther5542552c8494
diff --git a/modules/meeting/app/controllers/meeting_contents_controller.rb b/modules/meeting/app/controllers/meeting_contents_controller.rbindex 9da573568a2..0a729cf6fb9 100644--- a/modules/meeting/app/controllers/meeting_contents_controller.rb+++ b/modules/meeting/app/controllers/meeting_contents_controller.rb@@ -90,36 +90,6 @@ class MeetingContentsController < ApplicationControllerrender_404end- def notify- unless @content.new_record?- 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- end- redirect_back_or_default controller: '/meetings', action: 'show', id: @meeting- end-- def icalendar- unless @content.new_record?- service = MeetingNotificationService.new(@meeting)- result = service.call(:icalendar_notification, include_author: true)-- 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- end- redirect_back_or_default controller: '/meetings', action: 'show', id: @meeting- end-def default_breadcrumbMeetingsController.new.send(:default_breadcrumb)enddiff --git a/modules/meeting/app/helpers/meeting_contents_helper.rb b/modules/meeting/app/helpers/meeting_contents_helper.rbindex 9d9eb4498b3..cbc2fca7015 100644--- a/modules/meeting/app/helpers/meeting_contents_helper.rb+++ b/modules/meeting/app/helpers/meeting_contents_helper.rb@@ -45,11 +45,6 @@ module MeetingContentsHelpermenu << meeting_content_edit_link(content_type) if can_edit_meeting_content?(content, content_type)menu << meeting_content_history_link(content_type, content.meeting)- if saved_meeting_content_text_present?(content)- menu << meeting_content_notify_link(content_type, content.meeting)- menu << meeting_content_icalendar_link(content_type, content.meeting)- end-menu.join(' ')end@@ -129,28 +124,6 @@ module MeetingContentsHelperendend- def meeting_content_notify_link(content_type, meeting)- content_tag :li, '', class: 'toolbar-item' do- link_to_if_authorized({ controller: '/' + content_type.pluralize,- action: 'notify', meeting_id: meeting },- method: :put,- class: 'button') do- text_with_icon(I18n.t(:label_notify), 'icon-mail1')- end- end- end-- def meeting_content_icalendar_link(content_type, meeting)- content_tag :li, '', class: 'toolbar-item' do- link_to_if_authorized({ controller: '/' + content_type.pluralize,- action: 'icalendar', meeting_id: meeting },- method: :put,- class: 'button') do- text_with_icon(I18n.t(:label_icalendar), 'icon-calendar2')- end- end- end-def text_with_icon(text, icon)op_icon("button--icon #{icon}") +' ' +diff --git a/modules/meeting/app/views/meetings/show.html.erb b/modules/meeting/app/views/meetings/show.html.erbindex aceab9f7e5e..0717c5d719b 100644--- a/modules/meeting/app/views/meetings/show.html.erb+++ b/modules/meeting/app/views/meetings/show.html.erb@@ -30,7 +30,7 @@ See COPYRIGHT and LICENSE files for more details.<% html_title "#{t(:label_meeting)}: #{@meeting.title}" %><%= toolbar title: t(:label_meeting),link_to: link_to(@meeting),- html: { class: 'meeting--main-toolbar' } do %>+ html: { class: 'meeting--main-toolbar -with-dropdown' } do %><% unless User.current.anonymous? %><li class="toolbar-item hidden-for-tablet"><div class="button">@@ -40,31 +40,56 @@ See COPYRIGHT and LICENSE files for more details.<% end %><% if authorize_for(:meetings, :edit) %><li class="toolbar-item">- <%= link_to({:controller => '/meetings', :action => 'edit', :id => @meeting}, class: 'button',:accesskey => accesskey(:edit)) do%>+ <%= link_to({ :controller => '/meetings', :action => 'edit', :id => @meeting }, class: 'button', :accesskey => accesskey(:edit)) do %><%= op_icon('button--icon icon-edit') %><span class="button--text"><%= t(:button_edit) %></span><% end %></li><% end %>- <% if authorize_for(:meetings, :copy) %>- <li class="toolbar-item hidden-for-tablet">- <%= link_to({:controller => '/meetings', :action => 'copy', :id => @meeting}, class: 'button') do %>- <%= op_icon('button--icon icon-copy') %>- <span class="button--text"><%= t(:button_copy) %></span>++ <li class="toolbar-item drop-down">+ <a+ href="#"+ aria-haspopup="true"+ title="<%= t(:label_more) %>"+ class="button"+ data-test-selector="meetings-more-dropdown-menu"+ >+ <%= op_icon('button--icon icon-show-more') %>+ </a>+ <ul style="display:none;" class="menu-drop-down-container">+ <% if authorize_for(:meetings, :notify) %>+ <li>+ <%= link_to t('meeting.label_mail_all_participants'),+ notify_meeting_path(@meeting),+ class: 'icon-context icon-mail1' %>+ </li><% end %>- </li>- <% end %>- <% if authorize_for(:meetings, :destroy) %>- <li class="toolbar-item">- <%= link_to({controller: '/meetings', action: 'destroy', id: @meeting},- class: 'button',- method: :delete,- data: { confirm: t(:text_are_you_sure) }) do %>- <%= op_icon('button--icon icon-delete') %>- <span class="button--text"><%= t(:button_delete) %></span>+ <% if authorize_for(:meetings, :icalendar) %>+ <li>+ <%= link_to t(:label_icalendar_download),+ download_ics_meeting_path(@meeting),+ class: 'icon-context icon-calendar2' %>+ </li><% end %>- </li>- <% end %>+ <% if authorize_for(:meetings, :copy) %>+ <li>+ <%= link_to(t(:button_copy),+ copy_meeting_path(@meeting),+ class: 'icon-context icon-copy') %>+ </li>+ <% end %>+ <% if authorize_for(:meetings, :destroy) %>+ <li>+ <%= link_to(t(:button_delete),+ meeting_path(@meeting),+ class: 'icon-context icon-delete',+ method: :delete,+ data: { confirm: t(:text_are_you_sure) }) %>+ </li>+ <% end %>+ </ul>+ </li><% end %><div class="meeting details box">@@ -74,28 +99,36 @@ See COPYRIGHT and LICENSE files for more details.<p class="author"><%= authoring @meeting.created_at, @meeting.author %></p></div><div class="grid-content small-6">- <p><strong><%= Meeting.human_attribute_name(:start_time) %></strong>: <%= format_date @meeting.start_time %> <%= format_time @meeting.start_time, false %> - <%= format_time @meeting.end_time, false %> <%= Time.zone %></p>+ <p>+ <strong><%= Meeting.human_attribute_name(:start_time) %></strong>: <%= format_date @meeting.start_time %> <%= format_time @meeting.start_time, false %>+ - <%= format_time @meeting.end_time, false %> <%= Time.zone %></p></div><div class="grid-content small-6">- <p><strong><%= Meeting.human_attribute_name(:location) %></strong>: <%= auto_link(h(@meeting.location), link: :all, html: { target: '_blank' }) %></p>+ <p>+ <strong><%= Meeting.human_attribute_name(:location) %></strong>: <%= auto_link(h(@meeting.location), link: :all, html: { target: '_blank' }) %>+ </p></div><div class="grid-content small-12">- <p><strong><%= Meeting.human_attribute_name(:participants_invited) %></strong>: <%= format_participant_list @meeting.participants.invited %></p>+ <p>+ <strong><%= Meeting.human_attribute_name(:participants_invited) %></strong>: <%= format_participant_list @meeting.participants.invited %>+ </p></div><div class="grid-content small-12">- <p><strong><%= Meeting.human_attribute_name(:participants_attended) %></strong>: <%= format_participant_list @meeting.participants.attended %></p>+ <p>+ <strong><%= Meeting.human_attribute_name(:participants_attended) %></strong>: <%= format_participant_list @meeting.participants.attended %>+ </p></div></div></div>-<%= render_tabs [{:name => 'agenda', :action => :create_meeting_agendas, :partial => 'meeting_contents/show', :path => meeting_agenda_path(@meeting), :label => :label_meeting_agenda, :content => @meeting.agenda || @meeting.build_agenda, :content_type => "meeting_agenda"},- {:name => 'minutes', :action => :create_meeting_minutes, :partial => 'meeting_contents/show', :path => meeting_minutes_path(@meeting), :label => :label_meeting_minutes, :content => @meeting.minutes || @meeting.build_minutes, :content_type => "meeting_minutes"}] %>+<%= render_tabs [{ :name => 'agenda', :action => :create_meeting_agendas, :partial => 'meeting_contents/show', :path => meeting_agenda_path(@meeting), :label => :label_meeting_agenda, :content => @meeting.agenda || @meeting.build_agenda, :content_type => "meeting_agenda" },+ { :name => 'minutes', :action => :create_meeting_minutes, :partial => 'meeting_contents/show', :path => meeting_minutes_path(@meeting), :label => :label_meeting_minutes, :content => @meeting.minutes || @meeting.build_minutes, :content_type => "meeting_minutes" }] %><% if @meeting.journals.changing.present? %>-<div id="history">- <h3><%=t(:label_history)%></h3>- <% @meeting.journals.each do |journal| %>- <%= render_meeting_journal @meeting, journal %>- <% end %>-</div>+ <div id="history">+ <h3><%= t(:label_history) %></h3>+ <% @meeting.journals.each do |journal| %>+ <%= render_meeting_journal @meeting, journal %>+ <% end %>+ </div><% end %>diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rbindex e28a792f98e..a27824fb4da 100644--- a/modules/meeting/config/routes.rb+++ b/modules/meeting/config/routes.rb@@ -74,8 +74,6 @@ OpenProject::Application.routes.draw doget :diffput :closeput :open- put :notify- put :icalendarpost :previewend@@ -87,8 +85,6 @@ OpenProject::Application.routes.draw domember doget :historyget :diff- put :notify- get :icalendarendend@@ -96,7 +92,6 @@ OpenProject::Application.routes.draw domember doget :historyget :diff- put :notifypost :previewenddiff --git a/modules/meeting/spec/controllers/meeting_contents_controller_spec.rb b/modules/meeting/spec/controllers/meeting_contents_controller_spec.rbdeleted file mode 100644index 18d4d4b4c4b..00000000000--- a/modules/meeting/spec/controllers/meeting_contents_controller_spec.rb+++ /dev/null@@ -1,131 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) 2012-2023 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 MeetingContentsController do- shared_let(:role) { create(:project_role, permissions: [:view_meetings]) }- shared_let(:project) { create(:project) }- shared_let(:author) { create(:user, member_with_roles: { project => role }) }- shared_let(:watcher1) { create(:user, member_with_roles: { project => role }) }- shared_let(:watcher2) { create(:user, member_with_roles: { project => role }) }- shared_let(:meeting) do- User.execute_as author do- meeting = build(:meeting, author:, project:)- meeting.participants.build(user: watcher1, invited: true, attended: false)- meeting.participants.build(user: watcher2, invited: true, attended: false)-- meeting.save!- meeting- end- end- shared_let(:meeting_agenda) do- User.execute_as author do- create(:meeting_agenda, meeting:)- end- end-- before do- ActionMailer::Base.deliveries = []- allow_any_instance_of(MeetingContentsController).to receive(:find_content)- allow(controller).to receive(:authorize)- controller.instance_variable_set(:@content, meeting_agenda.meeting.agenda)- controller.instance_variable_set(:@content_type, 'meeting_agenda')- end-- shared_examples_for 'delivered by mail' do- before { put action, params: { meeting_id: meeting.id } }-- it 'submits the mails' do- perform_enqueued_jobs-- expect(ActionMailer::Base.deliveries.count).to eql(mail_count)- end- end-- describe 'PUT' do- describe 'notify' do- let(:action) { 'notify' }-- before do- author.save!- end-- it_behaves_like 'delivered by mail' do- let(:mail_count) { 2 }- end-- context 'with an error during deliver' do- before do- allow(MeetingMailer).to receive(:invited).and_raise(Net::SMTPError)- end-- it 'does not raise an error' do- expect { put 'notify', params: { meeting_id: meeting.id } }.not_to raise_error- end-- it 'produces a flash message containing the mail addresses raising the error' do- put 'notify', params: { meeting_id: meeting.id }- meeting.participants.each do |participant|- expect(flash[:error]).to include(participant.name)- end- end- end- end-- describe 'icalendar' do- let(:action) { 'icalendar' }-- before do- author.save!- end-- it_behaves_like 'delivered by mail' do- let(:mail_count) { 3 }- end-- context 'with an error during deliver' do- before do- author.save!- allow(MeetingMailer).to receive(:invited).and_raise(Net::SMTPError)- end-- it 'does not raise an error' do- expect { put 'notify', params: { meeting_id: meeting.id } }.not_to raise_error- end-- it 'produces a flash message containing the mail addresses raising the error' do- put 'notify', params: { meeting_id: meeting.id }- meeting.participants.each do |participant|- expect(flash[:error]).to include(participant.name)- end- end- end- end- end-enddiff --git a/modules/meeting/spec/controllers/meetings_controller_spec.rb b/modules/meeting/spec/controllers/meetings_controller_spec.rbindex aaec71aa276..25b70d14a91 100644--- a/modules/meeting/spec/controllers/meetings_controller_spec.rb+++ b/modules/meeting/spec/controllers/meetings_controller_spec.rb@@ -223,4 +223,32 @@ RSpec.describe MeetingsController doendendend++ describe 'notify' do+ let!(:meeting) { create(:meeting) }+ let!(:participant) { create(:meeting_participant, meeting:, attended: true) }++ it 'produces a background job for notification' do+ post :notify, params: { id: meeting.id }++ perform_enqueued_jobs+ expect(ActionMailer::Base.deliveries.count).to eq(1)+ end++ context 'with an error during deliver' do+ before do+ allow(MeetingMailer).to receive(:invited).and_raise(Net::SMTPError)+ end++ it 'produces a flash message containing the mail addresses raising the error' do+ expect { post :notify, params: { id: meeting.id } }.not_to raise_error+ meeting.participants.each do |participant|+ expect(flash[:error]).to include(participant.name)+ end++ perform_enqueued_jobs+ expect(ActionMailer::Base.deliveries.count).to eq(0)+ end+ end+ endenddiff --git a/modules/meeting/spec/features/meetings_copy_spec.rb b/modules/meeting/spec/features/meetings_copy_spec.rbindex 74060cec645..a7558b9ad4e 100644--- a/modules/meeting/spec/features/meetings_copy_spec.rb+++ b/modules/meeting/spec/features/meetings_copy_spec.rb@@ -78,7 +78,8 @@ RSpec.describe 'Meetings copy', :js, :with_cuprite doclick_link meeting.title- within '.meeting--main-toolbar' do+ find_test_selector('meetings-more-dropdown-menu').click+ page.within('.menu-drop-down-container') doclick_link 'Copy'enddiff --git a/modules/meeting/spec/features/meetings_delete_spec.rb b/modules/meeting/spec/features/meetings_delete_spec.rbindex 5099b74948c..bc0667ca6db 100644--- a/modules/meeting/spec/features/meetings_delete_spec.rb+++ b/modules/meeting/spec/features/meetings_delete_spec.rb@@ -56,6 +56,7 @@ RSpec.describe 'Meetings deletion' doclick_link meeting.titleaccept_confirm do+ find_test_selector('meetings-more-dropdown-menu').clickclick_link "Delete"end@@ -64,6 +65,7 @@ RSpec.describe 'Meetings deletion' doclick_link other_meeting.titleaccept_confirm do+ find_test_selector('meetings-more-dropdown-menu').clickclick_link "Delete"end