From c1cf1df7a93afa78e47a45701f3dd818dd6d8d7a Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Thu, 2 Apr 2020 21:58:59 -0400 Subject: [PATCH] [deploy] Fix up connect group issues (#7051) * Fix up connect group issues * Fix spec * Fix spec --- app/mailers/notify_mailer.rb | 4 ++-- app/models/chat_channel.rb | 3 ++- .../notify_mailer/channel_invite_email.html.erb | 12 +++++++++--- spec/mailers/notify_mailer_spec.rb | 4 ++-- spec/mailers/previews/notify_mailer_preview.rb | 6 ++++++ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/mailers/notify_mailer.rb b/app/mailers/notify_mailer.rb index ba6940951..4ec716140 100644 --- a/app/mailers/notify_mailer.rb +++ b/app/mailers/notify_mailer.rb @@ -85,9 +85,9 @@ class NotifyMailer < ApplicationMailer @membership = membership @inviter = inviter subject = if @membership.role == "mod" - "You are invited to Channel #{@membership.chat_channel.channel_name} as moderator." + "You are invited to the #{@membership.chat_channel.channel_name} channel as moderator." else - "You are invited to Channel #{@membership.chat_channel.channel_name} by #{@inviter.name}." + "You are invited to the #{@membership.chat_channel.channel_name} channel." end mail(to: @membership.user.email, subject: subject) end diff --git a/app/models/chat_channel.rb b/app/models/chat_channel.rb index a8391b19f..97770148e 100644 --- a/app/models/chat_channel.rb +++ b/app/models/chat_channel.rb @@ -78,7 +78,7 @@ class ChatChannel < ApplicationRecord channel.status = "active" channel.save else - create( + channel = create( channel_type: channel_type, channel_name: contrived_name, slug: slug, @@ -86,6 +86,7 @@ class ChatChannel < ApplicationRecord status: "active", ) end + channel end end diff --git a/app/views/mailers/notify_mailer/channel_invite_email.html.erb b/app/views/mailers/notify_mailer/channel_invite_email.html.erb index d9f0785f4..702ce48e9 100644 --- a/app/views/mailers/notify_mailer/channel_invite_email.html.erb +++ b/app/views/mailers/notify_mailer/channel_invite_email.html.erb @@ -4,11 +4,15 @@ <% if @membership.role == "mod" %>

- You have been invited to be a Moderator of a connect group on <%= ApplicationConfig["COMMUNITY_NAME"] %>. + You have been invited to be a Moderator of a Connect group on <%= ApplicationConfig["COMMUNITY_NAME"] %>. +

+ <% elsif @inviter %> +

+ <%= link_to(@inviter.name, ApplicationController.helpers.user_url(@inviter)) %> sent you an invitation to join a Connect group on <%= ApplicationConfig["COMMUNITY_NAME"] %>.

<% else %>

- <%= link_to(@inviter.name, ApplicationController.helpers.user_url(@inviter)) %> sent you an invitation to join a connect group on <%= ApplicationConfig["COMMUNITY_NAME"] %>. + You have been invited to a Connect group on <%= ApplicationConfig["COMMUNITY_NAME"] %>.

<% end %> @@ -32,7 +36,9 @@

-

<%= link_to("Check Invitation", ApplicationController.helpers.app_url("connect?ref=group_invite")) %>

+

+ <%= link_to("Check Invitation", ApplicationController.helpers.app_url("connect?ref=group_invite"), style: "color: white;font-size:1.4em;font-weight: bold;text-decoration: none;padding: 15px 0px; display: block;") %> +

diff --git a/spec/mailers/notify_mailer_spec.rb b/spec/mailers/notify_mailer_spec.rb index 9515319b7..324a22f3c 100644 --- a/spec/mailers/notify_mailer_spec.rb +++ b/spec/mailers/notify_mailer_spec.rb @@ -489,8 +489,8 @@ RSpec.describe NotifyMailer, type: :mailer do let(:member_email) { described_class.channel_invite_email(regular_membership, user) } it "renders proper subject" do - expect(moderator_email.subject).to eq("You are invited to Channel #{moderator_membership.chat_channel.channel_name} as moderator.") - expect(member_email.subject).to eq("You are invited to Channel #{regular_membership.chat_channel.channel_name} by #{user.name}.") + expect(moderator_email.subject).to eq("You are invited to the #{moderator_membership.chat_channel.channel_name} channel as moderator.") + expect(member_email.subject).to eq("You are invited to the #{regular_membership.chat_channel.channel_name} channel.") end it "renders proper sender" do diff --git a/spec/mailers/previews/notify_mailer_preview.rb b/spec/mailers/previews/notify_mailer_preview.rb index 69d543dc2..859ee6e75 100644 --- a/spec/mailers/previews/notify_mailer_preview.rb +++ b/spec/mailers/previews/notify_mailer_preview.rb @@ -32,6 +32,12 @@ class NotifyMailerPreview < ActionMailer::Preview NotifyMailer.new_badge_email(badge_achievement) end + def channel_invite_email + user = User.first + membership = ChatChannelMembership.last + NotifyMailer.channel_invite_email(membership, user) + end + def tag_moderator_confirmation_email NotifyMailer.tag_moderator_confirmation_email(User.first, "discuss") end