Skip to content

Commit

Permalink
Fix group projects fetch
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Zaporozhets <[email protected]>
  • Loading branch information
dzaporozhets committed May 29, 2014
1 parent 8f259c5 commit f329d34
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -108,12 +108,12 @@ def load_projects
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
Expand Down
12 changes: 12 additions & 0 deletions spec/features/security/group/group_access_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,17 @@
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

0 comments on commit f329d34

Please sign in to comment.