additionals/test/test_helper.rb

58 lines
1.8 KiB
Ruby
Raw Normal View History

2018-05-21 13:43:42 +03:00
$VERBOSE = nil
unless ENV['SKIP_COVERAGE']
require 'simplecov'
require 'simplecov-rcov'
2017-06-28 16:21:00 +03:00
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter[SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::RcovFormatter]
2017-06-28 16:21:00 +03:00
SimpleCov.start :rails do
add_filter 'init.rb'
root File.expand_path(File.dirname(__FILE__) + '/..')
end
2017-06-28 16:21:00 +03:00
end
2017-06-28 17:19:58 +03:00
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
# Additionals helper class for tests
module Additionals
2016-10-19 14:30:14 +03:00
class TestCase
include ActionDispatch::TestProcess
def self.plugin_fixtures(plugin, *fixture_names)
plugin_fixture_path = "#{Redmine::Plugin.find(plugin).directory}/test/fixtures"
if fixture_names.first == :all
fixture_names = Dir["#{plugin_fixture_path}/**/*.{yml}"]
fixture_names.map! { |f| f[(plugin_fixture_path.size + 1)..-5] }
else
fixture_names = fixture_names.flatten.map(&:to_s)
end
ActiveRecord::Fixtures.create_fixtures(plugin_fixture_path, fixture_names)
end
def uploaded_test_file(name, mime)
ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime, true)
end
2018-03-05 12:29:57 +03:00
def self.arrays_equal?(value1, value2)
(value1 - value2) - (value2 - value1) == []
2016-10-19 14:30:14 +03:00
end
def self.create_fixtures(fixtures_directory, table_names, _class_names = {})
ActiveRecord::FixtureSet.create_fixtures(fixtures_directory, table_names, _class_names = {})
2016-10-19 14:30:14 +03:00
end
def self.prepare
Role.where(id: [1, 2]).each do |r|
r.permissions << :view_issues
r.save
end
Project.where(id: [1, 2]).each do |project|
EnabledModule.create(project: project, name: 'issue_tracking')
end
end
end
end