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
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.
24 # Note: You'll currently still have to declare fixtures explicitly in integration tests
25 # -- they do not yet inherit this setting
29 # seed the database, call in tests that rely on seed data
31 assert Rails.application.load_seed, 'db:seed failed!'
34 # Add more helper methods to be used by all tests here...
39 # Success should redirect us to '/' showing Assets overview as its the
42 # See ActionDispatch::IntegrationTest documentation in case multiple
43 # parallel sessions are required at some point.
44 def smr_login(loginname, password)
45 post sessions_path, :login=>loginname, :password=>password
46 assert_response :redirect
48 assert_response :success
50 assert_equal root_path, path
51 assert_not_nil assigns(:current_user), 'login failed, no current_user'
52 assert_not_nil assigns(:assets), 'no Assets listed after login'
53 assert_not_nil assigns(:open_positions), 'no Open Positions listed after login'
55 # see we are logged in as the one we think we are and got a token
56 current_user = assigns(:current_user)
57 assert_equal current_user.login, loginname
58 assert current_user.password_auth_token
62 # evaluates SMR_ONLINE_TEST environment variable.
64 # - true => run tests that need internet connectivity
65 # - false / unset => skip such tests
67 ENV['SMR_ONLINE_TEST'] == 'true' ? true : false