diff options
-rw-r--r-- | app/controllers/users_controller.rb | 2 | ||||
-rw-r--r-- | app/views/users/index.html.erb | 2 | ||||
-rw-r--r-- | test/functional/users_controller_test.rb | 7 |
3 files changed, 9 insertions, 2 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a56371c5f..da6f6ae28 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index a477a5c90..f88b5231e 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -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 -%> diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 3d4f08487..db912bf6d 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -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]} |