Commit e6c6e072
Changed files (6)
app
controllers
views
dashboard
config
spec
controllers
factories
app/controllers/dashboard_controller.rb
@@ -0,0 +1,5 @@
+class DashboardController < ApplicationController
+ def index
+ @activities = current_user.activities
+ end
+end
app/views/dashboard/_favorite.html.erb
@@ -0,0 +1,4 @@
+<div>
+ <%= avatar_for(subject.user, size: 24) %> <%= link_to subject.user.name, profile_path(subject.user) %> added <%= link_to subject.creation.name, creation_path(subject.creation) %> to their favorites
+ on <%= subject.created_at.to_s :foomat %>.
+</div>
app/views/dashboard/index.html.erb
@@ -0,0 +1,10 @@
+<div class="row">
+ <div class="span12">
+ <h1>Activity Feed</h1>
+ <ul>
+ <% @activities.each do |activity| %>
+ <li><%= render activity.subject.class.to_s.downcase, subject: activity.subject %></li>
+ <% end %>
+ </ul>
+ </div>
+</div>
config/routes.rb
@@ -3,6 +3,8 @@ Cake::Application.routes.draw do
get "about_us" => "home#about_us"
get "why_cakeside" => "home#why_cakeside"
+ get 'dashboard', to: 'dashboard#index'
+
resources :tutorials do
get 'page/:page', :action => :index, :on => :collection
end
spec/controllers/dashboard_controller_spec.rb
@@ -0,0 +1,17 @@
+require "spec_helper"
+
+describe DashboardController do
+ context "#index" do
+ let(:user) { create(:user) }
+ let!(:activity) { create(:activity, user: user) }
+
+ before :each do
+ http_login(user)
+ end
+
+ it "loads the most recent activities" do
+ get :index
+ assigns(:activities).should include(activity)
+ end
+ end
+end
spec/factories/activity.rb
@@ -0,0 +1,6 @@
+FactoryGirl.define do
+ factory :activity, class: Activity do
+ user { FactoryGirl.create(:user) }
+ subject { FactoryGirl.create(:creation) }
+ end
+end