Merge pull request #9818 from opf/fix/34901/meeting-time-as-date

[34901] Use format_time_as_date to get the locale formatted date
pull/9840/head
Oliver Günther 3 years ago committed by GitHub
commit 5f1160c878
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      modules/meeting/app/views/meeting_mailer/content_for_review.html.erb
  2. 2
      modules/meeting/app/views/meeting_mailer/content_for_review.text.erb
  3. 2
      modules/meeting/app/views/meeting_mailer/icalendar_notification.html.erb
  4. 2
      modules/meeting/app/views/meeting_mailer/icalendar_notification.text.erb
  5. 66
      modules/meeting/spec/mailers/meeting_mailer_spec.rb

@ -31,7 +31,7 @@ See COPYRIGHT and LICENSE files for more details.
<em><%= @meeting.author %></em>
<ul>
<li><%=t :label_meeting_date_time %>: <%= format_date @meeting.start_time %> <%= format_time @meeting.start_time, false %>-<%= format_time @meeting.end_time, false %> <%= Time.zone %></li>
<li><%=t :label_meeting_date_time %>: <%= format_time_as_date @meeting.start_time %> <%= format_time @meeting.start_time, false %>-<%= format_time @meeting.end_time, false %> <%= Time.zone %></li>
<li><%=Meeting.human_attribute_name(:location) %>: <%= @meeting.location %></li>
<li><%=Meeting.human_attribute_name(:participants_invited) %>: <%= @meeting.participants.invited.sort.join("; ") %></li>
<li><%=Meeting.human_attribute_name(:participants_attended) %>: <%= @meeting.participants.attended.sort.join("; ") %></li>

@ -30,7 +30,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= @meeting.project.name %>: <%= @meeting.title %> (<%= meeting_url(@meeting) %>)
<%= @meeting.author %>
<%=t :label_meeting_date_time %>: <%= format_date @meeting.start_time %> <%= format_time @meeting.start_time, false %>-<%= format_time @meeting.end_time, false %> <%= Time.zone %>
<%=t :label_meeting_date_time %>: <%= format_time_as_date @meeting.start_time %> <%= format_time @meeting.start_time, false %>-<%= format_time @meeting.end_time, false %> <%= Time.zone %>
<%= Meeting.human_attribute_name(:location) %>: <%= @meeting.location %>
<%= Meeting.human_attribute_name(:participants_invited) %>: <%= @meeting.participants.invited.sort.join("; ") %>
<%= Meeting.human_attribute_name(:participants_attended) %>: <%= @meeting.participants.attended.sort.join("; ") %>

@ -4,7 +4,7 @@
<p><%= t(:text_notificiation_invited) %></p>
<ul>
<li><%=t :label_meeting_date_time %>: <%= format_date @meeting.start_time %> <%= format_time @meeting.start_time, false %>-<%= format_time @meeting.end_time, false %> <%= Time.zone %></li>
<li><%=t :label_meeting_date_time %>: <%= format_time_as_date @meeting.start_time %> <%= format_time @meeting.start_time, false %>-<%= format_time @meeting.end_time, false %> <%= Time.zone %></li>
<li><%=Meeting.human_attribute_name(:location) %>: <%= @meeting.location %></li>
<li><%=Meeting.human_attribute_name(:participants_invited) %>: <%= @meeting.participants.invited.sort.join("; ") %></li>
<li><%=Meeting.human_attribute_name(:participants_attended) %>: <%= @meeting.participants.attended.sort.join("; ") %></li>

@ -3,7 +3,7 @@
<%= t(:text_notificiation_invited) %>
<%=t :label_meeting_date_time %>: <%= format_date @meeting.start_time %> <%= format_time @meeting.start_time, false %>-<%= format_time @meeting.end_time, false %> <%= Time.zone %>
<%=t :label_meeting_date_time %>: <%= format_time_as_date @meeting.start_time %> <%= format_time @meeting.start_time, false %>-<%= format_time @meeting.end_time, false %> <%= Time.zone %>
<%=Meeting.human_attribute_name(:location) %>: <%= @meeting.location %>
<%=Meeting.human_attribute_name(:participants_invited) %>: <%= @meeting.participants.invited.sort.join("; ") %>
<%=Meeting.human_attribute_name(:participants_attended) %>: <%= @meeting.participants.attended.sort.join("; ") %>

