From c74f6d9f9bcf02ccc480a2028802b83ec5d91aca Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Mon, 9 Dec 2013 06:16:03 +0000 Subject: [PATCH] add tests for non member watchers (#15622) git-svn-id: http://svn.redmine.org/redmine/trunk@12396 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/functional/watchers_controller_test.rb | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) 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