##// END OF EJS Templates
Fixed that magic links to existing attachments are not converted when previewing issue notes....
Fixed that magic links to existing attachments are not converted when previewing issue notes. git-svn-id: http://svn.redmine.org/redmine/trunk@12476 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r11216:d1244b31a4c2
r12201:58a63c49c49b
Show More
messages_controller_test.rb
217 lines | 7.1 KiB | text/x-ruby | RubyLexer
/ test / functional / messages_controller_test.rb
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473 # Redmine - project management software
Jean-Philippe Lang
Copyright for 2013 (#12788)....
r10939 # Copyright (C) 2006-2013 Jean-Philippe Lang
Jean-Philippe Lang
Forums enhancements:...
r913 #
# 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.
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473 #
Jean-Philippe Lang
Forums enhancements:...
r913 # 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.
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473 #
Jean-Philippe Lang
Forums enhancements:...
r913 # 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
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
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473
Jean-Philippe Lang
Forums enhancements:...
r913 def setup
User.current = nil
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473
Jean-Philippe Lang
Forums enhancements:...
r913 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 test for r7961 fix (#9672)....
r7842
def test_show_should_contain_reply_field_tags_for_quoting
@request.session[:user_id] = 2
get :show, :board_id => 1, :id => 1
assert_response :success
# tags required by MessagesController#quote
assert_tag 'input', :attributes => {:id => 'message_subject'}
assert_tag 'textarea', :attributes => {:id => 'message_content'}
assert_tag 'div', :attributes => {:id => 'reply'}
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473
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
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473 30.times do
Jean-Philippe Lang
Adds pagination to forum messages (#4664)....
r3259 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
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473
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
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473
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
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473
Jean-Philippe Lang
Fixed that requesting a message from an invalid forum should respond with 404 (#13232)....
r11216 def test_show_message_from_invalid_board_should_respond_with_404
get :show, :board_id => 999, :id => 1
assert_response 404
end
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 def test_get_new
@request.session[:user_id] = 2
get :new, :board_id => 1
assert_response :success
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473 assert_template 'new'
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 end
Jean-Philippe Lang
Code cleanup....
r10758
def test_get_new_with_invalid_board
@request.session[:user_id] = 2
get :new, :board_id => 99
assert_response 404
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 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
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473
Jean-Philippe Lang
Tests should not change settings....
r9766 with_settings :notified_events => %w(message_posted) do
post :new, :board_id => 1,
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 :message => { :subject => 'Test created message',
:content => 'Message body'}
Jean-Philippe Lang
Tests should not change settings....
r9766 end
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 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
Jean-Philippe Lang
Do not do assertions on mail class....
r8871 assert_not_nil 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
Adds helpers for testing email body....
r8966 assert_mail_body_match 'Message body', mail
Jean-Philippe Lang
Notify project members when a message is posted if they want to receive notifications for everything on the project (#1079)....
r1353 # 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
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 def test_get_edit
@request.session[:user_id] = 2
get :edit, :board_id => 1, :id => 1
assert_response :success
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473 assert_template 'edit'
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 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
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473
Jean-Philippe Lang
Fixed: Unable to change locked, sticky flags and board when editing a message (#10564)....
r9216 def test_post_edit_sticky_and_locked
@request.session[:user_id] = 2
post :edit, :board_id => 1, :id => 1,
:message => { :subject => 'New subject',
:content => 'New body',
:locked => '1',
:sticky => '1'}
assert_redirected_to '/boards/1/topics/1'
message = Message.find(1)
assert_equal true, message.sticky?
assert_equal true, message.locked?
end
def test_post_edit_should_allow_to_change_board
@request.session[:user_id] = 2
post :edit, :board_id => 1, :id => 1,
:message => { :subject => 'New subject',
:content => 'New body',
:board_id => 2}
assert_redirected_to '/boards/2/topics/1'
message = Message.find(1)
assert_equal Board.find(2), message.board
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
Replaces find(:first) calls....
r10701 reply = Message.order('id DESC').first
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
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 def test_destroy_topic
@request.session[:user_id] = 2
Jean-Philippe Lang
More function tests for MessagesController....
r9048 assert_difference 'Message.count', -3 do
post :destroy, :board_id => 1, :id => 1
end
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
Toshi MARUYAMA
remove trailing white-spaces from test/functional/messages_controller_test.rb....
r6473
Jean-Philippe Lang
More function tests for MessagesController....
r9048 def test_destroy_reply
@request.session[:user_id] = 2
assert_difference 'Message.count', -1 do
post :destroy, :board_id => 1, :id => 2
end
assert_redirected_to '/boards/1/topics/1?r=2'
assert_nil Message.find_by_id(2)
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
Jean-Philippe Lang
Removes RJS from MessagesController....
r9870 assert_equal 'text/javascript', response.content_type
assert_template 'quote'
assert_include 'RE: First post', response.body
assert_include '> An other reply', response.body
Jean-Philippe Lang
Adds posts quoting functionality (#1825)....
r1771 end
Jean-Philippe Lang
More function tests for MessagesController....
r9048
def test_preview_new
@request.session[:user_id] = 2
post :preview,
:board_id => 1,
:message => {:subject => "", :content => "Previewed text"}
assert_response :success
assert_template 'common/_preview'
end
def test_preview_edit
@request.session[:user_id] = 2
post :preview,
:id => 4,
:board_id => 1,
:message => {:subject => "", :content => "Previewed text"}
assert_response :success
assert_template 'common/_preview'
end
Jean-Philippe Lang
Forums enhancements:...
r913 end