]> source.dussan.org Git - redmine.git/commitdiff
Fixed Internal Error in watchers XHR search (#10600).
authorEtienne Massip <etienne.massip@gmail.com>
Thu, 5 Apr 2012 18:10:54 +0000 (18:10 +0000)
committerEtienne Massip <etienne.massip@gmail.com>
Thu, 5 Apr 2012 18:10:54 +0000 (18:10 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9323 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/watchers_controller.rb
test/functional/watchers_controller_test.rb

index 0a427801c55f0f92688f6ee8efe9af896a584900..19af1e672e5ab6b4193ba5b690b85436f37851d5 100644 (file)
@@ -98,7 +98,7 @@ class WatchersController < ApplicationController
   def autocomplete_for_user
     @users = User.active.like(params[:q]).find(:all, :limit => 100)
     if @watched
-      @user -= @watched.watcher_users
+      @users -= @watched.watcher_users
     end
     render :layout => false
   end
index 03b1a977b7eeeffbc96e3151dccefba324f4d99c..8781db797063dd4a3c971b6449a4b330bb0e446f 100644 (file)
@@ -98,6 +98,26 @@ class WatchersControllerTest < ActionController::TestCase
     assert Issue.find(2).watched_by?(User.find(7))
   end
 
+  def test_autocomplete_on_watchable_creation
+    xhr :get, :autocomplete_for_user, :q => 'mi'
+    assert_response :success
+    assert_select 'input', :count => 4
+    assert_select 'input[name=?][value=1]', 'watcher[user_ids][]'
+    assert_select 'input[name=?][value=2]', 'watcher[user_ids][]'
+    assert_select 'input[name=?][value=8]', 'watcher[user_ids][]'
+    assert_select 'input[name=?][value=9]', 'watcher[user_ids][]'
+  end
+
+  def test_autocomplete_on_watchable_update
+    xhr :get, :autocomplete_for_user, :q => 'mi', :object_id => '2' , :object_type => 'issue'
+    assert_response :success
+    assert_select 'input', :count => 3
+    assert_select 'input[name=?][value=2]', 'watcher[user_ids][]'
+    assert_select 'input[name=?][value=8]', 'watcher[user_ids][]'
+    assert_select 'input[name=?][value=9]', 'watcher[user_ids][]'
+
+  end
+
   def test_append
     @request.session[:user_id] = 2
     assert_no_difference 'Watcher.count' do