test_helper.rb 1.85 KB
Newer Older
bfs15's avatar
bfs15 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec.  If not, see <http://www.gnu.org/licenses/>.

20 21 22
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
23
require 'minitest/mock'
24
require 'minitest/reporters'
25

26 27 28
# disable public activity gem for testing purpouses
require 'public_activity/testing'

29 30 31 32
class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

33 34 35
  # load seeds
  # Rails.application.load_seed

36
  # Add more helper methods to be used by all tests here...
37 38 39 40 41

  def assert_count(expected, actual = 0)
    assert_equal expected.to_i, actual.count
  end

42 43
  # authenticate requests using devise_token_auth
  def auth_request(user)
44
    auth_application
45
    sign_in user
Mateus Rambo Strey's avatar
Mateus Rambo Strey committed
46
    @request.headers.merge!(user.create_new_auth_token)
47 48
  end

49 50 51 52
  def auth_application
    @request.headers['PortalMEC-AppID'] = applications(:test_app).application_id
  end

53 54 55 56
  def mock
    MiniTest::Mock.new
  end

57 58 59 60
  # config.after :all do
  #   ActiveRecord::Base.subclasses.each(&:delete_all)
  # end

61
  Minitest::Reporters.use!
Mateus Rambo Strey's avatar
Mateus Rambo Strey committed
62 63

  PublicActivity.enabled = false
64
end