From 9ad2ca61da9d91ac0d7de999ce492bbeb3a0449c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 11 Jan 2014 11:47:26 +0000 Subject: [PATCH] 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 --- lib/redmine.rb | 1 + lib/redmine/access_control.rb | 2 +- test/integration/api_test/memberships_test.rb | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/redmine.rb b/lib/redmine.rb index 0c78b99d9..d35f82847 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -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 diff --git a/lib/redmine/access_control.rb b/lib/redmine/access_control.rb index 7c4a5a5ec..56927845d 100644 --- a/lib/redmine/access_control.rb +++ b/lib/redmine/access_control.rb @@ -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 diff --git a/test/integration/api_test/memberships_test.rb b/test/integration/api_test/memberships_test.rb index 626282054..0a319420f 100644 --- a/test/integration/api_test/memberships_test.rb +++ b/test/integration/api_test/memberships_test.rb @@ -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')