Commit 398f83e
Changed files (2)
config
spec
routing
config/routes.rb
@@ -8,8 +8,8 @@ Rails.application.routes.draw do
end
end
resources :programs, only: [:show]
- resources :profiles, only: [:show]
- get "/u/:id" => "profiles#show"
+ resources :profiles, only: [:show], constraints: { id: /[^\/]+/ }
+ get "/u/:id" => "profiles#show", constraints: { id: /[^\/]+/ }
get "/dashboard" => "training_sessions#index", as: :dashboard
get "/terms" => "static_pages#terms"
end
spec/routing/profiles_routing_spec.rb
@@ -16,4 +16,17 @@ describe "/profiles" do
id: "mokha"
)
end
+
+ it 'routes to /profiles/<username> with funky usernames' do
+ expect(get: "/profiles/mo.kha").to route_to(
+ controller: "profiles",
+ action: "show",
+ id: "mo.kha"
+ )
+ expect(get: "/u/mo.kha").to route_to(
+ controller: "profiles",
+ action: "show",
+ id: "mo.kha"
+ )
+ end
end