2021-04-18 14:34:55 +03:00
# frozen_string_literal: true
2018-05-21 13:43:42 +03:00
2021-05-06 11:50:25 +03:00
if ENV [ 'COVERAGE' ]
2017-09-30 07:31:45 +03:00
require 'simplecov'
SimpleCov . start :rails do
add_filter 'init.rb'
2020-08-08 19:44:40 +03:00
root File . expand_path " #{ File . dirname __FILE__ } /.. "
2017-09-30 07:31:45 +03:00
end
2017-06-28 16:21:00 +03:00
end
2020-08-08 19:44:40 +03:00
require File . expand_path " #{ File . dirname __FILE__ } /../../../test/test_helper "
require File . expand_path " #{ File . dirname __FILE__ } /global_test_helper "
2020-11-04 21:29:52 +03:00
require File . expand_path " #{ File . dirname __FILE__ } /crud_controller_base "
2017-06-28 17:19:58 +03:00
2017-06-07 20:23:20 +03:00
module Additionals
2018-07-15 19:02:52 +03:00
module TestHelper
2018-07-24 17:28:23 +03:00
include Additionals :: GlobalTestHelper
2016-10-19 14:30:14 +03:00
2018-07-23 19:17:04 +03:00
def prepare_tests
2016-10-19 14:30:14 +03:00
Role . where ( id : [ 1 , 2 ] ) . each do | r |
2020-07-27 11:49:23 +03:00
r . permissions << :save_dashboards
r . save
end
Role . where ( id : [ 1 ] ) . each do | r |
2020-08-07 19:10:18 +03:00
r . permissions << :share_dashboards
2020-07-27 11:49:23 +03:00
r . permissions << :set_system_dashboards
2016-10-19 14:30:14 +03:00
r . save
end
Project . where ( id : [ 1 , 2 ] ) . each do | project |
2020-08-06 09:18:30 +03:00
EnabledModule . create project : project , name : 'issue_tracking'
2016-10-19 14:30:14 +03:00
end
end
end
2018-07-15 19:02:52 +03:00
2020-07-27 11:49:23 +03:00
module PluginFixturesLoader
def fixtures ( * table_names )
2020-08-08 19:44:40 +03:00
dir = " #{ File . dirname __FILE__ } /fixtures/ "
2020-07-27 11:49:23 +03:00
table_names . each do | x |
2021-04-18 14:34:55 +03:00
ActiveRecord :: FixtureSet . create_fixtures dir , x if File . exist? " #{ dir } / #{ x } .yml "
2020-07-27 11:49:23 +03:00
end
2021-04-18 14:34:55 +03:00
super table_names
2020-07-27 11:49:23 +03:00
end
end
2018-07-23 19:17:04 +03:00
class ControllerTest < Redmine :: ControllerTest
include Additionals :: TestHelper
2020-07-27 11:49:23 +03:00
extend PluginFixturesLoader
2018-07-23 19:17:04 +03:00
end
class TestCase < ActiveSupport :: TestCase
include Additionals :: TestHelper
2020-07-27 11:49:23 +03:00
extend PluginFixturesLoader
end
class IntegrationTest < Redmine :: IntegrationTest
extend PluginFixturesLoader
2018-07-23 19:17:04 +03:00
end
end