From 380890d28b098a0f10d3ed4be0274670989c323a Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Thu, 13 Jul 2023 10:48:22 -0600 Subject: [PATCH] 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. --- spec/requests/admin/api_controller_spec.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/spec/requests/admin/api_controller_spec.rb b/spec/requests/admin/api_controller_spec.rb index 3d6bae83881..d83520968f5 100644 --- a/spec/requests/admin/api_controller_spec.rb +++ b/spec/requests/admin/api_controller_spec.rb @@ -435,7 +435,26 @@ RSpec.describe Admin::ApiController do "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?("/private-posts (GET)") }).to be_truthy end