mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
Add filtering support to flags
This commit is contained in:
@ -10,7 +10,7 @@ describe FlagQuery do
|
||||
admin = Fabricate(:admin)
|
||||
post = create_post(user: Discourse.system_user)
|
||||
PostAction.act(codinghorror, post, PostActionType.types[:spam])
|
||||
posts, topics, users = FlagQuery.flagged_posts_report(admin, "")
|
||||
posts, topics, users = FlagQuery.flagged_posts_report(admin)
|
||||
|
||||
expect(posts).to be_blank
|
||||
expect(topics).to be_blank
|
||||
@ -34,7 +34,7 @@ describe FlagQuery do
|
||||
PostAction.act(codinghorror, post2, PostActionType.types[:spam])
|
||||
PostAction.act(user2, post2, PostActionType.types[:spam])
|
||||
|
||||
posts, topics, users = FlagQuery.flagged_posts_report(admin, "")
|
||||
posts, topics, users = FlagQuery.flagged_posts_report(admin)
|
||||
|
||||
expect(posts.count).to eq(2)
|
||||
first = posts.first
|
||||
@ -50,9 +50,15 @@ describe FlagQuery do
|
||||
expect(second[:post_actions].first[:permalink]).to eq(mod_message.related_post.topic.relative_url)
|
||||
expect(second[:post_actions].first[:conversation][:response][:excerpt]).to match("<img src=")
|
||||
|
||||
posts, users = FlagQuery.flagged_posts_report(admin, "", 1)
|
||||
posts, users = FlagQuery.flagged_posts_report(admin, offset: 1)
|
||||
expect(posts.count).to eq(1)
|
||||
|
||||
# Try by topic
|
||||
posts = FlagQuery.flagged_posts_report(admin, topic_id: post.topic_id)
|
||||
expect(posts).to be_present
|
||||
posts = FlagQuery.flagged_posts_report(admin, topic_id: -1)
|
||||
expect(posts).to be_blank
|
||||
|
||||
# chuck post in category a mod can not see and make sure its missing
|
||||
category = Fabricate(:category)
|
||||
category.set_permissions(admins: :full)
|
||||
@ -60,9 +66,11 @@ describe FlagQuery do
|
||||
post2.topic.category_id = category.id
|
||||
post2.topic.save
|
||||
|
||||
posts, users = FlagQuery.flagged_posts_report(moderator, "")
|
||||
posts, users = FlagQuery.flagged_posts_report(moderator)
|
||||
|
||||
expect(posts.count).to eq(1)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user