Mercurial > hg > soundsoftware-site
comparison test/functional/messages_controller_test.rb @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | 5f33065ddc4b |
children | 3e4c3460b6ca |
comparison
equal
deleted
inserted
replaced
929:5f33065ddc4b | 1115:433d4f72a19b |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2011 Jean-Philippe Lang | 2 # Copyright (C) 2006-2012 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. |
89 end | 89 end |
90 | 90 |
91 def test_post_new | 91 def test_post_new |
92 @request.session[:user_id] = 2 | 92 @request.session[:user_id] = 2 |
93 ActionMailer::Base.deliveries.clear | 93 ActionMailer::Base.deliveries.clear |
94 Setting.notified_events = ['message_posted'] | 94 |
95 | 95 with_settings :notified_events => %w(message_posted) do |
96 post :new, :board_id => 1, | 96 post :new, :board_id => 1, |
97 :message => { :subject => 'Test created message', | 97 :message => { :subject => 'Test created message', |
98 :content => 'Message body'} | 98 :content => 'Message body'} |
99 end | |
99 message = Message.find_by_subject('Test created message') | 100 message = Message.find_by_subject('Test created message') |
100 assert_not_nil message | 101 assert_not_nil message |
101 assert_redirected_to "/boards/1/topics/#{message.to_param}" | 102 assert_redirected_to "/boards/1/topics/#{message.to_param}" |
102 assert_equal 'Message body', message.content | 103 assert_equal 'Message body', message.content |
103 assert_equal 2, message.author_id | 104 assert_equal 2, message.author_id |
104 assert_equal 1, message.board_id | 105 assert_equal 1, message.board_id |
105 | 106 |
106 mail = ActionMailer::Base.deliveries.last | 107 mail = ActionMailer::Base.deliveries.last |
107 assert_kind_of TMail::Mail, mail | 108 assert_not_nil mail |
108 assert_equal "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] Test created message", mail.subject | 109 assert_equal "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] Test created message", mail.subject |
109 assert mail.body.include?('Message body') | 110 assert_mail_body_match 'Message body', mail |
110 # author | 111 # author |
111 assert mail.bcc.include?('jsmith@somenet.foo') | 112 assert mail.bcc.include?('jsmith@somenet.foo') |
112 # project member | 113 # project member |
113 assert mail.bcc.include?('dlopper@somenet.foo') | 114 assert mail.bcc.include?('dlopper@somenet.foo') |
114 end | 115 end |
163 assert Message.find_by_subject('Test reply') | 164 assert Message.find_by_subject('Test reply') |
164 end | 165 end |
165 | 166 |
166 def test_destroy_topic | 167 def test_destroy_topic |
167 @request.session[:user_id] = 2 | 168 @request.session[:user_id] = 2 |
168 post :destroy, :board_id => 1, :id => 1 | 169 assert_difference 'Message.count', -3 do |
170 post :destroy, :board_id => 1, :id => 1 | |
171 end | |
169 assert_redirected_to '/projects/ecookbook/boards/1' | 172 assert_redirected_to '/projects/ecookbook/boards/1' |
170 assert_nil Message.find_by_id(1) | 173 assert_nil Message.find_by_id(1) |
171 end | 174 end |
172 | 175 |
176 def test_destroy_reply | |
177 @request.session[:user_id] = 2 | |
178 assert_difference 'Message.count', -1 do | |
179 post :destroy, :board_id => 1, :id => 2 | |
180 end | |
181 assert_redirected_to '/boards/1/topics/1?r=2' | |
182 assert_nil Message.find_by_id(2) | |
183 end | |
184 | |
173 def test_quote | 185 def test_quote |
174 @request.session[:user_id] = 2 | 186 @request.session[:user_id] = 2 |
175 xhr :get, :quote, :board_id => 1, :id => 3 | 187 xhr :get, :quote, :board_id => 1, :id => 3 |
176 assert_response :success | 188 assert_response :success |
177 assert_select_rjs :show, 'reply' | 189 assert_equal 'text/javascript', response.content_type |
190 assert_template 'quote' | |
191 assert_include 'RE: First post', response.body | |
192 assert_include '> An other reply', response.body | |
193 end | |
194 | |
195 def test_preview_new | |
196 @request.session[:user_id] = 2 | |
197 post :preview, | |
198 :board_id => 1, | |
199 :message => {:subject => "", :content => "Previewed text"} | |
200 assert_response :success | |
201 assert_template 'common/_preview' | |
202 end | |
203 | |
204 def test_preview_edit | |
205 @request.session[:user_id] = 2 | |
206 post :preview, | |
207 :id => 4, | |
208 :board_id => 1, | |
209 :message => {:subject => "", :content => "Previewed text"} | |
210 assert_response :success | |
211 assert_template 'common/_preview' | |
178 end | 212 end |
179 end | 213 end |