Commit 7146ea1

mo khan <mo@mokhan.ca>
2015-06-01 04:02:53
add reddit style vanity url.
1 parent f4ef350
Changed files (2)
config/routes.rb
@@ -9,6 +9,7 @@ Rails.application.routes.draw do
   end
   resources :programs, only: [:show]
   resources :profiles, only: [:show]
+  get "/u/:id" => "profiles#show"
   get "/dashboard" => "training_sessions#index", as: :dashboard
   get "/terms" => "static_pages#terms"
 end
spec/routing/profiles_routing_spec.rb
@@ -0,0 +1,19 @@
+require "rails_helper"
+
+describe "/profiles" do
+  it "routes to /profiles/<username>" do
+    expect(get: "/profiles/mokha").to route_to(
+      controller: "profiles",
+      action: "show",
+      id: "mokha"
+    )
+  end
+
+  it "routes to /u/<username>" do
+    expect(get: "/u/mokha").to route_to(
+      controller: "profiles",
+      action: "show",
+      id: "mokha"
+    )
+  end
+end