Commit 23d51520 authored by jplang's avatar jplang
Browse files

Fixed that project settings should show locked members (#22034).

git-svn-id: https://svn.redmine.org/redmine/trunk@16116 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 70e21ff5
......@@ -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']
......
<% roles = Role.find_all_givable
members = @project.memberships.active.sorted.to_a %>
members = @project.memberships.sorted.to_a %>
<p><%= link_to l(:label_member_new), new_project_membership_path(@project), :remote => true, :class => "icon icon-add" %></p>
......
......@@ -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
......
......@@ -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',
......
......@@ -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')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment