Commit f8b5e5f78ebcd7f37a0dbfb299e96d918d9c40fa
1 parent
1a03b17a
Exists in
master
and in
4 other branches
dashboard
Showing
2 changed files
with
23 additions
and
18 deletions
Show diff stats
app/controllers/projects_controller.rb
| ... | ... | @@ -6,7 +6,7 @@ class ProjectsController < ApplicationController |
| 6 | 6 | before_filter :authorize_read_project!, :except => [:index, :new, :create] |
| 7 | 7 | before_filter :authorize_admin_project!, :only => [:edit, :update, :destroy] |
| 8 | 8 | |
| 9 | - before_filter :require_non_empty_project, :only => [:blob, :tree, :show] | |
| 9 | + before_filter :require_non_empty_project, :only => [:blob, :tree] | |
| 10 | 10 | |
| 11 | 11 | def index |
| 12 | 12 | @projects = current_user.projects.all |
| ... | ... | @@ -60,21 +60,25 @@ class ProjectsController < ApplicationController |
| 60 | 60 | end |
| 61 | 61 | |
| 62 | 62 | def show |
| 63 | - @date = case params[:view] | |
| 64 | - when "week" then Date.today - 7.days | |
| 65 | - else Date.today | |
| 66 | - end | |
| 67 | - | |
| 68 | - @heads = @project.repo.heads | |
| 69 | - @commits = @heads.map do |h| | |
| 70 | - @project.repo.log(h.name, nil, :since => @date - 1.day) | |
| 71 | - end.flatten.uniq { |c| c.id } | |
| 72 | - | |
| 73 | - @commits.sort! do |x, y| | |
| 74 | - y.committed_date <=> x.committed_date | |
| 75 | - end | |
| 63 | + if @project.repo_exists? | |
| 64 | + @date = case params[:view] | |
| 65 | + when "week" then Date.today - 7.days | |
| 66 | + else Date.today | |
| 67 | + end | |
| 68 | + | |
| 69 | + @heads = @project.repo.heads | |
| 70 | + @commits = @heads.map do |h| | |
| 71 | + @project.repo.log(h.name, nil, :since => @date - 1.day) | |
| 72 | + end.flatten.uniq { |c| c.id } | |
| 73 | + | |
| 74 | + @commits.sort! do |x, y| | |
| 75 | + y.committed_date <=> x.committed_date | |
| 76 | + end | |
| 76 | 77 | |
| 77 | - @messages = project.notes.since(@date).limit(40).order("created_at DESC") | |
| 78 | + @messages = project.notes.since(@date).limit(40).order("created_at DESC") | |
| 79 | + else | |
| 80 | + return render "projects/empty" | |
| 81 | + end | |
| 78 | 82 | end |
| 79 | 83 | |
| 80 | 84 | # | ... | ... |
spec/requests/projects_spec.rb
| ... | ... | @@ -72,7 +72,10 @@ describe "Projects" do |
| 72 | 72 | current_path.should == project_path(@project) |
| 73 | 73 | end |
| 74 | 74 | |
| 75 | - it_behaves_like :tree_view | |
| 75 | + it "should beahave like dashboard" do | |
| 76 | + page.should have_content("Recent history") | |
| 77 | + end | |
| 78 | + | |
| 76 | 79 | end |
| 77 | 80 | |
| 78 | 81 | describe "GET /projects/team" do |
| ... | ... | @@ -134,8 +137,6 @@ describe "Projects" do |
| 134 | 137 | it "should show project" do |
| 135 | 138 | page.should have_content("Awesome") |
| 136 | 139 | end |
| 137 | - | |
| 138 | - it_behaves_like :tree_view | |
| 139 | 140 | end |
| 140 | 141 | |
| 141 | 142 | #describe "DELETE /projects/:id", :js => true do | ... | ... |