@ -95,6 +95,38 @@ describe MeetingMailer, type: :mailer do
expect(mail.to).to match_array([watcher1.mail])
end
end
context 'when the meeting time results in another date' do
let(:meeting) do
FactoryBot.create :meeting,
author: author,
project: project,
start_time: '2021-11-09T23:00:00 +0100'.to_datetime.utc
end
describe 'it renders november 9th for Berlin zone' do
let(:mail) { described_class.content_for_review meeting_agenda, 'meeting_agenda', author }
it 'renders the mail with the correct locale' do
expect(mail.html_part.body).to include('11/09/2021 11:00 PM-12:00 AM (GMT+01:00) Europe/Berlin')
expect(mail.text_part.body).to include('11/09/2021 11:00 PM-12:00 AM (GMT+01:00) Europe/Berlin')
expect(mail.to).to match_array([author.mail])
end
end
describe 'it renders november 10th for Tokyo zone' do
let(:mail) { described_class.content_for_review meeting_agenda, 'meeting_agenda', watcher1 }
let!(:preference) { FactoryBot.create(:user_preference, user: watcher1, time_zone: 'Asia/Tokyo') }
it 'renders the mail with the correct locale' do
expect(mail.text_part.body).to include('11/10/2021 07:00 AM-08:00 AM (GMT+09:00) Asia/Tokyo')
expect(mail.html_part.body).to include('11/10/2021 07:00 AM-08:00 AM (GMT+09:00) Asia/Tokyo')
expect(mail.to).to match_array([watcher1.mail])
end
end
end
end
describe 'icalendar' do
@ -159,7 +191,7 @@ describe MeetingMailer, type: :mailer do
let!(:preference) { FactoryBot.create(:user_preference, user: watcher1, time_zone: 'Asia/Tokyo') }
let(:mail) { described_class.content_for_review meeting_agenda, 'meeting_agenda', watcher1 }
it 'renders the mail with the correcet locale' do
it 'renders the mail with the correct locale' do
expect(mail.text_part.body).to include('01/19/2021 07:00 PM-08:00 PM (GMT+09:00) Asia/Tokyo')
expect(mail.text_part.body).to include("#{author.name} has put the")
expect(mail.html_part.body).to include('01/19/2021 07:00 PM-08:00 PM (GMT+09:00) Asia/Tokyo')
@ -168,6 +200,38 @@ describe MeetingMailer, type: :mailer do
expect(mail.to).to match_array([watcher1.mail])
end
end
context 'when the meeting time results in another date' do
let(:meeting) do
FactoryBot.create :meeting,
author: author,
project: project,
start_time: '2021-11-09T23:00:00 +0100'.to_datetime.utc
end
describe 'it renders november 9th for Berlin zone' do
let(:mail) { described_class.icalendar_notification meeting_agenda, 'meeting_agenda', author }
it 'renders the mail with the correct locale' do
expect(mail.text_part.body).to include('11/09/2021 11:00 PM-12:00 AM (GMT+01:00) Europe/Berlin')
expect(mail.html_part.body).to include('11/09/2021 11:00 PM-12:00 AM (GMT+01:00) Europe/Berlin')
expect(mail.to).to match_array([author.mail])
end
end
describe 'it renders november 10th for Tokyo zone' do
let(:mail) { described_class.icalendar_notification meeting_agenda, 'meeting_agenda', watcher1 }
let!(:preference) { FactoryBot.create(:user_preference, user: watcher1, time_zone: 'Asia/Tokyo') }
it 'renders the mail with the correct locale' do
expect(mail.text_part.body).to include('11/10/2021 07:00 AM-08:00 AM (GMT+09:00) Asia/Tokyo')
expect(mail.html_part.body).to include('11/10/2021 07:00 AM-08:00 AM (GMT+09:00) Asia/Tokyo')
expect(mail.to).to match_array([watcher1.mail])
end
end
end
end
def check_meeting_mail_content(body)

Loading…
Cancel
Save