Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2017-08-18 22:06:41 +0300
committerRobert Speicher <rspeicher@gmail.com>2017-08-18 22:16:54 +0300
commit5b37f21bf2c3a9bc6006bcdfbcbc04d19b9b9b86 (patch)
tree0e5491276e362c218b8f8be2a2b591d8429f77da /lib/gitlab/git_access.rb
parentbb40f4ab6ec2aa8e435b6f5b6cbcf2d316008add (diff)
Reduce duplication in GitAccess spec around error messages
- Adds a new `ProjectMovedError` class to encapsulate that error condition. Inherits from `NotFoundError` so existing rescues should continue to work. - Separating that condition out of `NotFoundError` allowed us to simplify the `raise_not_found` helper and avoid repeating the literal string. - Spec makes use of `ERROR_MESSAGES` hash to avoid repeating literal error message strings.
Diffstat (limited to 'lib/gitlab/git_access.rb')
-rw-r--r--lib/gitlab/git_access.rb19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb
index 0b62911958d..3e8b83c0f90 100644
--- a/lib/gitlab/git_access.rb
+++ b/lib/gitlab/git_access.rb
@@ -4,6 +4,7 @@ module Gitlab
class GitAccess
UnauthorizedError = Class.new(StandardError)
NotFoundError = Class.new(StandardError)
+ ProjectMovedError = Class.new(NotFoundError)
ERROR_MESSAGES = {
upload: 'You are not allowed to upload code for this project.',
@@ -90,18 +91,18 @@ module Gitlab
end
def check_project_moved!
- if redirected_path
- url = protocol == 'ssh' ? project.ssh_url_to_repo : project.http_url_to_repo
- message = <<-MESSAGE.strip_heredoc
- Project '#{redirected_path}' was moved to '#{project.full_path}'.
+ return unless redirected_path
- Please update your Git remote and try again:
+ url = protocol == 'ssh' ? project.ssh_url_to_repo : project.http_url_to_repo
+ message = <<-MESSAGE.strip_heredoc
+ Project '#{redirected_path}' was moved to '#{project.full_path}'.
- git remote set-url origin #{url}
- MESSAGE
+ Please update your Git remote and try again:
- raise NotFoundError, message
- end
+ git remote set-url origin #{url}
+ MESSAGE
+
+ raise ProjectMovedError, message
end
def check_command_disabled!(cmd)