]> source.dussan.org Git - redmine.git/commitdiff
Fixed that destroying a user from the edit page returns a 404 response (#11691).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 26 Aug 2012 10:50:59 +0000 (10:50 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 26 Aug 2012 10:50:59 +0000 (10:50 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10240 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/users_controller.rb
app/views/users/index.html.erb
test/functional/users_controller_test.rb

index a56371c5f8f479cfef0ad8b9dc0e0aa145ed5c24..da6f6ae28971927b09a7f686dc69d214f817811f 100644 (file)
@@ -174,7 +174,7 @@ class UsersController < ApplicationController
   def destroy
     @user.destroy
     respond_to do |format|
-      format.html { redirect_to_referer_or(users_url) }
+      format.html { redirect_back_or_default(users_url) }
       format.api  { render_api_ok }
     end
   end
index a477a5c90abe0cfd802246949a4cb83c3dff0799..f88b5231e2f8bb73b4a144fa831326a183f614e0 100644 (file)
@@ -46,7 +46,7 @@
   <td class="last_login_on" align="center"><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
     <td class="buttons">
       <%= change_status_link(user) %>
-      <%= delete_link user_path(user) unless User.current == user %>
+      <%= delete_link user_path(user, :back_url => users_path(params)) unless User.current == user %>
     </td>
   </tr>
 <% end -%>
index 3d4f084871592e2df08f1032a9a7888f9d340461..db912bf6d8b95afee8b46dac29294833e70ca710 100644 (file)
@@ -349,6 +349,13 @@ class UsersControllerTest < ActionController::TestCase
     assert_response 403
   end
 
+  def test_destroy_should_redirect_to_back_url_param
+    assert_difference 'User.count', -1 do
+      delete :destroy, :id => 2, :back_url => '/users?name=foo'
+    end
+    assert_redirected_to '/users?name=foo'
+  end
+
   def test_create_membership
     assert_difference 'Member.count' do
       post :edit_membership, :id => 7, :membership => { :project_id => 3, :role_ids => [2]}