FIX: subfolder digest emails have incorrect URLs
This commit is contained in:
parent
17d8fea796
commit
4e6e4a83df
|
@ -420,7 +420,7 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
|
|||
<%=raw(t 'user_notifications.digest.unsubscribe',
|
||||
site_link: html_site_link(@anchor_color),
|
||||
email_preferences_link: link_to(t('user_notifications.digest.your_email_settings'), Discourse.base_url + '/my/preferences/emails'),
|
||||
unsubscribe_link: link_to(t('user_notifications.digest.click_here'), email_unsubscribe_url(host: Discourse.base_url, key: @unsubscribe_key), {:style=>"color: ##{@anchor_color}"})) %>
|
||||
unsubscribe_link: link_to(t('user_notifications.digest.click_here'), "#{Discourse.base_url}/email/unsubscribe/#{@unsubscribe_key}", {:style=>"color: ##{@anchor_color}"})) %>
|
||||
</div>
|
||||
|
||||
<%= digest_custom_html("below_footer") %>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
### <%=t 'user_notifications.digest.popular_topics' %>
|
||||
|
||||
<%- @popular_topics.each_with_index do |t,i| %>
|
||||
<%= raw(@markdown_linker.create(t.title, t.relative_url)) %>
|
||||
<%= raw(@markdown_linker.create(t.title, t.url)) %>
|
||||
|
||||
<%- if t.best_post.present? %>
|
||||
<%= raw(t.best_post.excerpt(1000, strip_links: true, text_entities: true, markdown_images: true)) %>
|
||||
|
@ -29,7 +29,7 @@
|
|||
### <%=t 'user_notifications.digest.popular_posts' %>
|
||||
|
||||
<%- @popular_posts.each_with_index do |post,i| %>
|
||||
<%= post.user.username -%> - <%= raw(@markdown_linker.create(post.topic.title, post.topic.relative_url)) %>
|
||||
<%= post.user.username -%> - <%= raw(@markdown_linker.create(post.topic.title, post.topic.url)) %>
|
||||
|
||||
<%= raw(post.excerpt(1000, strip_links: true, text_entities: true, markdown_images: true)) %>
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -41,7 +41,7 @@
|
|||
**<%=t 'user_notifications.digest.more_new' %>**
|
||||
|
||||
<%- @other_new_for_you.each do |t| %>
|
||||
* <%= raw(@markdown_linker.create(t.title, t.relative_url)) %> - <%= t.posts_count %> - <%- if t.category %>[<%= t.category.name %>]<%- end %>
|
||||
* <%= raw(@markdown_linker.create(t.title, t.url)) %> - <%= t.posts_count %> - <%- if t.category %>[<%= t.category.name %>]<%- end %>
|
||||
<%- end -%>
|
||||
<%- end %>
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
|||
<%=raw(t :'user_notifications.digest.unsubscribe',
|
||||
site_link: site_link,
|
||||
email_preferences_link: raw(@markdown_linker.create(t('user_notifications.digest.your_email_settings'), '/my/preferences/emails')),
|
||||
unsubscribe_link: raw(@markdown_linker.create(t('user_notifications.digest.click_here'), email_unsubscribe_url(key: @unsubscribe_key, only_path: true)))) %>
|
||||
unsubscribe_link: raw(@markdown_linker.create(t('user_notifications.digest.click_here'), "/email/unsubscribe/#{@unsubscribe_key}"))) %>
|
||||
|
||||
<%= raw(@markdown_linker.references) %>
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ class MarkdownLinker
|
|||
end
|
||||
|
||||
def create(title, url)
|
||||
@markdown_links[@index] = "#{@base_url}#{url}"
|
||||
@markdown_links[@index] = url.start_with?(@base_url) ? url : "#{@base_url}#{url}"
|
||||
result = "[#{title}][#{@index}]"
|
||||
@index += 1
|
||||
result
|
||||
|
|
|
@ -127,9 +127,7 @@ describe UserNotifications do
|
|||
|
||||
context "with new topics" do
|
||||
|
||||
before do
|
||||
Fabricate(:topic, user: Fabricate(:coding_horror), created_at: 1.hour.ago)
|
||||
end
|
||||
let!(:popular_topic) { Fabricate(:topic, user: Fabricate(:coding_horror), created_at: 1.hour.ago) }
|
||||
|
||||
it "works" do
|
||||
expect(subject.to).to eq([user.email])
|
||||
|
@ -206,6 +204,22 @@ describe UserNotifications do
|
|||
expect(html).to include '1E1E1E'
|
||||
expect(html).to include '858585'
|
||||
end
|
||||
|
||||
it "supports subfolder" do
|
||||
GlobalSetting.stubs(:relative_url_root).returns('/forum')
|
||||
Discourse.stubs(:base_uri).returns("/forum")
|
||||
html = subject.html_part.body.to_s
|
||||
text = subject.text_part.body.to_s
|
||||
expect(html).to be_present
|
||||
expect(text).to be_present
|
||||
expect(html).to_not include("/forum/forum")
|
||||
expect(text).to_not include("/forum/forum")
|
||||
expect(subject.header["List-Unsubscribe"].to_s).to match(/http:\/\/test.localhost\/forum\/email\/unsubscribe\/\h{64}/)
|
||||
|
||||
topic_url = "http://test.localhost/forum/t/#{popular_topic.slug}/#{popular_topic.id}"
|
||||
expect(html).to include(topic_url)
|
||||
expect(text).to include(topic_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue