Commit 0bb9b964 authored by Patricio Cano's avatar Patricio Cano

Refactored tests, better view restrictions, and moved the message generator to a helper.

parent 954b68ed
......@@ -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."
end
def project_above_size_limit_message
Gitlab::RepositorySizeError.new(@project).above_size_limit_message
end
def git_user_name
if current_user
current_user.name
......
.alert.alert-warning.hidden-xs
= Gitlab::RepositorySizeError.new(@project).over_size_limit_message
= project_above_size_limit_message
......@@ -8,9 +8,8 @@
- if current_user && can?(current_user, :download_code, @project)
= render 'shared/no_ssh'
= render 'shared/no_password'
- if @project.above_size_limit?
= render 'over_size_limit_warning'
= render 'above_size_limit_warning'
= render 'projects/last_push'
= render "home_panel"
......
module Gitlab
class RepositorySizeError < StandardError
class RepositorySizeError
include ActionView::Helpers
attr_reader :project
......@@ -32,7 +32,7 @@ module Gitlab
'Please contact your GitLab administrator for more information.'
end
def over_size_limit_message
def above_size_limit_message
"#{to_s} You won't be able to push new code to this project. #{more_info_message}"
end
......
......@@ -92,15 +92,22 @@ describe ProjectsController do
context 'project repo over limit' do
before do
sign_in(user)
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' do
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).to render_template('_over_size_limit_warning')
expect(response).not_to render_template('_above_size_limit_warning')
end
end
end
......
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