additionals/test/test_helper.rb
2020-07-28 19:38:53 +02:00

60 lines
1.4 KiB
Ruby
Executable File

$VERBOSE = nil
if ENV['JENKINS']
require 'simplecov'
SimpleCov.start :rails do
add_filter 'init.rb'
root File.expand_path(File.dirname(__FILE__) + '/..')
end
end
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
require File.expand_path(File.dirname(__FILE__) + '/global_test_helper')
module Additionals
module TestHelper
include Additionals::GlobalTestHelper
def prepare_tests
Role.where(id: [1, 2]).each do |r|
r.permissions << :save_dashboards
r.save
end
Role.where(id: [1]).each do |r|
r.permissions << :manage_shared_dashboards
r.permissions << :set_system_dashboards
r.save
end
Project.where(id: [1, 2]).each do |project|
EnabledModule.create(project: project, name: 'issue_tracking')
end
end
end
module PluginFixturesLoader
def fixtures(*table_names)
dir = File.dirname(__FILE__) + '/fixtures/'
table_names.each do |x|
ActiveRecord::FixtureSet.create_fixtures(dir, x) if File.exist?("#{dir}/#{x}.yml")
end
super(table_names)
end
end
class ControllerTest < Redmine::ControllerTest
include Additionals::TestHelper
extend PluginFixturesLoader
end
class TestCase < ActiveSupport::TestCase
include Additionals::TestHelper
extend PluginFixturesLoader
end
class IntegrationTest < Redmine::IntegrationTest
extend PluginFixturesLoader
end
end