Commit 5ab3e5c1

mo khan <mo@mokhan.ca>
2014-05-22 04:09:46
move favorites to my/favorites.
1 parent 959bd34
app/controllers/my/favorites_controller.rb
@@ -0,0 +1,9 @@
+module My
+  class FavoritesController < BaseController
+    def index
+      @user = current_user
+      @favorites = current_user.favorites.includes(:creation)
+      @creations = @favorites.map {|f| f.creation }
+    end
+  end
+end
app/controllers/profiles_controller.rb
@@ -12,10 +12,4 @@ class ProfilesController < ApplicationController
     @nearby_users = @user.nearbys(50) || []
     expires_in(1.hour)
   end
-
-  def favorites
-    @user = current_user
-    @favorites = current_user.favorites.includes(:creation)
-    @creations = @favorites.map {|f| f.creation }
-  end
 end
app/views/profiles/favorites.html.erb → app/views/my/favorites/index.html.erb
File renamed without changes
app/views/shared/_account_nav.html.erb
@@ -3,7 +3,7 @@
     <ul class="nav nav-tabs">
       <li class="<%= selected == :dashboard ? "active" : "" %>"><%= link_to "Dashboard", my_dashboard_path %></li>
       <li class="<%= selected == :creations ? "active" : "" %>"><%= link_to "Creations", my_cakes_path %></li>
-      <li class="<%= selected == :favorites ? "active" : "" %>"><%= link_to "Favorites", profiles_favorites_path %></li>
+      <li class="<%= selected == :favorites ? "active" : "" %>"><%= link_to "Favorites", my_favorites_path %></li>
       <li class="<%= selected == :basic_info ? "active" : "" %>"><%= link_to "Settings", settings_path %></li>
       <li class="<%= selected == :password ? "active" : "" %>"><%= link_to "Password", pwd_path %></li>
       <li class="<%= selected == :picture ? "active" : "" %>"><%= link_to "Picture", edit_avatar_path(current_user) %></li>
config/routes.rb
@@ -22,7 +22,7 @@ Cake::Application.routes.draw do
   resources :profiles, :only => [:index, :show] do
     get 'page/:page', :action => :index, :on => :collection
   end
-  get 'favorites' => 'profiles#favorites', :as => 'profiles_favorites'
+  #get 'favorites' => 'profiles#favorites', :as => 'profiles_favorites'
 
   # /categories
   get 'categories/:slug' => "categories#show", :as => :category
@@ -68,7 +68,7 @@ Cake::Application.routes.draw do
 
   namespace :my do
     get 'dashboard', to: 'dashboard#index'
-    resources :cakes do
-    end
+    resources :cakes, only: [:index]
+    resources :favorites, only: [:index]
   end
 end
spec/routing/my/favorites_routing_spec.rb
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+describe My::FavoritesController do
+  describe "routing" do
+    it "routes to my favorites" do
+      get("/my/favorites").should route_to("my/favorites#index")
+    end
+  end
+end
spec/routing/profiles_routing_spec.rb
@@ -1,4 +1,5 @@
 require 'spec_helper'
+
 describe ProfilesController do
   describe "routing" do
     it "routes to index" do
@@ -8,9 +9,5 @@ describe ProfilesController do
     it "routes to #show" do
       get("/profiles/1").should route_to("profiles#show", :id => "1")
     end
-
-    it "routes to my favorites" do
-      get("/favorites").should route_to("profiles#favorites")
-    end
   end
 end