##// END OF EJS Templates
Fixed: Error deleting issue with grandchild (#8880)....
Fixed: Error deleting issue with grandchild (#8880). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6311 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r4395:17f86d964fe0
r6191:9957883c4ddf
Show More
messages_controller_test.rb
144 lines | 4.9 KiB | text/x-ruby | RubyLexer
/ test / functional / messages_controller_test.rb
Jean-Philippe Lang
Forums enhancements:...
r913 # redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Jean-Baptiste Barth
Use absolute paths in test/**/* requires for Ruby 1.9.2 compatibility. #4050...
r4395 require File.expand_path('../../test_helper', __FILE__)
Jean-Philippe Lang
Forums enhancements:...
r913 require 'messages_controller'
# Re-raise errors caught by the controller.
class MessagesController; def rescue_action(e) raise e end; end
Eric Davis
Upgraded to Rails 2.3.4 (#3597)...
r2773 class MessagesControllerTest < ActionController::TestCase
Jean-Philippe Lang
Allows multiple roles on the same project (#706). Prerequisite for user groups feature....
r2627 fixtures :projects, :users, :members, :member_roles, :roles, :boards, :messages, :enabled_modules
Jean-Philippe Lang
Forums enhancements:...
r913
def setup
@controller = MessagesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
def test_show
get :show, :board_id => 1, :id => 1
assert_response :success
assert_template 'show'
assert_not_nil assigns(:board)
assert_not_nil assigns(:project)
assert_not_nil assigns(:topic)
end
Jean-Philippe Lang
Adds pagination to forum messages (#4664)....
r3259 def test_show_with_pagination
message = Message.find(1)
assert_difference 'Message.count', 30 do
30.times do
message.children << Message.new(:subject => 'Reply', :content => 'Reply body', :author_id => 2, :board_id => 1)
end
end
get :show, :board_id => 1, :id => 1, :r => message.children.last(:order => 'id').id
assert_response :success
assert_template 'show'
replies = assigns(:replies)
assert_not_nil replies
assert !replies.include?(message.children.first(:order => 'id'))
assert replies.include?(message.children.last(:order => 'id'))
end
Jean-Philippe Lang
Adds posts quoting functionality (#1825)....
r1771 def test_show_with_reply_permission
@request.session[:user_id] = 2
get :show, :board_id => 1, :id => 1
assert_response :success
assert_template 'show'
assert_tag :div, :attributes => { :id => 'reply' },
:descendant => { :tag => 'textarea', :attributes => { :id => 'message_content' } }
end
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 def test_show_message_not_found
get :show, :board_id => 1, :id => 99999
assert_response 404
end
def test_get_new
@request.session[:user_id] = 2
get :new, :board_id => 1
assert_response :success
assert_template 'new'
end
def test_post_new
@request.session[:user_id] = 2
Jean-Philippe Lang
Notify project members when a message is posted if they want to receive notifications for everything on the project (#1079)....
r1353 ActionMailer::Base.deliveries.clear
Jean-Philippe Lang
Fixes functional test failures....
r2185 Setting.notified_events = ['message_posted']
Jean-Philippe Lang
Notify project members when a message is posted if they want to receive notifications for everything on the project (#1079)....
r1353
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 post :new, :board_id => 1,
:message => { :subject => 'Test created message',
:content => 'Message body'}
message = Message.find_by_subject('Test created message')
assert_not_nil message
Jean-Philippe Lang
Adds leading slash to all assert_redirected_to arguments (#6887)....
r4293 assert_redirected_to "/boards/1/topics/#{message.to_param}"
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 assert_equal 'Message body', message.content
assert_equal 2, message.author_id
assert_equal 1, message.board_id
Jean-Philippe Lang
Notify project members when a message is posted if they want to receive notifications for everything on the project (#1079)....
r1353
mail = ActionMailer::Base.deliveries.last
assert_kind_of TMail::Mail, mail
Jean-Philippe Lang
Fixes a test that was broken by r2294....
r2301 assert_equal "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] Test created message", mail.subject
Jean-Philippe Lang
Notify project members when a message is posted if they want to receive notifications for everything on the project (#1079)....
r1353 assert mail.body.include?('Message body')
# author
assert mail.bcc.include?('jsmith@somenet.foo')
# project member
assert mail.bcc.include?('dlopper@somenet.foo')
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 end
def test_get_edit
@request.session[:user_id] = 2
get :edit, :board_id => 1, :id => 1
assert_response :success
assert_template 'edit'
end
def test_post_edit
@request.session[:user_id] = 2
post :edit, :board_id => 1, :id => 1,
:message => { :subject => 'New subject',
:content => 'New body'}
Jean-Philippe Lang
Adds leading slash to all assert_redirected_to arguments (#6887)....
r4293 assert_redirected_to '/boards/1/topics/1'
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 message = Message.find(1)
assert_equal 'New subject', message.subject
assert_equal 'New body', message.content
end
Jean-Philippe Lang
Forums enhancements:...
r913 def test_reply
@request.session[:user_id] = 2
post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
Jean-Philippe Lang
Adds pagination to forum messages (#4664)....
r3259 reply = Message.find(:first, :order => 'id DESC')
Jean-Philippe Lang
Adds leading slash to all assert_redirected_to arguments (#6887)....
r4293 assert_redirected_to "/boards/1/topics/1?r=#{reply.id}"
Jean-Philippe Lang
Forums enhancements:...
r913 assert Message.find_by_subject('Test reply')
end
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974
def test_destroy_topic
@request.session[:user_id] = 2
post :destroy, :board_id => 1, :id => 1
Jean-Philippe Lang
Adds leading slash to all assert_redirected_to arguments (#6887)....
r4293 assert_redirected_to '/projects/ecookbook/boards/1'
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 assert_nil Message.find_by_id(1)
end
Jean-Philippe Lang
Adds posts quoting functionality (#1825)....
r1771
def test_quote
@request.session[:user_id] = 2
xhr :get, :quote, :board_id => 1, :id => 3
assert_response :success
assert_select_rjs :show, 'reply'
end
Jean-Philippe Lang
Forums enhancements:...
r913 end