Merge pull request #5142 from karlhungus/bugfix-handle-empty-public-projects
Prevent empty public projects from throwing exceptions
This commit is contained in:
commit
7be084b13a
4 changed files with 60 additions and 32 deletions
|
@ -16,9 +16,11 @@ class Public::ProjectsController < ApplicationController
|
|||
render_404 and return unless @project
|
||||
|
||||
@repository = @project.repository
|
||||
unless @project.empty_repo?
|
||||
@recent_tags = @repository.tags.first(10)
|
||||
|
||||
@commit = @repository.commit(params[:ref])
|
||||
@tree = Tree.new(@repository, @commit.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
%br
|
||||
.row
|
||||
- unless @project.empty_repo?
|
||||
.span9
|
||||
= render 'tree', tree: @tree
|
||||
.span3
|
||||
|
@ -44,3 +45,5 @@
|
|||
%i.icon-calendar
|
||||
= time_ago_in_words(tag.commit.committed_date)
|
||||
ago
|
||||
- else
|
||||
= 'Empty Repository'
|
||||
|
|
|
@ -12,3 +12,8 @@ Feature: Public Projects Feature
|
|||
When I visit public page for "Community" project
|
||||
Then I should see public project details
|
||||
And I should see project readme
|
||||
|
||||
Scenario: I visit an empty public project page
|
||||
Given public empty project "Empty Public Project"
|
||||
When I visit empty public project page
|
||||
Then I should see empty public project details
|
|
@ -9,6 +9,11 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
|
|||
page.should_not have_content "Enterprise"
|
||||
end
|
||||
|
||||
step 'I should see project "Empty Public Project"' do
|
||||
page.should have_content "Empty Public Project"
|
||||
puts page.save_page('foo.html')
|
||||
end
|
||||
|
||||
step 'I should see public project details' do
|
||||
page.should have_content '32 branches'
|
||||
page.should have_content '16 tags'
|
||||
|
@ -22,6 +27,19 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
|
|||
create :project_with_code, name: 'Community', public: true
|
||||
end
|
||||
|
||||
step 'public empty project "Empty Public Project"' do
|
||||
create :project, name: 'Empty Public Project', public: true
|
||||
end
|
||||
|
||||
step 'I visit empty public project page' do
|
||||
project = Project.find_by_name('Empty Public Project')
|
||||
visit public_project_path(project)
|
||||
end
|
||||
|
||||
step 'I should see empty public project details' do
|
||||
page.should have_content 'Empty Repository'
|
||||
end
|
||||
|
||||
step 'private project "Enterprise"' do
|
||||
create :project, name: 'Enterprise'
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue