Add filtering support to flags

This commit is contained in:
Robin Ward
2017-09-08 16:47:49 -04:00
parent be0eb0a554
commit 5e69217793
7 changed files with 77 additions and 28 deletions

View File

@ -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