From f0bb4380bba6b9625f51d35bc6f788ca52b303f7 Mon Sep 17 00:00:00 2001 From: Caleb Guanzon Date: Mon, 10 Apr 2023 09:45:52 -0600 Subject: [PATCH] account for group announcements in new message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit flag=none fixes VICE-3412 test plan: - specs pass OR - create a new group announcement - as an admin visit /users/:id_of_someone_in_group/messages - go to html tab of the new announcement messae - verify the messaging at the bottom says Group instead of Course Change-Id: Ibb80ddc2097291b0e8aee5b0c1adf5ce64d3c67c Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/315513 Tested-by: Service Cloud Jenkins Reviewed-by: Omar Soto-Fortuño Product-Review: Omar Soto-Fortuño QA-Review: Jason Gillett --- app/messages/new_announcement.email.html.erb | 6 +++++- spec/messages/new_announcement.erb_spec.rb | 22 +++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/messages/new_announcement.email.html.erb b/app/messages/new_announcement.email.html.erb index 36c13840164..9f94942f400 100644 --- a/app/messages/new_announcement.email.html.erb +++ b/app/messages/new_announcement.email.html.erb @@ -31,5 +31,9 @@ <% end %> <% if !asset.locked? %> - <%= t :announcement_info, "Replies to this email will be posted as a reply to the announcement, which will be seen by everyone in the course." %> + <% if asset.context.is_a? Course %> + <%= t :announcement_info_course, "Replies to this email will be posted as a reply to the announcement, which will be seen by everyone in the course." %> + <% else %> + <%= t :announcement_info_group, "Replies to this email will be posted as a reply to the announcement, which will be seen by everyone in the group." %> + <% end%> <% end %> \ No newline at end of file diff --git a/spec/messages/new_announcement.erb_spec.rb b/spec/messages/new_announcement.erb_spec.rb index 2e6be20d353..ff8a23c92d6 100644 --- a/spec/messages/new_announcement.erb_spec.rb +++ b/spec/messages/new_announcement.erb_spec.rb @@ -33,12 +33,12 @@ describe "new_announcement" do context ".email" do let(:path_type) { :email } - it "renders" do + it "renders for course" do generate_message(notification_name, path_type, asset) expect(@message.subject).to eq "value for title: value for name" expect(@message.url).to match(%r{/courses/\d+/announcements/\d+}) expect(@message.body).to match(%r{/courses/\d+/announcements/\d+}) - expect(@message.html_body).to include "Replies to this email will be posted as a reply to the announcement," + expect(@message.html_body).to include "Replies to this email will be posted as a reply to the announcement, which will be seen by everyone in the course." end it "does not show announcement reply helper if announcement is locked" do @@ -49,7 +49,23 @@ describe "new_announcement" do expect(@message.subject).to eq "value for title: value for name" expect(@message.url).to match(%r{/courses/\d+/announcements/\d+}) expect(@message.body).to match(%r{/courses/\d+/announcements/\d+}) - expect(@message.html_body).not_to include "Replies to this email will be posted as a reply to the announcement," + expect(@message.html_body).not_to include "Replies to this email will be posted as a reply to the announcement, which will be seen by everyone in the course." + end + + it "renders for group" do + @course.group_categories.create!(name: "My Group Category") + teacher_in_course + group = @course.groups.create!(name: "My Group", group_category: @course.group_categories.first) + group_announcement = group.announcements.create!( + title: "Group Announcement", + message: "Group", + user: @teacher + ) + generate_message(notification_name, path_type, group_announcement) + expect(@message.subject).to eq "Group Announcement: My Group" + expect(@message.url).to match(%r{/groups/\d+/announcements/\d+}) + expect(@message.body).to match(%r{/groups/\d+/announcements/\d+}) + expect(@message.html_body).to include "Replies to this email will be posted as a reply to the announcement, which will be seen by everyone in the group." end end