mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 03:51:07 +08:00
DEV: Delete dead Topic#incoming_email_addresses code (#19970)
This code has been dead since b463a80cbfffa4aaa38e14cc674c4cd295468fd9, we can delete it now.
This commit is contained in:
@ -3271,85 +3271,6 @@ RSpec.describe Topic do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#incoming_email_addresses" do
|
||||
fab!(:group) do
|
||||
Fabricate(
|
||||
:group,
|
||||
smtp_server: "imap.gmail.com",
|
||||
smtp_port: 587,
|
||||
email_username: "discourse@example.com",
|
||||
email_password: "discourse@example.com",
|
||||
)
|
||||
end
|
||||
|
||||
fab!(:topic) do
|
||||
Fabricate(
|
||||
:private_message_topic,
|
||||
topic_allowed_groups: [Fabricate.build(:topic_allowed_group, group: group)],
|
||||
)
|
||||
end
|
||||
|
||||
let!(:incoming1) do
|
||||
Fabricate(
|
||||
:incoming_email,
|
||||
to_addresses: "discourse@example.com",
|
||||
from_address: "johnsmith@user.com",
|
||||
topic: topic,
|
||||
post: topic.posts.first,
|
||||
created_at: 20.minutes.ago,
|
||||
)
|
||||
end
|
||||
let!(:incoming2) do
|
||||
Fabricate(
|
||||
:incoming_email,
|
||||
from_address: "discourse@example.com",
|
||||
to_addresses: "johnsmith@user.com",
|
||||
topic: topic,
|
||||
post: Fabricate(:post, topic: topic),
|
||||
created_at: 10.minutes.ago,
|
||||
)
|
||||
end
|
||||
let!(:incoming3) do
|
||||
Fabricate(
|
||||
:incoming_email,
|
||||
to_addresses: "discourse@example.com",
|
||||
from_address: "johnsmith@user.com",
|
||||
topic: topic,
|
||||
post: topic.posts.first,
|
||||
cc_addresses: "otherguy@user.com",
|
||||
created_at: 2.minutes.ago,
|
||||
)
|
||||
end
|
||||
let!(:incoming4) do
|
||||
Fabricate(
|
||||
:incoming_email,
|
||||
to_addresses: "unrelated@test.com",
|
||||
from_address: "discourse@example.com",
|
||||
topic: topic,
|
||||
post: topic.posts.first,
|
||||
created_at: 1.minutes.ago,
|
||||
)
|
||||
end
|
||||
|
||||
it "returns an array of all the incoming email addresses" do
|
||||
expect(topic.incoming_email_addresses).to match_array(
|
||||
%w[discourse@example.com johnsmith@user.com otherguy@user.com unrelated@test.com],
|
||||
)
|
||||
end
|
||||
|
||||
it "returns an array of all the incoming email addresses where incoming was received before X" do
|
||||
expect(topic.incoming_email_addresses(received_before: 5.minutes.ago)).to match_array(
|
||||
%w[discourse@example.com johnsmith@user.com],
|
||||
)
|
||||
end
|
||||
|
||||
context "when the group is present" do
|
||||
it "excludes incoming emails that are not to or CCd to the group" do
|
||||
expect(topic.incoming_email_addresses(group: group)).not_to include("unrelated@test.com")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#cannot_permanently_delete_reason" do
|
||||
fab!(:post) { Fabricate(:post) }
|
||||
let!(:topic) { post.topic }
|
||||
|
Reference in New Issue
Block a user