Added forums topics on the activity view (disabled by default).
[gitredmine.git] / test / test_helper.rb
blob542d4ce72478b930512cf117c2104c0359adbea7
1 # redMine - project management software
2 # Copyright (C) 2006  Jean-Philippe Lang
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
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
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 ENV["RAILS_ENV"] ||= "test"
19 require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
20 require 'test_help'
21 require File.expand_path(File.dirname(__FILE__) + '/helper_testcase')
23 class Test::Unit::TestCase
24   # Transactional fixtures accelerate your tests by wrapping each test method
25   # in a transaction that's rolled back on completion.  This ensures that the
26   # test database remains unchanged so your fixtures don't have to be reloaded
27   # between every test method.  Fewer database queries means faster tests.
28   #
29   # Read Mike Clark's excellent walkthrough at
30   #   http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
31   #
32   # Every Active Record database supports transactions except MyISAM tables
33   # in MySQL.  Turn off transactional fixtures in this case; however, if you
34   # don't care one way or the other, switching from MyISAM to InnoDB tables
35   # is recommended.
36   self.use_transactional_fixtures = true
38   # Instantiated fixtures are slow, but give you @david where otherwise you
39   # would need people(:david).  If you don't want to migrate your existing
40   # test cases which use the @david style and don't mind the speed hit (each
41   # instantiated fixtures translates to a database query per test method),
42   # then set this back to true.
43   self.use_instantiated_fixtures  = false
45   # Add more helper methods to be used by all tests here...
46   
47   def log_user(login, password)
48     get "/account/login"
49     assert_equal nil, session[:user_id]
50     assert_response :success
51     assert_template "account/login"
52     post "/account/login", :login => login, :password => password
53     assert_redirected_to "my/page"
54     assert_equal login, User.find(session[:user_id]).login
55   end
56 end
59 # ActionController::TestUploadedFile bug
60 # see http://dev.rubyonrails.org/ticket/4635
61 class String
62   def original_filename
63     "testfile.txt"
64   end
65   
66   def content_type
67     "text/plain"
68   end
69   
70   def read
71     self.to_s
72   end
73 end