merged initial codebase
[smr.git] / gui / test / test_helper.rb
blob312b7893e1534ac5365a014ad926e8dc9bdcab24
2 # This file is part of SMR.
4 # SMR is free software: you can redistribute it and/or modify it under the
5 # terms of the GNU General Public License as published by the Free Software
6 # Foundation, either version 3 of the License, or (at your option) any later
7 # version.
9 # SMR is distributed in the hope that it will be useful, but WITHOUT ANY
10 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License along with
14 # SMR.  If not, see <http://www.gnu.org/licenses/>.
16 ENV["RAILS_ENV"] = "test"
17 include ActionDispatch::TestProcess
18 require File.expand_path('../../config/environment', __FILE__)
19 require 'rails/test_help'
21 class ActiveSupport::TestCase
22     # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
23     #
24     # Note: You'll currently still have to declare fixtures explicitly in integration tests
25     # -- they do not yet inherit this setting
26     fixtures :all
27     
28     # Add more helper methods to be used by all tests here...
30     ##
31     # log user into Smr
32     #
33     # Success should redirect us to '/' showing Assets overview as its the
34     # default page.
35     #
36     # See ActionDispatch::IntegrationTest documentation in case multiple
37     # parallel sessions are required at some point.
38     def smr_login(loginname, password)
39         post sessions_path, :login=>loginname, :password=>password
40         assert_response :redirect
41         follow_redirect!
42         assert_response :success
44         assert_equal root_path, path
45         assert_not_nil assigns(:current_user), 'login failed, no current_user'
46         assert_not_nil assigns(:assets), 'no Assets listed after login'
47         assert_not_nil assigns(:open_positions), 'no Open Positions listed after login'
48     
49         # see we are logged in as the one we think we are and got a token
50         current_user = assigns(:current_user)
51         assert_equal current_user.login, loginname
52         assert current_user.password_auth_token
53     end
54 end