Project

General

Profile

Actions

Patch #38144

closed

Refactoring: Use Group.visible instead of manual visibility check in GroupsController

Added by Holger Just about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Groups
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

The following patch adapts the find_group behavior in the GroupsController to directly rely on the Principal.visible scope rather than a manual check. The visible behavior should not change at all, the check is just at a more explicit area and thus is a little less likely to be forgotten with future changes.

diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 69dd0d5920..a88c06391e 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -50,8 +50,6 @@ def index
   end

   def show
-    return render_404 unless @group.visible?
-
     respond_to do |format|
       format.html do
         render :layout => 'base'
@@ -149,7 +147,7 @@ def autocomplete_for_user
   private

   def find_group
-    @group = Group.find(params[:id])
+    @group = Group.visible.find(params[:id])
   rescue ActiveRecord::RecordNotFound
     render_404
   end

Related issues

Related to Redmine - Feature #12795: View group members by non-admin usersClosedGo MAEDA

Actions
Actions #1

Updated by Holger Just about 1 year ago

  • Related to Feature #12795: View group members by non-admin users added
Actions #2

Updated by Go MAEDA about 1 year ago

  • Target version set to 5.0.5

Setting the target version to 5.0.5.

Actions #3

Updated by Go MAEDA about 1 year ago

  • Status changed from New to Resolved
  • Assignee set to Go MAEDA

Committed the fix. Thank you.

Actions #4

Updated by Go MAEDA about 1 year ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF