@@ -1,16 +1,16 | |||
|
1 |
# |
|
|
2 |
# Copyright (C) 2006-20 |
|
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 |
# |
|
|
8 | # | |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 |
# |
|
|
13 | # | |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
@@ -23,14 +23,14 class NewsController; def rescue_action(e) raise e end; end | |||
|
23 | 23 | |
|
24 | 24 | class NewsControllerTest < ActionController::TestCase |
|
25 | 25 | fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :news, :comments |
|
26 | ||
|
26 | ||
|
27 | 27 | def setup |
|
28 | 28 | @controller = NewsController.new |
|
29 | 29 | @request = ActionController::TestRequest.new |
|
30 | 30 | @response = ActionController::TestResponse.new |
|
31 | 31 | User.current = nil |
|
32 | 32 | end |
|
33 | ||
|
33 | ||
|
34 | 34 | def test_index |
|
35 | 35 | get :index |
|
36 | 36 | assert_response :success |
@@ -38,33 +38,33 class NewsControllerTest < ActionController::TestCase | |||
|
38 | 38 | assert_not_nil assigns(:newss) |
|
39 | 39 | assert_nil assigns(:project) |
|
40 | 40 | end |
|
41 | ||
|
41 | ||
|
42 | 42 | def test_index_with_project |
|
43 | 43 | get :index, :project_id => 1 |
|
44 | 44 | assert_response :success |
|
45 | 45 | assert_template 'index' |
|
46 | 46 | assert_not_nil assigns(:newss) |
|
47 | 47 | end |
|
48 | ||
|
48 | ||
|
49 | 49 | def test_show |
|
50 | 50 | get :show, :id => 1 |
|
51 | 51 | assert_response :success |
|
52 | 52 | assert_template 'show' |
|
53 | 53 | assert_tag :tag => 'h2', :content => /eCookbook first release/ |
|
54 | 54 | end |
|
55 | ||
|
55 | ||
|
56 | 56 | def test_show_not_found |
|
57 | 57 | get :show, :id => 999 |
|
58 | 58 | assert_response 404 |
|
59 | 59 | end |
|
60 | ||
|
60 | ||
|
61 | 61 | def test_get_new |
|
62 | 62 | @request.session[:user_id] = 2 |
|
63 | 63 | get :new, :project_id => 1 |
|
64 | 64 | assert_response :success |
|
65 | 65 | assert_template 'new' |
|
66 | 66 | end |
|
67 | ||
|
67 | ||
|
68 | 68 | def test_post_create |
|
69 | 69 | ActionMailer::Base.deliveries.clear |
|
70 | 70 | Setting.notified_events << 'news_added' |
@@ -74,7 +74,7 class NewsControllerTest < ActionController::TestCase | |||
|
74 | 74 | :description => 'This is the description', |
|
75 | 75 | :summary => '' } |
|
76 | 76 | assert_redirected_to '/projects/ecookbook/news' |
|
77 | ||
|
77 | ||
|
78 | 78 | news = News.find_by_title('NewsControllerTest') |
|
79 | 79 | assert_not_nil news |
|
80 | 80 | assert_equal 'This is the description', news.description |
@@ -82,14 +82,14 class NewsControllerTest < ActionController::TestCase | |||
|
82 | 82 | assert_equal Project.find(1), news.project |
|
83 | 83 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
84 | 84 | end |
|
85 | ||
|
85 | ||
|
86 | 86 | def test_get_edit |
|
87 | 87 | @request.session[:user_id] = 2 |
|
88 | 88 | get :edit, :id => 1 |
|
89 | 89 | assert_response :success |
|
90 | 90 | assert_template 'edit' |
|
91 | 91 | end |
|
92 | ||
|
92 | ||
|
93 | 93 | def test_put_update |
|
94 | 94 | @request.session[:user_id] = 2 |
|
95 | 95 | put :update, :id => 1, :news => { :description => 'Description changed by test_post_edit' } |
@@ -110,7 +110,7 class NewsControllerTest < ActionController::TestCase | |||
|
110 | 110 | assert_tag :tag => 'div', :attributes => { :id => 'errorExplanation' }, |
|
111 | 111 | :content => /1 error/ |
|
112 | 112 | end |
|
113 | ||
|
113 | ||
|
114 | 114 | def test_destroy |
|
115 | 115 | @request.session[:user_id] = 2 |
|
116 | 116 | delete :destroy, :id => 1 |
General Comments 0
You need to be logged in to leave comments.
Login now