From 9184d2b9541e3f57ff9f8bc247624e2d948aa262 Mon Sep 17 00:00:00 2001 From: Daniel Gerhardt Date: Mon, 4 May 2015 13:50:23 +0200 Subject: [PATCH] Prevent group names of length < 5 when updating settings This restriction does not apply to admins. --- app/controllers/groups_controller.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 4a0feb0f8de..caff3298505 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -18,7 +18,8 @@ class GroupsController < Groups::ApplicationController before_action :user_actions, only: [:show, :subgroups] - before_filter :validate_name, only: :create + before_filter :validate_name, only: [:create, :update] + layout :determine_layout @@ -179,10 +180,15 @@ def user_actions end def validate_name - @group = Group.new(group_params) - unless @group.path.empty? || @group.path.length > 4 || current_user.admin? + group = Group.new(group_params) + unless group.path.empty? || group.path.length > 4 || current_user.admin? flash.now[:alert] = 'Path must have at least a length of 5.' - render action: "new" + if action_name == 'update' + render action: 'edit' + else + @group = group + render action: 'new' + end end end -- GitLab