From 514d9bad9efd584d9dd70aca2b1c27128c2f0eca Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 31 Dec 2016 13:33:02 +0000 Subject: [PATCH] Fixed that project settings should show locked members (#22034). git-svn-id: http://svn.redmine.org/redmine/trunk@16116 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/members_controller.rb | 2 +- app/views/projects/settings/_members.html.erb | 2 +- test/functional/members_controller_test.rb | 18 ++++++++++ test/functional/projects_controller_test.rb | 12 +++++++ test/integration/api_test/memberships_test.rb | 34 +++++++++++-------- 5 files changed, 52 insertions(+), 16 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 4aedf8f2d..ca3dcd474 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -26,7 +26,7 @@ class MembersController < ApplicationController require_sudo_mode :create, :update, :destroy def index - scope = @project.memberships.active + scope = @project.memberships @offset, @limit = api_offset_and_limit @member_count = scope.count @member_pages = Paginator.new @member_count, @limit, params['page'] diff --git a/app/views/projects/settings/_members.html.erb b/app/views/projects/settings/_members.html.erb index 05707fe78..1dd665a34 100644 --- a/app/views/projects/settings/_members.html.erb +++ b/app/views/projects/settings/_members.html.erb @@ -1,5 +1,5 @@ <% roles = Role.find_all_givable - members = @project.memberships.active.sorted.to_a %> + members = @project.memberships.sorted.to_a %>

<%= link_to l(:label_member_new), new_project_membership_path(@project), :remote => true, :class => "icon icon-add" %>

diff --git a/test/functional/members_controller_test.rb b/test/functional/members_controller_test.rb index c9337e210..d132c8293 100644 --- a/test/functional/members_controller_test.rb +++ b/test/functional/members_controller_test.rb @@ -117,6 +117,16 @@ class MembersControllerTest < Redmine::ControllerTest assert_redirected_to '/projects/ecookbook/settings/members' end + def test_update_locked_member_should_be_allowed + User.find(3).lock! + + put :update, :id => 2, :membership => {:role_ids => [1]} + assert_response 302 + member = Member.find(2) + assert member.user.locked? + assert_equal [1], member.role_ids + end + def test_update_should_not_add_unmanaged_roles role = Role.find(1) role.update! :all_roles_managed => false @@ -157,6 +167,14 @@ class MembersControllerTest < Redmine::ControllerTest assert !User.find(3).member_of?(Project.find(1)) end + def test_destroy_locked_member_should_be_allowed + assert User.find(3).lock! + + assert_difference 'Member.count', -1 do + delete :destroy, :id => 2 + end + end + def test_destroy_should_fail_with_unmanaged_roles role = Role.find(1) role.update! :all_roles_managed => false diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 01c68308f..da2818174 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -527,6 +527,18 @@ class ProjectsControllerTest < Redmine::ControllerTest assert_select 'a#tab-versions[href=?]', '/projects/ecookbook/settings/versions?version_name=.1&version_status=' end + def test_settings_should_show_locked_members + user = User.generate! + member = User.add_to_project(user, Project.find(1)) + user.lock! + assert user.reload.locked? + @request.session[:user_id] = 2 + + get :settings, :id => 'ecookbook', :tab => 'members' + assert_response :success + assert_select "tr#member-#{member.id}" + end + def test_update @request.session[:user_id] = 2 # manager post :update, :id => 1, :project => {:name => 'Test changed name', diff --git a/test/integration/api_test/memberships_test.rb b/test/integration/api_test/memberships_test.rb index 92d4b094c..dd259839d 100644 --- a/test/integration/api_test/memberships_test.rb +++ b/test/integration/api_test/memberships_test.rb @@ -37,20 +37,17 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base assert_response :success assert_equal 'application/json', @response.content_type json = ActiveSupport::JSON.decode(response.body) - assert_equal({ - "memberships" => - [{"id"=>1, - "project" => {"name"=>"eCookbook", "id"=>1}, - "roles" => [{"name"=>"Manager", "id"=>1}], - "user" => {"name"=>"John Smith", "id"=>2}}, - {"id"=>2, - "project" => {"name"=>"eCookbook", "id"=>1}, - "roles" => [{"name"=>"Developer", "id"=>2}], - "user" => {"name"=>"Dave Lopper", "id"=>3}}], - "limit" => 25, - "total_count" => 2, - "offset" => 0}, - json) + assert_equal 3, json["total_count"] + assert_equal 25, json["limit"] + assert_equal 0, json["offset"] + assert_include({ + "id"=>1, + "project" => {"name"=>"eCookbook", "id"=>1}, + "roles" => [{"name"=>"Manager", "id"=>1}], + "user" => {"name"=>"John Smith", "id"=>2} + }, + json["memberships"] + ) end test "GET /projects/:project_id/memberships.xml should succeed for closed project" do @@ -61,6 +58,15 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base assert_response :success end + test "GET /projects/:project_id/memberships.xml should include locked users" do + assert User.find(3).lock! + get '/projects/ecookbook/memberships.xml', {}, credentials('jsmith') + assert_response :success + assert_select 'memberships[type=array] membership id', :text => '2' do + assert_select '~ user[id="3"][name="Dave Lopper"]' + end + 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') -- 2.39.5