Remove daily mailing mode option as it doesn't scale.

https://meta.discourse.org/t/daily-updates-option-for-mailing-list-mode/45029/14?u=tgxworld
This commit is contained in:
Guo Xiang Tan
2017-05-05 12:11:20 +08:00
parent 441e0059af
commit 71a266b673
14 changed files with 17 additions and 425 deletions

View File

@@ -79,94 +79,6 @@ describe UserNotifications do
end
describe '.mailing_list' do
subject { UserNotifications.mailing_list(user) }
context "without new posts" do
it "doesn't send the email" do
expect(subject.to).to be_blank
end
end
context "with new posts" do
let(:user) { Fabricate(:user) }
let(:topic) { Fabricate(:topic, user: user) }
let!(:new_post) { Fabricate(:post, topic: topic, created_at: 2.hours.ago, raw: "Feel the Bern") }
let!(:old_post) { Fabricate(:post, topic: topic, created_at: 25.hours.ago, raw: "Make America Great Again") }
let(:old_topic) { Fabricate(:topic, user: user, created_at: 10.days.ago) }
let(:new_post_in_old_topic) { Fabricate(:post, topic: old_topic, created_at: 2.hours.ago, raw: "Yes We Can") }
let(:stale_post) { Fabricate(:post, topic: old_topic, created_at: 2.days.ago, raw: "A New American Century") }
it "works" do
expect(subject.to).to eq([user.email])
expect(subject.subject).to be_present
expect(subject.from).to eq([SiteSetting.notification_email])
expect(subject.html_part.body.to_s).to include topic.title
expect(subject.text_part.body.to_s).to be_present
expect(subject.header["List-Unsubscribe"].to_s).to match(/\/email\/unsubscribe\/\h{64}/)
end
it "includes posts less than 24 hours old" do
expect(subject.html_part.body.to_s).to include new_post.cooked
end
it "does not include posts older than 24 hours old" do
expect(subject.html_part.body.to_s).to_not include old_post.cooked
end
it "includes topics created over 24 hours ago which have new posts" do
new_post_in_old_topic
expect(subject.html_part.body.to_s).to include old_topic.title
expect(subject.html_part.body.to_s).to include new_post_in_old_topic.cooked
expect(subject.html_part.body.to_s).to_not include stale_post.cooked
end
it "includes multiple topics" do
new_post_in_old_topic
expect(subject.html_part.body.to_s).to include topic.title
expect(subject.html_part.body.to_s).to include old_topic.title
end
it "does not include topics not updated for the past 24 hours" do
stale_post
expect(subject.html_part.body.to_s).to_not include old_topic.title
expect(subject.html_part.body.to_s).to_not include stale_post.cooked
end
it "includes email_prefix in email subject instead of site title" do
SiteSetting.email_prefix = "Try Discourse"
SiteSetting.title = "Discourse Meta"
expect(subject.subject).to match(/Try Discourse/)
expect(subject.subject).not_to match(/Discourse Meta/)
end
it "excludes whispers" do
new_post_in_old_topic
whisper = Fabricate(:post, topic: old_topic, created_at: 1.hour.ago, raw: "This is secret", post_type: Post.types[:whisper])
expect(subject.html_part.body.to_s).to include old_topic.title
expect(subject.html_part.body.to_s).to_not include whisper.cooked
end
it "includes whispers for staff" do
user.admin = true; user.save!
new_post_in_old_topic
whisper = Fabricate(:post, topic: old_topic, created_at: 1.hour.ago, raw: "This is secret", post_type: Post.types[:whisper])
expect(subject.html_part.body.to_s).to include old_topic.title
expect(subject.html_part.body.to_s).to include whisper.cooked
end
it "hides details for private email" do
SiteSetting.private_email = true
expect(subject.html_part.body.to_s).not_to include(topic.title)
expect(subject.html_part.body.to_s).not_to include(topic.slug)
expect(subject.text_part.body.to_s).not_to include(topic.title)
expect(subject.text_part.body.to_s).not_to include(topic.slug)
end
end
end
describe '.digest' do
subject { UserNotifications.digest(user) }