@@ -1,16 +1,16 | |||||
1 |
# |
|
1 | # Redmine - project management software | |
2 |
# Copyright (C) 2006-20 |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 |
# |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 |
# |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
@@ -23,14 +23,14 class MessagesController; def rescue_action(e) raise e end; end | |||||
23 |
|
23 | |||
24 | class MessagesControllerTest < ActionController::TestCase |
|
24 | class MessagesControllerTest < ActionController::TestCase | |
25 | fixtures :projects, :users, :members, :member_roles, :roles, :boards, :messages, :enabled_modules |
|
25 | fixtures :projects, :users, :members, :member_roles, :roles, :boards, :messages, :enabled_modules | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = MessagesController.new |
|
28 | @controller = MessagesController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | User.current = nil |
|
31 | User.current = nil | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def test_show |
|
34 | def test_show | |
35 | get :show, :board_id => 1, :id => 1 |
|
35 | get :show, :board_id => 1, :id => 1 | |
36 | assert_response :success |
|
36 | assert_response :success | |
@@ -39,11 +39,11 class MessagesControllerTest < ActionController::TestCase | |||||
39 | assert_not_nil assigns(:project) |
|
39 | assert_not_nil assigns(:project) | |
40 | assert_not_nil assigns(:topic) |
|
40 | assert_not_nil assigns(:topic) | |
41 | end |
|
41 | end | |
42 |
|
42 | |||
43 | def test_show_with_pagination |
|
43 | def test_show_with_pagination | |
44 | message = Message.find(1) |
|
44 | message = Message.find(1) | |
45 | assert_difference 'Message.count', 30 do |
|
45 | assert_difference 'Message.count', 30 do | |
46 |
30.times do |
|
46 | 30.times do | |
47 | message.children << Message.new(:subject => 'Reply', :content => 'Reply body', :author_id => 2, :board_id => 1) |
|
47 | message.children << Message.new(:subject => 'Reply', :content => 'Reply body', :author_id => 2, :board_id => 1) | |
48 | end |
|
48 | end | |
49 | end |
|
49 | end | |
@@ -55,7 +55,7 class MessagesControllerTest < ActionController::TestCase | |||||
55 | assert !replies.include?(message.children.first(:order => 'id')) |
|
55 | assert !replies.include?(message.children.first(:order => 'id')) | |
56 | assert replies.include?(message.children.last(:order => 'id')) |
|
56 | assert replies.include?(message.children.last(:order => 'id')) | |
57 | end |
|
57 | end | |
58 |
|
58 | |||
59 | def test_show_with_reply_permission |
|
59 | def test_show_with_reply_permission | |
60 | @request.session[:user_id] = 2 |
|
60 | @request.session[:user_id] = 2 | |
61 | get :show, :board_id => 1, :id => 1 |
|
61 | get :show, :board_id => 1, :id => 1 | |
@@ -64,24 +64,24 class MessagesControllerTest < ActionController::TestCase | |||||
64 | assert_tag :div, :attributes => { :id => 'reply' }, |
|
64 | assert_tag :div, :attributes => { :id => 'reply' }, | |
65 | :descendant => { :tag => 'textarea', :attributes => { :id => 'message_content' } } |
|
65 | :descendant => { :tag => 'textarea', :attributes => { :id => 'message_content' } } | |
66 | end |
|
66 | end | |
67 |
|
67 | |||
68 | def test_show_message_not_found |
|
68 | def test_show_message_not_found | |
69 | get :show, :board_id => 1, :id => 99999 |
|
69 | get :show, :board_id => 1, :id => 99999 | |
70 | assert_response 404 |
|
70 | assert_response 404 | |
71 | end |
|
71 | end | |
72 |
|
72 | |||
73 | def test_get_new |
|
73 | def test_get_new | |
74 | @request.session[:user_id] = 2 |
|
74 | @request.session[:user_id] = 2 | |
75 | get :new, :board_id => 1 |
|
75 | get :new, :board_id => 1 | |
76 | assert_response :success |
|
76 | assert_response :success | |
77 |
assert_template 'new' |
|
77 | assert_template 'new' | |
78 | end |
|
78 | end | |
79 |
|
79 | |||
80 | def test_post_new |
|
80 | def test_post_new | |
81 | @request.session[:user_id] = 2 |
|
81 | @request.session[:user_id] = 2 | |
82 | ActionMailer::Base.deliveries.clear |
|
82 | ActionMailer::Base.deliveries.clear | |
83 | Setting.notified_events = ['message_posted'] |
|
83 | Setting.notified_events = ['message_posted'] | |
84 |
|
84 | |||
85 | post :new, :board_id => 1, |
|
85 | post :new, :board_id => 1, | |
86 | :message => { :subject => 'Test created message', |
|
86 | :message => { :subject => 'Test created message', | |
87 | :content => 'Message body'} |
|
87 | :content => 'Message body'} | |
@@ -101,14 +101,14 class MessagesControllerTest < ActionController::TestCase | |||||
101 | # project member |
|
101 | # project member | |
102 | assert mail.bcc.include?('dlopper@somenet.foo') |
|
102 | assert mail.bcc.include?('dlopper@somenet.foo') | |
103 | end |
|
103 | end | |
104 |
|
104 | |||
105 | def test_get_edit |
|
105 | def test_get_edit | |
106 | @request.session[:user_id] = 2 |
|
106 | @request.session[:user_id] = 2 | |
107 | get :edit, :board_id => 1, :id => 1 |
|
107 | get :edit, :board_id => 1, :id => 1 | |
108 | assert_response :success |
|
108 | assert_response :success | |
109 |
assert_template 'edit' |
|
109 | assert_template 'edit' | |
110 | end |
|
110 | end | |
111 |
|
111 | |||
112 | def test_post_edit |
|
112 | def test_post_edit | |
113 | @request.session[:user_id] = 2 |
|
113 | @request.session[:user_id] = 2 | |
114 | post :edit, :board_id => 1, :id => 1, |
|
114 | post :edit, :board_id => 1, :id => 1, | |
@@ -119,7 +119,7 class MessagesControllerTest < ActionController::TestCase | |||||
119 | assert_equal 'New subject', message.subject |
|
119 | assert_equal 'New subject', message.subject | |
120 | assert_equal 'New body', message.content |
|
120 | assert_equal 'New body', message.content | |
121 | end |
|
121 | end | |
122 |
|
122 | |||
123 | def test_reply |
|
123 | def test_reply | |
124 | @request.session[:user_id] = 2 |
|
124 | @request.session[:user_id] = 2 | |
125 | post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' } |
|
125 | post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' } | |
@@ -127,14 +127,14 class MessagesControllerTest < ActionController::TestCase | |||||
127 | assert_redirected_to "/boards/1/topics/1?r=#{reply.id}" |
|
127 | assert_redirected_to "/boards/1/topics/1?r=#{reply.id}" | |
128 | assert Message.find_by_subject('Test reply') |
|
128 | assert Message.find_by_subject('Test reply') | |
129 | end |
|
129 | end | |
130 |
|
130 | |||
131 | def test_destroy_topic |
|
131 | def test_destroy_topic | |
132 | @request.session[:user_id] = 2 |
|
132 | @request.session[:user_id] = 2 | |
133 | post :destroy, :board_id => 1, :id => 1 |
|
133 | post :destroy, :board_id => 1, :id => 1 | |
134 | assert_redirected_to '/projects/ecookbook/boards/1' |
|
134 | assert_redirected_to '/projects/ecookbook/boards/1' | |
135 | assert_nil Message.find_by_id(1) |
|
135 | assert_nil Message.find_by_id(1) | |
136 | end |
|
136 | end | |
137 |
|
137 | |||
138 | def test_quote |
|
138 | def test_quote | |
139 | @request.session[:user_id] = 2 |
|
139 | @request.session[:user_id] = 2 | |
140 | xhr :get, :quote, :board_id => 1, :id => 3 |
|
140 | xhr :get, :quote, :board_id => 1, :id => 3 |
General Comments 0
You need to be logged in to leave comments.
Login now