]> source.dussan.org Git - redmine.git/commitdiff
Merged r16116 (#22034).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 4 Jan 2017 18:09:00 +0000 (18:09 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 4 Jan 2017 18:09:00 +0000 (18:09 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@16128 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/members_controller.rb
app/views/projects/settings/_members.html.erb
test/functional/members_controller_test.rb
test/functional/projects_controller_test.rb
test/integration/api_test/memberships_test.rb

index 140d504aad5c64973a4f907d767c9fa08eabc833..173b3ee66a22c3310eaf5cae59ffb1227fb2f108 100644 (file)
@@ -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']
index 31415f80e1d2e3d8bd986082717a51870e49aa24..185bce4d30554f3f1134ee9ff2e44e91095c9dff 100644 (file)
@@ -1,5 +1,5 @@
 <% roles = Role.find_all_givable
-   members = @project.memberships.active.includes(:member_roles, :roles, :principal).to_a.sort %>
+   members = @project.memberships.includes(:member_roles, :roles, :principal).to_a.sort %>
 
 <p><%= link_to l(:label_member_new), new_project_membership_path(@project), :remote => true, :class => "icon icon-add" %></p>
 
index 05a4fa5a974bc75affd1cf33782537cc97b1404d..4179a2bce4d3e4b84dab664cb224bb26e7fefbdf 100644 (file)
@@ -119,6 +119,16 @@ class MembersControllerTest < ActionController::TestCase
     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
@@ -160,6 +170,14 @@ class MembersControllerTest < ActionController::TestCase
     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
index 55dbeefb0ee5226052d4dfb3454e84a0746d1045..415c7c4edcdcac9aacc05c983f0fc2021266e426 100644 (file)
@@ -461,6 +461,18 @@ class ProjectsControllerTest < ActionController::TestCase
     end
   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',
index 92d4b094cc11532b607e5edf5c4802dcd82672d6..dd259839d70ce3cde60ffbd5e7d435bf0a37d2b5 100644 (file)
@@ -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')