OSDN Git Service

dashboard
authorgitlabhq <m@gitlabhq.com>
Tue, 18 Oct 2011 14:57:01 +0000 (17:57 +0300)
committergitlabhq <m@gitlabhq.com>
Tue, 18 Oct 2011 14:57:01 +0000 (17:57 +0300)
app/controllers/projects_controller.rb
spec/requests/projects_spec.rb

index 7469b05..6bcc14b 100644 (file)
@@ -6,7 +6,7 @@ class ProjectsController < ApplicationController
   before_filter :authorize_read_project!, :except => [:index, :new, :create] 
   before_filter :authorize_admin_project!, :only => [:edit, :update, :destroy] 
 
-  before_filter :require_non_empty_project, :only => [:blob, :tree, :show]
+  before_filter :require_non_empty_project, :only => [:blob, :tree]
 
   def index
     @projects = current_user.projects.all
@@ -60,21 +60,25 @@ class ProjectsController < ApplicationController
   end
 
   def show
-    @date = case params[:view]
-            when "week" then Date.today - 7.days
-            else Date.today
-            end
-
-    @heads = @project.repo.heads
-    @commits = @heads.map do |h| 
-      @project.repo.log(h.name, nil, :since => @date - 1.day)
-    end.flatten.uniq { |c| c.id }
-    
-    @commits.sort! do |x, y|
-      y.committed_date <=> x.committed_date
-    end
+    if @project.repo_exists?
+      @date = case params[:view]
+              when "week" then Date.today - 7.days
+              else Date.today
+              end
+
+      @heads = @project.repo.heads
+      @commits = @heads.map do |h| 
+        @project.repo.log(h.name, nil, :since => @date - 1.day)
+      end.flatten.uniq { |c| c.id }
+
+      @commits.sort! do |x, y|
+        y.committed_date <=> x.committed_date
+      end
 
-    @messages = project.notes.since(@date).limit(40).order("created_at DESC")
+      @messages = project.notes.since(@date).limit(40).order("created_at DESC")
+    else 
+      return render "projects/empty"
+    end
   end
 
   #
index 2825a6a..a1bac06 100644 (file)
@@ -72,7 +72,10 @@ describe "Projects" do
       current_path.should == project_path(@project)
     end
 
-    it_behaves_like :tree_view
+    it "should beahave like dashboard" do 
+      page.should have_content("Recent history")
+    end
+
   end
 
   describe "GET /projects/team" do
@@ -134,8 +137,6 @@ describe "Projects" do
     it "should show project" do
       page.should have_content("Awesome")
     end
-
-    it_behaves_like :tree_view
   end
 
   #describe "DELETE /projects/:id", :js => true do