Fixed: cannot retrieve members for closed projects through the REST API (#15848).

git-svn-id: http://svn.redmine.org/redmine/trunk@12650 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2014-01-11 11:47:26 +00:00
parent de19424ea5
commit 9ad2ca61da
3 changed files with 10 additions and 1 deletions

View File

@ -86,6 +86,7 @@ Redmine::AccessControl.map do |map|
map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member
map.permission :close_project, {:projects => [:close, :reopen]}, :require => :member, :read => true
map.permission :select_project_modules, {:projects => :modules}, :require => :member
map.permission :view_members, {:members => [:index, :show]}, :public => true, :read => true
map.permission :manage_members, {:projects => :settings, :members => [:index, :show, :create, :update, :destroy, :autocomplete]}, :require => :member
map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member
map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member

View File

@ -60,7 +60,7 @@ module Redmine
!perm.nil? && perm.read?
else
s = "#{action[:controller]}/#{action[:action]}"
permissions.detect {|p| p.actions.include?(s) && !p.read?}.nil?
permissions.detect {|p| p.actions.include?(s) && p.read?}.present?
end
end

View File

@ -73,6 +73,14 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
json)
end
test "GET /projects/:project_id/memberships.xml should succeed for closed project" do
project = Project.find(1)
project.close
assert !project.reload.active?
get '/projects/1/memberships.json', {}, credentials('jsmith')
assert_response :success
end
test "POST /projects/:project_id/memberships.xml should create the membership" do
assert_difference 'Member.count' do
post '/projects/1/memberships.xml', {:membership => {:user_id => 7, :role_ids => [2,3]}}, credentials('jsmith')