diff --git a/test/functional/watchers_controller_test.rb b/test/functional/watchers_controller_test.rb index 4290a4fac..03ecbfbc8 100644 --- a/test/functional/watchers_controller_test.rb +++ b/test/functional/watchers_controller_test.rb @@ -164,6 +164,17 @@ class WatchersControllerTest < ActionController::TestCase assert_select 'input[name=?][value=9]', 'watcher[user_ids][]' end + def test_search_non_member_on_create + @request.session[:user_id] = 2 + project = Project.find_by_name("ecookbook") + user = User.generate!(:firstname => 'issue15622') + membership = user.membership(project) + assert_nil membership + xhr :get, :autocomplete_for_user, :q => 'issue15622', :project_id => 'ecookbook' + assert_response :success + assert_select 'input', :count => 1 + end + def test_autocomplete_on_watchable_update @request.session[:user_id] = 2 xhr :get, :autocomplete_for_user, :q => 'mi', :object_id => '2', @@ -175,6 +186,26 @@ class WatchersControllerTest < ActionController::TestCase assert_select 'input[name=?][value=9]', 'watcher[user_ids][]' end + def test_search_and_add_non_member_on_update + @request.session[:user_id] = 2 + project = Project.find_by_name("ecookbook") + user = User.generate!(:firstname => 'issue15622') + membership = user.membership(project) + assert_nil membership + xhr :get, :autocomplete_for_user, :q => 'issue15622', :object_id => '2', + :object_type => 'issue', :project_id => 'ecookbook' + assert_response :success + assert_select 'input', :count => 1 + assert_difference('Watcher.count', 1) do + xhr :post, :create, :object_type => 'issue', :object_id => '2', + :watcher => {:user_ids => ["#{user.id}"]} + assert_response :success + assert_match /watchers/, response.body + assert_match /ajax-modal/, response.body + end + assert Issue.find(2).watched_by?(user) + end + def test_append @request.session[:user_id] = 2 assert_no_difference 'Watcher.count' do