mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
DEV: Add test for post notices. (#7352)
This commit is contained in:
parent
689c7f5410
commit
47c50d9a95
@ -371,7 +371,7 @@ class PostSerializer < BasicPostSerializer
|
||||
|
||||
def include_post_notice_type?
|
||||
return false if !scope.user || !scope.user.id || scope.user.id == object.user_id ||
|
||||
!object.user || object.user.anonymous? || object.user.bot? ||
|
||||
!object.user || object.user.anonymous? || object.user.bot? || object.user.staged ||
|
||||
!scope.user.has_trust_level?(SiteSetting.min_post_notice_tl)
|
||||
|
||||
post_notice_type.present?
|
||||
|
@ -191,7 +191,7 @@ describe PostSerializer do
|
||||
PostSerializer.new(post, scope: Guardian.new(user), root: false).as_json
|
||||
end
|
||||
|
||||
it "will not show for poster and TL2+ users" do
|
||||
it "is visible for TL2+ users (except poster)" do
|
||||
expect(json_for_user(nil)[:post_notice_type]).to eq(nil)
|
||||
expect(json_for_user(user)[:post_notice_type]).to eq(nil)
|
||||
|
||||
@ -203,6 +203,22 @@ describe PostSerializer do
|
||||
expect(json_for_user(user_tl1)[:post_notice_type]).to eq("returning")
|
||||
expect(json_for_user(user_tl2)[:post_notice_type]).to eq("returning")
|
||||
end
|
||||
|
||||
it "is visible when created by anonymous, bots and staged users" do
|
||||
expect(json_for_user(user_tl2)[:post_notice_type]).to eq("returning")
|
||||
|
||||
post.user = nil
|
||||
expect(json_for_user(user_tl2)[:post_notice_type]).to eq(nil)
|
||||
|
||||
post.user = AnonymousShadowCreator.get(user)
|
||||
expect(json_for_user(user_tl2)[:post_notice_type]).to eq(nil)
|
||||
|
||||
post.user = Discourse.system_user
|
||||
expect(json_for_user(user_tl2)[:post_notice_type]).to eq(nil)
|
||||
|
||||
post.user = Fabricate(:staged)
|
||||
expect(json_for_user(user_tl2)[:post_notice_type]).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user