diff options
author | Go MAEDA <maeda@farend.jp> | 2021-03-25 05:16:54 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2021-03-25 05:16:54 +0000 |
commit | 4c2e42e1c3748ca9ae3b6a7a45e77931ec8a7ce7 (patch) | |
tree | d729547dfe34925a0164b963d5109bcf63afbc74 /test/functional | |
parent | 0a9498bf300c653eac53200cd0c1fd6603f61967 (diff) | |
download | redmine-4c2e42e1c3748ca9ae3b6a7a45e77931ec8a7ce7.tar.gz redmine-4c2e42e1c3748ca9ae3b6a7a45e77931ec8a7ce7.zip |
"Add news" button in cross-project News tab (#33167).
Patch by Mizuki ISHIKAWA.
git-svn-id: http://svn.redmine.org/redmine/trunk@20845 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/news_controller_test.rb | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/test/functional/news_controller_test.rb b/test/functional/news_controller_test.rb index 76517e1a1..c6545fa15 100644 --- a/test/functional/news_controller_test.rb +++ b/test/functional/news_controller_test.rb @@ -87,13 +87,32 @@ class NewsControllerTest < Redmine::ControllerTest assert_response 404 end - def test_get_new + def test_get_new_with_project_id @request.session[:user_id] = 2 get(:new, :params => {:project_id => 1}) assert_response :success + assert_select 'select[name=project_id]', false assert_select 'input[name=?]', 'news[title]' end + def test_get_new_without_project_id + @request.session[:user_id] = 2 + get(:new) + assert_response :success + assert_select 'select[name=project_id]' + assert_select 'input[name=?]', 'news[title]' + end + + def test_get_new_if_user_does_not_have_permission + @request.session[:user_id] = 2 + User.find(2).roles.each{|u| u.remove_permission! :manage_news } + + get(:new) + assert_response :forbidden + assert_select 'select[name=project_id]', false + assert_select 'input[name=?]', 'news[title]', count: 0 + end + def test_post_create ActionMailer::Base.deliveries.clear @request.session[:user_id] = 2 @@ -121,6 +140,34 @@ class NewsControllerTest < Redmine::ControllerTest assert_equal 2, ActionMailer::Base.deliveries.size end + def test_post_create_with_cross_project_param + ActionMailer::Base.deliveries.clear + @request.session[:user_id] = 2 + + with_settings :notified_events => %w(news_added) do + post( + :create, + :params => { + :project_id => 1, + :cross_project => '1', + :news => { + :title => 'NewsControllerTest', + :description => 'This is the description', + :summary => '' + } + } + ) + end + assert_redirected_to '/news' + + news = News.find_by(title: 'NewsControllerTest') + assert_not_nil news + assert_equal 'This is the description', news.description + assert_equal User.find(2), news.author + assert_equal Project.find(1), news.project + assert_equal 2, ActionMailer::Base.deliveries.size + end + def test_post_create_with_attachment set_tmp_attachments_directory ActionMailer::Base.deliveries.clear |