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

Update specs

Mir Bhatia9490cb0c91ef
diff --git a/modules/meeting/spec/mailers/meeting_mailer_spec.rb b/modules/meeting/spec/mailers/meeting_mailer_spec.rb
index e17ea369ceb..8c847c3c6c8 100644
--- a/modules/meeting/spec/mailers/meeting_mailer_spec.rb
+++ b/modules/meeting/spec/mailers/meeting_mailer_spec.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -62,6 +63,7 @@ RSpec.describe MeetingMailer do
let(:i18n) do
Class.new do
include Redmine::I18n
+
public :format_date, :format_time
end
end
@@ -132,6 +134,70 @@ RSpec.describe MeetingMailer do
end
end
+ describe "updated" do
+ let(:meeting) do
+ create(:meeting,
+ author:,
+ project:,
+ start_time: "2021-11-09T23:00:00 +0100".to_datetime.utc)
+ end
+ let(:new_start) { "2021-11-12T23:00:00 +0100".to_datetime.utc }
+ let(:changes) do
+ { old_start: meeting.start_time,
+ new_start:,
+ old_duration: 1,
+ new_duration: 1,
+ old_location: nil,
+ new_location: "Some new location" }
+ end
+ let(:mail) { described_class.updated(meeting, watcher1, author, changes:) }
+ # this is needed to call module functions from Redmine::I18n
+ let(:i18n) do
+ Class.new do
+ include Redmine::I18n
+
+ public :format_date, :format_time
+ end
+ end
+
+ it "renders the headers" do
+ expect(mail.subject).to include(meeting.project.name)
+ expect(mail.subject).to include(meeting.title)
+ expect(mail.to).to contain_exactly(watcher1.mail)
+ expect(mail.from).to eq([Setting.mail_from])
+ end
+
+ describe "text body" do
+ subject(:body) { mail.text_part.body }
+
+ it "renders the text body" do
+ expect(body).to include("has been updated")
+ expect(body).to include(meeting.title)
+ expect(body).to include(i18n.format_date(meeting.start_time))
+ expect(body).to include(i18n.format_time(meeting.start_time, include_date: false))
+ expect(body).to include(i18n.format_date(new_start))
+ expect(body).to include(i18n.format_time(new_start, include_date: false))
+ expect(body).to include("-")
+ expect(body).to include("Some new location")
+ end
+ end
+
+ describe "renders the html body" do
+ subject(:body) { mail.html_part.body }
+
+ it "renders the text body" do
+ expect(body).to include("has been updated")
+ expect(body).to include(meeting.title)
+ expect(body).to include(i18n.format_date(meeting.start_time))
+ expect(body).to include(i18n.format_time(meeting.start_time, include_date: false))
+ expect(body).to include(i18n.format_date(new_start))
+ expect(body).to include(i18n.format_time(new_start, include_date: false))
+ expect(body).to include("-")
+ expect(body).to include("Some new location")
+ end
+ end
+ end
+
describe "icalendar" do
let(:meeting) do
create(:meeting,
diff --git a/modules/meeting/spec/mailers/meeting_series_mailer_spec.rb b/modules/meeting/spec/mailers/meeting_series_mailer_spec.rb
index 2116ac5c633..d7bb6e21685 100644
--- a/modules/meeting/spec/mailers/meeting_series_mailer_spec.rb
+++ b/modules/meeting/spec/mailers/meeting_series_mailer_spec.rb
@@ -28,6 +28,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
+require "icalendar"
require_relative "../spec_helper"
RSpec.describe MeetingSeriesMailer do
@@ -87,9 +88,9 @@ RSpec.describe MeetingSeriesMailer do
end
end
- describe "rescheduled" do
- let(:changes) { { old_schedule: "some old schedule" } }
- let(:mail) { described_class.rescheduled(series, recipient, author, changes:) }
+ describe "updated" do
+ let(:changes) { { old_schedule: "some old schedule", old_location: "some old location" } }
+ let(:mail) { described_class.updated(series, recipient, author, changes:) }
it "renders the headers" do
expect(mail.subject).to include(series.project.name)
@@ -101,18 +102,22 @@ RSpec.describe MeetingSeriesMailer do
it "renders the text body" do
User.execute_as(recipient) do
check_series_mail_content(mail.text_part.body)
- expect(mail.text_part.body).to include("has changed the schedule")
+ expect(mail.text_part.body).to include("has been updated")
expect(mail.text_part.body).to include("some old schedule")
+ expect(mail.text_part.body).to include("some old location")
expect(mail.text_part.body).to include(series.full_schedule_in_words)
+ expect(mail.text_part.body).to include(series.location)
end
end
it "renders the html body" do
User.execute_as(recipient) do
check_series_mail_content(mail.html_part.body)
- expect(mail.html_part.body).to include("has changed the schedule")
+ expect(mail.html_part.body).to include("has been updated")
expect(mail.html_part.body).to include("some old schedule")
+ expect(mail.text_part.body).to include("some old location")
expect(mail.html_part.body).to include(series.full_schedule_in_words)
+ expect(mail.text_part.body).to include(series.location)
end
end
diff --git a/modules/meeting/spec/services/recurring_meetings/update_service_integration_spec.rb b/modules/meeting/spec/services/recurring_meetings/update_service_integration_spec.rb
index 9390fa6b5d6..b561bb7b948 100644
--- a/modules/meeting/spec/services/recurring_meetings/update_service_integration_spec.rb
+++ b/modules/meeting/spec/services/recurring_meetings/update_service_integration_spec.rb
@@ -164,12 +164,12 @@ RSpec.describe RecurringMeetings::UpdateService, "integration", type: :model do
series.template.participants << MeetingParticipant.new(user: recipient, invited: true)
end
- it "sends out rescheduled mails" do
+ it "sends out updated mails" do
expect(service_result).to be_success
perform_enqueued_jobs
expect(ActionMailer::Base.deliveries.count).to eq(1)
expect(ActionMailer::Base.deliveries.first.subject)
- .to eq "[#{project.name}] Meeting series '#{series.title}' rescheduled"
+ .to eq "[#{project.name}] Meeting series '#{series.title}' has been updated"
end
end
end