Skip to content

Commit 482656f

Browse files
committed
Allow non-admin users to see group members (#12795).
Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@21072 e93f8b46-1217-0410-a6f0-8f06a7374b81
1 parent 8e4d71a commit 482656f

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

app/controllers/groups_controller.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class GroupsController < ApplicationController
2121
layout 'admin'
2222
self.main_menu = false
2323

24-
before_action :require_admin
24+
before_action :require_admin, :except => [:show]
2525
before_action :find_group, :except => [:index, :new, :create]
2626
accept_api_auth :index, :show, :create, :update, :destroy, :add_users, :remove_user
2727

@@ -50,8 +50,12 @@ def index
5050
end
5151

5252
def show
53+
return render_404 unless @group.visible?
54+
5355
respond_to do |format|
54-
format.html
56+
format.html do
57+
render :layout => 'base'
58+
end
5559
format.api
5660
end
5761
end

app/views/groups/show.html.erb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<%= title [l(:label_group_plural), groups_path], @group.name %>
1+
<div class="contextual">
2+
<%= link_to(l(:button_edit), edit_group_path(@group), :class => 'icon icon-edit') if User.current.admin? %>
3+
</div>
4+
5+
<h2><%= @group.name %></h2>
26

37
<% if @group.custom_field_values.any? %>
48
<ul>
@@ -14,3 +18,4 @@
1418
<li><%= user %></li>
1519
<% end %>
1620
</ul>
21+
<% html_title @group.name %>

test/functional/groups_controller_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ def test_index_with_name_filter
4747
end
4848

4949
def test_show
50+
Role.anonymous.update! :users_visibility => 'all'
51+
52+
@request.session[:user_id] = nil
5053
get(:show, :params => {:id => 10})
5154
assert_response :success
5255
end
@@ -70,6 +73,14 @@ def test_show_invalid_should_return_404
7073
assert_response 404
7174
end
7275

76+
def test_show_group_that_is_not_visible_should_return_404
77+
Role.anonymous.update! :users_visibility => 'members_of_visible_projects'
78+
79+
@request.session[:user_id] = nil
80+
get :show, :params => {:id => 10}
81+
assert_response 404
82+
end
83+
7384
def test_new
7485
get :new
7586
assert_response :success

0 commit comments

Comments
 (0)