A platform for community discussion. Free, open, simple.
REFACTOR: Add `full_url` to `Group`
Gerhard Schlagerb7230d14a357
diff --git a/app/mailers/group_smtp_mailer.rb b/app/mailers/group_smtp_mailer.rbindex 367297d4a5a..15e20959e10 100644--- a/app/mailers/group_smtp_mailer.rb+++ b/app/mailers/group_smtp_mailer.rb@@ -77,7 +77,7 @@ class GroupSmtpMailer < ActionMailer::Baselist = []post.topic.allowed_groups.each do |g|- list.push("[#{g.name_full_preferred}](#{Discourse.base_url}/groups/#{g.name})")+ list.push("[#{g.name_full_preferred}](#{g.full_url})")endpost.topic.allowed_users.each do |u|diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rbindex 892f407b987..8ca231a5f30 100644--- a/app/mailers/user_notifications.rb+++ b/app/mailers/user_notifications.rb@@ -556,7 +556,7 @@ class UserNotifications < ActionMailer::Baseparticipant_list = []post.topic.allowed_groups.each do |g|- participant_list.push "[#{g.name} (#{g.users.count})](#{Discourse.base_url}/groups/#{g.name})"+ participant_list.push "[#{g.name} (#{g.users.count})](#{g.full_url})"endpost.topic.allowed_users.each do |u|diff --git a/app/models/group.rb b/app/models/group.rbindex 72eae6ab167..d0a401a8d6e 100644--- a/app/models/group.rb+++ b/app/models/group.rb@@ -936,6 +936,10 @@ class Group < ActiveRecord::BaseTopicAllowedGroup.where(group_id: self.id).joins(:topic).countend+ def full_url+ "#{Discourse.base_url}/g/#{UrlHelper.encode_component(self.name)}"+ end+protecteddef name_format_validatordiff --git a/spec/mailers/user_notifications_spec.rb b/spec/mailers/user_notifications_spec.rbindex 25ade90edbf..0f1518cd7a2 100644--- a/spec/mailers/user_notifications_spec.rb+++ b/spec/mailers/user_notifications_spec.rb@@ -606,7 +606,7 @@ describe UserNotifications donotification_data_hash: notification.data_hash)- expect(mail.body).to include("[group1 (2)](http://test.localhost/groups/group1), [group2 (1)](http://test.localhost/groups/group2), [one](http://test.localhost/u/one), [two](http://test.localhost/u/two)")+ expect(mail.body).to include("[group1 (2)](http://test.localhost/g/group1), [group2 (1)](http://test.localhost/g/group2), [one](http://test.localhost/u/one), [two](http://test.localhost/u/two)")endcontext "when SiteSetting.group_name_in_subject is true" do