##// END OF EJS Templates
Speeds up rendering of the project list for users who belong to hundreds of projects....
Speeds up rendering of the project list for users who belong to hundreds of projects. git-svn-id: http://svn.redmine.org/redmine/trunk@16123 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r15333:bb5ccb870ce3
r15741:f8df935dcada
Show More
messages_controller_test.rb
219 lines | 7.0 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
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 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
Jean-Philippe Lang
Adds our own class for controller tests....
r15279 class MessagesControllerTest < Redmine::ControllerTest
Jean-Philippe Lang
"I don't want to be notified of changes that I make myself" as Default for all User (#14574)....
r14906 fixtures :projects, :users, :email_addresses, :user_preferences, :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
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15333
assert_select 'h2', :text => 'First post'
Jean-Philippe Lang
Forums enhancements:...
r913 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
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'input#message_subject'
assert_select 'textarea#message_content'
assert_select 'div#reply'
Jean-Philippe Lang
Adds test for r7961 fix (#9672)....
r7842 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
Toshi MARUYAMA
code format cleanup MessagesControllerTest...
r12348 message.children << Message.new(:subject => 'Reply',
:content => 'Reply body',
:author_id => 2,
:board_id => 1)
Jean-Philippe Lang
Adds pagination to forum messages (#4664)....
r3259 end
end
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15333 reply_ids = message.children.map(&:id).sort
get :show, :board_id => 1, :id => 1, :r => reply_ids.last
Jean-Philippe Lang
Adds pagination to forum messages (#4664)....
r3259 assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15333
assert_select 'a[href=?]', "/boards/1/topics/1?r=#{reply_ids.last}#message-#{reply_ids.last}"
assert_select 'a[href=?]', "/boards/1/topics/1?r=#{reply_ids.first}#message-#{reply_ids.first}", 0
Jean-Philippe Lang
Adds pagination to forum messages (#4664)....
r3259 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
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15333
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'div#reply textarea#message_content'
Jean-Philippe Lang
Adds posts quoting functionality (#1825)....
r1771 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
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15333
assert_select 'input[name=?]', 'message[subject]'
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
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15333
assert_select 'input[name=?][value=?]', 'message[subject]', 'First post'
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
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15333
Jean-Philippe Lang
Removes RJS from MessagesController....
r9870 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
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15333 assert_include 'Previewed text', response.body
Jean-Philippe Lang
More function tests for MessagesController....
r9048 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
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15333 assert_include 'Previewed text', response.body
Jean-Philippe Lang
More function tests for MessagesController....
r9048 end
Jean-Philippe Lang
Forums enhancements:...
r913 end