DEV: Add a test for api scope routes (#22597)

Follow up to: 56e792d

Adds a test to check that there is an api scope for the t/external_id
route. Plus checks many other topic routes that should have scopes.
This commit is contained in:
Blake Erickson 2023-07-13 10:48:22 -06:00 committed by GitHub
parent ee3bdab61d
commit 380890d28b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 1 deletions

View File

@ -435,7 +435,26 @@ RSpec.describe Admin::ApiController do
"wordpress", "wordpress",
) )
expect(scopes["topics"].any? { |h| h["urls"].include?("/latest.rss (GET)") }).to be_truthy topic_routes = [
"/t/:id (GET)",
"/t/external_id/:external_id (GET)",
"/t/:slug/:topic_id/print (GET)",
"/t/:slug/:topic_id/summary (GET)",
"/t/:topic_id/summary (GET)",
"/t/:topic_id/:post_number (GET)",
"/t/:topic_id/last (GET)",
"/t/:slug/:topic_id.rss (GET)",
"/t/:slug/:topic_id (GET)",
"/t/:slug/:topic_id/:post_number (GET)",
"/t/:slug/:topic_id/last (GET)",
"/t/:topic_id/posts (GET)",
"/latest.rss (GET)",
]
topic_routes.each do |route|
expect(scopes["topics"].any? { |h| h["urls"].include?(route) }).to be_truthy
end
expect(scopes["posts"].any? { |h| h["urls"].include?("/posts (GET)") }).to be_truthy expect(scopes["posts"].any? { |h| h["urls"].include?("/posts (GET)") }).to be_truthy
expect(scopes["posts"].any? { |h| h["urls"].include?("/private-posts (GET)") }).to be_truthy expect(scopes["posts"].any? { |h| h["urls"].include?("/private-posts (GET)") }).to be_truthy
end end