diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-03-24 12:57:28 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-03-24 12:57:28 +0000 |
commit | fae5250e52506356965a478518aa7960ada3ec61 (patch) | |
tree | 91db93da34e2437bd9b0e9017fb7dd38eb275b30 /test | |
parent | e2bb8721d9e0b41094f7a7c768951235492dc3e4 (diff) | |
download | redmine-fae5250e52506356965a478518aa7960ada3ec61.tar.gz redmine-fae5250e52506356965a478518aa7960ada3ec61.zip |
Ability to add non-member watchers on issue creation (#5159).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9254 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/issues_controller_test.rb | 15 | ||||
-rw-r--r-- | test/functional/watchers_controller_test.rb | 19 | ||||
-rw-r--r-- | test/integration/routing/watchers_test.rb | 4 |
3 files changed, 38 insertions, 0 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 199e9317e..e91acb20c 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -1680,6 +1680,21 @@ class IssuesControllerTest < ActionController::TestCase :value => 'Value for field 2'} end + def test_post_create_with_failure_should_preserve_watchers + assert !User.find(8).member_of?(Project.find(1)) + + @request.session[:user_id] = 2 + post :create, :project_id => 1, + :issue => {:tracker_id => 1, + :watcher_user_ids => ['3', '8']} + assert_response :success + assert_template 'new' + + assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '2', :checked => nil} + assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '3', :checked => 'checked'} + assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '8', :checked => 'checked'} + end + def test_post_create_should_ignore_non_safe_attributes @request.session[:user_id] = 2 assert_nothing_raised do diff --git a/test/functional/watchers_controller_test.rb b/test/functional/watchers_controller_test.rb index bfd93fe0d..03b1a977b 100644 --- a/test/functional/watchers_controller_test.rb +++ b/test/functional/watchers_controller_test.rb @@ -68,6 +68,13 @@ class WatchersControllerTest < ActionController::TestCase assert_select_rjs :replace_html, 'ajax-modal' end + def test_new_for_new_record + @request.session[:user_id] = 2 + xhr :get, :new, :project_id => 1 + assert_response :success + assert_select_rjs :replace_html, 'ajax-modal' + end + def test_create @request.session[:user_id] = 2 assert_difference('Watcher.count') do @@ -91,6 +98,18 @@ class WatchersControllerTest < ActionController::TestCase assert Issue.find(2).watched_by?(User.find(7)) end + def test_append + @request.session[:user_id] = 2 + assert_no_difference 'Watcher.count' do + xhr :post, :append, :watcher => {:user_ids => ['4', '7']} + assert_response :success + assert_select_rjs :insert_html, 'watchers_inputs' do + assert_select 'input[name=?][value=4]', 'issue[watcher_user_ids][]' + assert_select 'input[name=?][value=7]', 'issue[watcher_user_ids][]' + end + end + end + def test_remove_watcher @request.session[:user_id] = 2 assert_difference('Watcher.count', -1) do diff --git a/test/integration/routing/watchers_test.rb b/test/integration/routing/watchers_test.rb index 441d2533c..00410289b 100644 --- a/test/integration/routing/watchers_test.rb +++ b/test/integration/routing/watchers_test.rb @@ -24,6 +24,10 @@ class RoutingWatchersTest < ActionController::IntegrationTest { :controller => 'watchers', :action => 'new' } ) assert_routing( + { :method => 'post', :path => "/watchers/append" }, + { :controller => 'watchers', :action => 'append' } + ) + assert_routing( { :method => 'post', :path => "/watchers" }, { :controller => 'watchers', :action => 'create' } ) |