File tree Expand file tree Collapse file tree 3 files changed +36
-10
lines changed
lib/code_corps/validators
test/lib/code_corps/validators Expand file tree Collapse file tree 3 files changed +36
-10
lines changed Original file line number Diff line number Diff line change @@ -30,18 +30,29 @@ defmodule CodeCorps.Validators.SlugValidator do
3030 # Routes for the API – api. subdomain
3131 api_routes = ~w(
3232 api
33- categories comments contributors
33+ categories comments contributors connect conversations conversation-parts
34+ donation-goals
35+ email_available
36+ forgot
37+ github-app-installations github-events github-issues github-pull-requests
38+ github-repos
3439 images issues
3540 mentions
41+ messages
3642 notifications
37- oauth oauth_clients organizations
38- ping projects project-categories
39- project-skills
40- repositories roles
41- skills slugged-route stars
42- tags tasks task-images task-likes
43+ oauth oauth_clients organizations organization-github-app-installations
44+ organization-invites
45+ password ping platform previews projects project-categories project-skills
46+ project-users
47+ refresh repositories reset roles role-skills
48+ skills slugged-route stars stripe stripe-connect-accounts
49+ stripe-connect-plans stripe-connect-subscriptions stripe-platform-cards
50+ stripe-platform-customers
51+ tags tasks task-images task-likes task-lists task-skills
4352 teams token tokens
44- user-roles user-skills user users
53+ user-categories user-roles user-skills user-tasks user username_available
54+ users
55+ webhooks
4556 )
4657
4758 # Routes for the web – www. subdomain
Original file line number Diff line number Diff line change 22-- PostgreSQL database dump
33--
44
5- -- Dumped from database version 10.1
6- -- Dumped by pg_dump version 10.1
5+ -- Dumped from database version 10.0
6+ -- Dumped by pg_dump version 10.0
77
88SET statement_timeout = 0 ;
99SET lock_timeout = 0 ;
Original file line number Diff line number Diff line change @@ -88,6 +88,21 @@ defmodule CodeCorps.Validators.SlugValidatorTest do
8888 refute changeset . valid?
8989 end
9090
91+ test "reserves all api routes" do
92+ CodeCorpsWeb.Router . __routes__
93+ |> Enum . map ( & Map . get ( & 1 , :path ) )
94+ |> Enum . map ( & String . split ( & 1 , "/" ) )
95+ |> List . flatten
96+ |> Enum . reject ( fn fragment -> fragment == "" end )
97+ |> Enum . reject ( fn fragment -> fragment |> String . at ( 0 ) == ":" end )
98+ |> Enum . uniq
99+ |> Enum . sort
100+ |> Enum . each ( fn reserved ->
101+ changeset = process_slug ( reserved )
102+ refute changeset . valid? , "#{ reserved } should not be allowed as a slug"
103+ end )
104+ end
105+
91106 defp process_slug ( slug ) do
92107 slug
93108 |> cast_slug
You can’t perform that action at this time.
0 commit comments