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:
authorRubén Dávila <ruben@gitlab.com>2017-08-31 02:38:06 +0300
committerRubén Dávila <ruben@gitlab.com>2017-08-31 02:38:06 +0300
commit68de5dcba28d83089fd563434ba9d1ba1d882b76 (patch)
tree46074d5834494cf420db55b228ef9730922db96a /app/helpers/visibility_level_helper.rb
parent8ffbab216b90c7743ee15a652bb72eaf460bc3ba (diff)
Fix error reported by Flay
Diffstat (limited to 'app/helpers/visibility_level_helper.rb')
-rw-r--r--app/helpers/visibility_level_helper.rb24
1 files changed, 16 insertions, 8 deletions
diff --git a/app/helpers/visibility_level_helper.rb b/app/helpers/visibility_level_helper.rb
index e21a7b04bb4..4b4f7c6a57a 100644
--- a/app/helpers/visibility_level_helper.rb
+++ b/app/helpers/visibility_level_helper.rb
@@ -89,11 +89,10 @@ module VisibilityLevelHelper
end
unless project.visibility_level_allowed_by_group?(level)
- group = link_to project.group.name, group_path(project.group)
- change_visiblity = link_to 'change the visibility', edit_group_path(project.group)
+ errors = visibility_level_errors_for_group(project.group, level_name)
- reasons << "the visibility of #{group} is #{project.group.visibility}"
- instructions << " To make this project #{level_name}, you must first #{change_visiblity} of the parent group."
+ reasons << errors[:reason]
+ instructions << errors[:instruction]
end
reasons = reasons.any? ? ' because ' + reasons.to_sentence : ''
@@ -116,11 +115,10 @@ module VisibilityLevelHelper
end
unless group.visibility_level_allowed_by_parent?(level)
- parent_group = link_to group.parent.name, group_path(group.parent)
- change_visiblity = link_to 'change the visibility', edit_group_path(group.parent)
+ errors = visibility_level_errors_for_group(group.parent, level_name)
- reasons << "the visibility of #{parent_group} is #{group.parent.visibility}"
- instructions << " To make this group #{level_name}, you must first #{change_visiblity} of the parent group."
+ reasons << errors[:reason]
+ instructions << errors[:instruction]
end
reasons = reasons.any? ? ' because ' + reasons.to_sentence : ''
@@ -163,4 +161,14 @@ module VisibilityLevelHelper
return false unless form_model.respond_to?(:visibility_level_allowed?)
!form_model.visibility_level_allowed?(level)
end
+
+ private
+
+ def visibility_level_errors_for_group(group, level_name)
+ group = link_to group.name, group_path(group)
+ change_visiblity = link_to 'change the visibility', edit_group_path(group)
+
+ { reason: "the visibility of #{group} is #{group.visibility}",
+ instruction: " To make this group #{level_name}, you must first #{change_visiblity} of the parent group." }
+ end
end