Commit 1fb55248 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'size-limit-message' into 'master'

Show a flash message in the project's main view when it's repo is
over the limit.

Fixes #1042 

See merge request !762
parents 2b252c9a 0bb9b964
...@@ -220,6 +220,10 @@ module ProjectsHelper ...@@ -220,6 +220,10 @@ module ProjectsHelper
"The total size of this project's repository #{show_lfs} will be limited to this size. 0 for unlimited. Leave empty to inherit the group/global value." "The total size of this project's repository #{show_lfs} will be limited to this size. 0 for unlimited. Leave empty to inherit the group/global value."
end end
def project_above_size_limit_message
Gitlab::RepositorySizeError.new(@project).above_size_limit_message
end
def git_user_name def git_user_name
if current_user if current_user
current_user.name current_user.name
......
.alert.alert-warning.hidden-xs
= project_above_size_limit_message
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
- if current_user && can?(current_user, :download_code, @project) - if current_user && can?(current_user, :download_code, @project)
= render 'shared/no_ssh' = render 'shared/no_ssh'
= render 'shared/no_password' = render 'shared/no_password'
- if @project.above_size_limit?
= render 'above_size_limit_warning'
= render 'projects/last_push' = render 'projects/last_push'
= render "home_panel" = render "home_panel"
......
module Gitlab module Gitlab
class RepositorySizeError < StandardError class RepositorySizeError
include ActionView::Helpers include ActionView::Helpers
attr_reader :project attr_reader :project
...@@ -32,6 +32,10 @@ module Gitlab ...@@ -32,6 +32,10 @@ module Gitlab
'Please contact your GitLab administrator for more information.' 'Please contact your GitLab administrator for more information.'
end end
def above_size_limit_message
"#{to_s} You won't be able to push new code to this project. #{more_info_message}"
end
private private
def base_message def base_message
......
...@@ -111,6 +111,27 @@ describe ProjectsController do ...@@ -111,6 +111,27 @@ describe ProjectsController do
get :show, namespace_id: public_project.namespace.path, id: public_project.path get :show, namespace_id: public_project.namespace.path, id: public_project.path
expect(response).to render_template('_files') expect(response).to render_template('_files')
end end
context 'project repo over limit' do
before do
allow_any_instance_of(Project).to receive(:above_size_limit?).and_return(true)
project.team << [user, :master]
end
it 'shows the over size limit warning message for project members' do
allow(controller).to receive(:current_user).and_return(user)
get :show, namespace_id: project.namespace.path, id: project.path
expect(response).to render_template('_above_size_limit_warning')
end
it 'does not show the message for non members' do
get :show, namespace_id: project.namespace.path, id: project.path
expect(response).not_to render_template('_above_size_limit_warning')
end
end
end end
context "when requested with case sensitive namespace and project path" do context "when requested with case sensitive namespace and project path" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment