mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 06:01:26 +08:00
FEATURE: Secondary emails support.
This commit is contained in:

committed by
Guo Xiang Tan

parent
50e59fb9bd
commit
21ebb1cd54
@ -169,6 +169,21 @@ describe Email::Receiver do
|
||||
expect { process(:from_reply_by_email_address) }.to raise_error(Email::Receiver::FromReplyByAddressError)
|
||||
end
|
||||
|
||||
it "accepts reply from secondary email address" do
|
||||
Fabricate(:secondary_email, email: "someone_else@bar.com", user: user)
|
||||
|
||||
expect { process(:reply_user_not_matching) }
|
||||
.to change { topic.posts.count }
|
||||
|
||||
post = Post.last
|
||||
|
||||
expect(post.raw).to eq(
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit."
|
||||
)
|
||||
|
||||
expect(post.user).to eq(user)
|
||||
end
|
||||
|
||||
it "raises a TopicNotFoundError when the topic was deleted" do
|
||||
topic.update_columns(deleted_at: 1.day.ago)
|
||||
expect { process(:reply_user_matching) }.to raise_error(Email::Receiver::TopicNotFoundError)
|
||||
@ -490,6 +505,27 @@ describe Email::Receiver do
|
||||
expect(topic.topic_users.count).to eq(3)
|
||||
end
|
||||
|
||||
it "invites users with a secondary email in the chain" do
|
||||
user1 = Fabricate(:user,
|
||||
trust_level: SiteSetting.email_in_min_trust,
|
||||
user_emails: [
|
||||
Fabricate.build(:secondary_email, email: "discourse@bar.com"),
|
||||
Fabricate.build(:secondary_email, email: "someone@else.com"),
|
||||
]
|
||||
)
|
||||
|
||||
user2 = Fabricate(:user,
|
||||
trust_level: SiteSetting.email_in_min_trust,
|
||||
user_emails: [
|
||||
Fabricate.build(:secondary_email, email: "team@bar.com"),
|
||||
Fabricate.build(:secondary_email, email: "wat@bar.com"),
|
||||
]
|
||||
)
|
||||
|
||||
expect { process(:cc) }.to change(Topic, :count)
|
||||
expect(Topic.last.allowed_users).to contain_exactly(user1, user2)
|
||||
end
|
||||
|
||||
it "cap the number of staged users created per email" do
|
||||
SiteSetting.maximum_staged_users_per_email = 1
|
||||
expect { process(:cc) }.to change(Topic, :count)
|
||||
@ -696,6 +732,24 @@ describe Email::Receiver do
|
||||
SiteSetting.ignore_by_title = "foo"
|
||||
expect { process(:ignored) }.to_not change(Topic, :count)
|
||||
end
|
||||
|
||||
it "associates email from a secondary address with user" do
|
||||
user = Fabricate(:user,
|
||||
trust_level: SiteSetting.email_in_min_trust,
|
||||
user_emails: [
|
||||
Fabricate.build(:secondary_email, email: "existing@bar.com")
|
||||
]
|
||||
)
|
||||
|
||||
expect { process(:existing_user) }.to change(Topic, :count).by(1)
|
||||
|
||||
topic = Topic.last
|
||||
|
||||
expect(topic.posts.last.raw)
|
||||
.to eq("Hey, this is a topic from an existing user ;)")
|
||||
|
||||
expect(topic.user).to eq(user)
|
||||
end
|
||||
end
|
||||
|
||||
context "new topic in a category that allows strangers" do
|
||||
|
Reference in New Issue
Block a user