add tests for non member watchers (#15622)

git-svn-id: http://svn.redmine.org/redmine/trunk@12396 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2013-12-09 06:16:03 +00:00
parent 4823d03423
commit c74f6d9f9b
1 changed files with 31 additions and 0 deletions

View File

@ -164,6 +164,17 @@ class WatchersControllerTest < ActionController::TestCase
assert_select 'input[name=?][value=9]', 'watcher[user_ids][]' assert_select 'input[name=?][value=9]', 'watcher[user_ids][]'
end 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 def test_autocomplete_on_watchable_update
@request.session[:user_id] = 2 @request.session[:user_id] = 2
xhr :get, :autocomplete_for_user, :q => 'mi', :object_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][]' assert_select 'input[name=?][value=9]', 'watcher[user_ids][]'
end 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 def test_append
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_no_difference 'Watcher.count' do assert_no_difference 'Watcher.count' do