REFACTOR: Add `full_url` to `Group`
Lets stop writing the same code over and over again.
This commit is contained in:
parent
b3cda195b8
commit
b7230d14a3
|
@ -77,7 +77,7 @@ class GroupSmtpMailer < ActionMailer::Base
|
||||||
list = []
|
list = []
|
||||||
|
|
||||||
post.topic.allowed_groups.each do |g|
|
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})")
|
||||||
end
|
end
|
||||||
|
|
||||||
post.topic.allowed_users.each do |u|
|
post.topic.allowed_users.each do |u|
|
||||||
|
|
|
@ -556,7 +556,7 @@ class UserNotifications < ActionMailer::Base
|
||||||
participant_list = []
|
participant_list = []
|
||||||
|
|
||||||
post.topic.allowed_groups.each do |g|
|
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})"
|
||||||
end
|
end
|
||||||
|
|
||||||
post.topic.allowed_users.each do |u|
|
post.topic.allowed_users.each do |u|
|
||||||
|
|
|
@ -936,6 +936,10 @@ class Group < ActiveRecord::Base
|
||||||
TopicAllowedGroup.where(group_id: self.id).joins(:topic).count
|
TopicAllowedGroup.where(group_id: self.id).joins(:topic).count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def full_url
|
||||||
|
"#{Discourse.base_url}/g/#{UrlHelper.encode_component(self.name)}"
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def name_format_validator
|
def name_format_validator
|
||||||
|
|
|
@ -606,7 +606,7 @@ describe UserNotifications do
|
||||||
notification_data_hash: notification.data_hash
|
notification_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)")
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when SiteSetting.group_name_in_subject is true" do
|
context "when SiteSetting.group_name_in_subject is true" do
|
||||||
|
|
Loading…
Reference in New Issue