diff options
author | Sean McGivern <sean@gitlab.com> | 2016-07-18 11:58:50 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-07-18 14:06:21 +0100 |
commit | 87035c294502451708262d68e228f7cb9e244552 (patch) | |
tree | 5049f1980d02f508376ca320a1bd31cecfb10a33 | |
parent | 2556d6d34761b6cfc4a81cfcb8f9c4a2fea114dc (diff) | |
download | gitlab-ce-87035c294502451708262d68e228f7cb9e244552.tar.gz |
Don't blow up in tree view on empty repo
-rw-r--r-- | app/controllers/projects_controller.rb | 2 | ||||
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 1803aa8eab4..4e5bcff9cf8 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -5,7 +5,7 @@ class ProjectsController < Projects::ApplicationController before_action :project, except: [:new, :create] before_action :repository, except: [:new, :create] before_action :assign_ref_vars, only: [:show], if: :repo_exists? - before_action :tree, only: [:show], if: :project_view_files? + before_action :tree, only: [:show], if: [:repo_exists?, :project_view_files?] # Authorize before_action :authorize_admin_project!, only: [:edit, :update, :housekeeping, :download_export, :export, :remove_export, :generate_new_export] diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 1b1b1bdf52d..3edce4d339c 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -43,6 +43,26 @@ describe ProjectsController do end end + context "project with empty repo" do + let(:empty_project) { create(:project_empty_repo, :public) } + + before { sign_in(user) } + + User.project_views.keys.each do |project_view| + context "with #{project_view} view set" do + before do + user.update_attributes(project_view: project_view) + + get :show, namespace_id: empty_project.namespace.path, id: empty_project.path + end + + it "renders the empty project view" do + expect(response).to render_template('empty') + end + end + end + end + context "rendering default project view" do render_views |