2018-05-21 13:43:42 +03:00
$VERBOSE = nil
2017-09-30 07:31:45 +03:00
unless ENV [ 'SKIP_COVERAGE' ]
require 'simplecov'
require 'simplecov-rcov'
2017-06-28 16:21:00 +03:00
2017-09-30 07:31:45 +03:00
SimpleCov . formatters = SimpleCov :: Formatter :: MultiFormatter [ SimpleCov :: Formatter :: HTMLFormatter ,
SimpleCov :: Formatter :: RcovFormatter ]
2017-06-28 16:21:00 +03:00
2017-09-30 07:31:45 +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' )
2018-07-23 18:26:52 +03:00
if defined? ( RSpec )
RSpec . configure do | config |
config . mock_with :mocha
config . example_status_persistence_file_path = Rails . root . join ( 'tmp' , 'additionals_rspec_examples.txt' )
end
end
2017-06-07 20:23:20 +03:00
module Additionals
2018-07-15 19:02:52 +03:00
module TestHelper
2018-07-15 20:08:39 +03:00
def with_additionals_settings ( settings , & _block )
2018-07-23 18:49:35 +03:00
Setting . plugin_additionals = ActionController :: Parameters . new ( Setting . plugin_additionals . merge ( settings ) )
2018-07-15 20:08:39 +03:00
yield
ensure
2018-07-23 18:49:35 +03:00
Setting . plugin_additionals = Setting . plugin_additionals
2018-07-15 19:02:52 +03:00
end
end
class ControllerTest < Redmine :: ControllerTest
2018-07-15 14:14:41 +03:00
end
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 = { } )
2017-10-31 12:14:59 +03:00
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
2018-07-15 19:02:52 +03:00
include Additionals :: TestHelper