From 58786e8d80d4a4749869866eee7b5b29c120edb2 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 29 Mar 2014 14:34:28 +0000 Subject: [PATCH] Merged r12985 (#14298). git-svn-id: http://svn.redmine.org/redmine/branches/2.5-stable@13019 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/watchers_controller.rb | 3 +++ test/functional/watchers_controller_test.rb | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb index 0096d8ac1..e6c4d3119 100644 --- a/app/controllers/watchers_controller.rb +++ b/app/controllers/watchers_controller.rb @@ -55,6 +55,9 @@ class WatchersController < ApplicationController user_ids = params[:watcher][:user_ids] || [params[:watcher][:user_id]] @users = User.active.where(:id => user_ids).all end + if @users.blank? + render :nothing => true + end end def destroy diff --git a/test/functional/watchers_controller_test.rb b/test/functional/watchers_controller_test.rb index 8ec2aa112..dc72a9b6b 100644 --- a/test/functional/watchers_controller_test.rb +++ b/test/functional/watchers_controller_test.rb @@ -237,6 +237,13 @@ class WatchersControllerTest < ActionController::TestCase end end + def test_append_without_user_should_render_nothing + @request.session[:user_id] = 2 + xhr :post, :append, :project_id => 'ecookbook' + assert_response :success + assert response.body.blank? + end + def test_remove_watcher @request.session[:user_id] = 2 assert_difference('Watcher.count', -1) do