Fix group projects fetch
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
8f259c5ecc
commit
f329d34ff3
2 changed files with 15 additions and 3 deletions
|
@ -5,7 +5,7 @@ class GroupsController < ApplicationController
|
|||
|
||||
# Authorize
|
||||
before_filter :authorize_read_group!, except: [:new, :create]
|
||||
before_filter :authorize_admin_group!, only: [:edit, :update, :destroy]
|
||||
before_filter :authorize_admin_group!, only: [:edit, :update, :destroy, :projects]
|
||||
before_filter :authorize_create_group!, only: [:new, :create]
|
||||
|
||||
# Load group projects
|
||||
|
@ -108,12 +108,12 @@ class GroupsController < ApplicationController
|
|||
end
|
||||
|
||||
def project_ids
|
||||
projects.pluck(:id)
|
||||
@projects.pluck(:id)
|
||||
end
|
||||
|
||||
# Dont allow unauthorized access to group
|
||||
def authorize_read_group!
|
||||
unless @group and (projects.present? or can?(current_user, :read_group, @group))
|
||||
unless @group and (@projects.present? or can?(current_user, :read_group, @group))
|
||||
if current_user.nil?
|
||||
return authenticate_user!
|
||||
else
|
||||
|
|
|
@ -82,5 +82,17 @@ describe "Group access", feature: true do
|
|||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/projects" do
|
||||
subject { projects_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_denied_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue