mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
improve receiver specs to account for posts approval
This commit is contained in:
parent
9bba68ed74
commit
e4980392da
5 changed files with 40 additions and 5 deletions
|
@ -2235,9 +2235,6 @@ en:
|
||||||
|
|
||||||
%{message}
|
%{message}
|
||||||
|
|
||||||
---
|
|
||||||
%{respond_instructions}
|
|
||||||
|
|
||||||
digest:
|
digest:
|
||||||
why: "A brief summary of %{site_link} since your last visit on %{last_seen_at}"
|
why: "A brief summary of %{site_link} since your last visit on %{last_seen_at}"
|
||||||
subject_template: "[%{site_name}] Digest"
|
subject_template: "[%{site_name}] Digest"
|
||||||
|
|
|
@ -375,7 +375,8 @@ module Email
|
||||||
options[:raw] << "</details>" << "\n"
|
options[:raw] << "</details>" << "\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
manager = NewPostManager.new(options[:user], options)
|
user = options.delete(:user)
|
||||||
|
manager = NewPostManager.new(user, options)
|
||||||
result = manager.perform
|
result = manager.perform
|
||||||
|
|
||||||
raise InvalidPost, result.errors.full_messages.join("\n") if result.errors.any?
|
raise InvalidPost, result.errors.full_messages.join("\n") if result.errors.any?
|
||||||
|
@ -383,7 +384,7 @@ module Email
|
||||||
if result.post
|
if result.post
|
||||||
@incoming_email.update_columns(topic_id: result.post.topic_id, post_id: result.post.id)
|
@incoming_email.update_columns(topic_id: result.post.topic_id, post_id: result.post.id)
|
||||||
if result.post.topic && result.post.topic.private_message?
|
if result.post.topic && result.post.topic.private_message?
|
||||||
add_other_addresses(result.post.topic, options[:user])
|
add_other_addresses(result.post.topic, user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -327,6 +327,21 @@ describe Email::Receiver do
|
||||||
expect { process(:new_user) }.to change(Topic, :count)
|
expect { process(:new_user) }.to change(Topic, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "works when approving is enabled" do
|
||||||
|
SiteSetting.approve_unless_trust_level = 4
|
||||||
|
|
||||||
|
Fabricate(:user, email: "tl3@bar.com", trust_level: TrustLevel[3])
|
||||||
|
Fabricate(:user, email: "tl4@bar.com", trust_level: TrustLevel[4])
|
||||||
|
|
||||||
|
category.set_permissions(Group[:trust_level_4] => :full)
|
||||||
|
category.save
|
||||||
|
|
||||||
|
Group.refresh_automatic_group!(:trust_level_4)
|
||||||
|
|
||||||
|
expect { process(:tl3_user) }.to_not change(Topic, :count)
|
||||||
|
expect { process(:tl4_user) }.to change(Topic, :count)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
11
spec/fixtures/emails/tl3_user.eml
vendored
Normal file
11
spec/fixtures/emails/tl3_user.eml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Return-Path: <tl3@bar.com>
|
||||||
|
From: Foo Bar <tl3@bar.com>
|
||||||
|
To: category@foo.com
|
||||||
|
Subject: This is a topic from a TL3 user
|
||||||
|
Date: Fri, 15 Jan 2016 00:12:43 +0100
|
||||||
|
Message-ID: <43@foo.bar.mail>
|
||||||
|
Mime-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: quoted-printable
|
||||||
|
|
||||||
|
Hey, this is a topic from a TL3 user :)
|
11
spec/fixtures/emails/tl4_user.eml
vendored
Normal file
11
spec/fixtures/emails/tl4_user.eml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Return-Path: <tl4@bar.com>
|
||||||
|
From: Foo Bar <tl4@bar.com>
|
||||||
|
To: category@foo.com
|
||||||
|
Subject: This is a topic from a TL4 user
|
||||||
|
Date: Fri, 15 Jan 2016 00:12:43 +0100
|
||||||
|
Message-ID: <44@foo.bar.mail>
|
||||||
|
Mime-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: quoted-printable
|
||||||
|
|
||||||
|
Hey, this is a topic from a TL4 user :)
|
Loading…
Reference in a new issue