2015-02-15 12:17:16 +03:00
# Load the Redmine helper
2015-10-09 16:04:38 +03:00
2015-02-15 12:17:16 +03:00
require File . expand_path ( File . dirname ( __FILE__ ) + '/../../../test/test_helper' )
2015-10-08 18:54:56 +03:00
2015-10-09 20:23:52 +03:00
# Redmine Tweaks helper class for tests
2015-10-08 18:54:56 +03:00
class RedmineTweaks :: 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 { | n | n . 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
2015-10-09 20:23:52 +03:00
def self . arrays_equal? ( a1 , a2 )
2015-10-08 18:54:56 +03:00
( a1 - a2 ) - ( a2 - a1 ) == [ ]
end
2015-10-09 20:23:52 +03:00
def self . create_fixtures ( fixtures_directory , table_names , _class_names = { } )
2015-10-08 18:54:56 +03:00
if ActiveRecord :: VERSION :: MAJOR > = 4
2015-10-09 20:23:52 +03:00
ActiveRecord :: FixtureSet . create_fixtures ( fixtures_directory , table_names , _class_names = { } )
2015-10-08 18:54:56 +03:00
else
2015-10-09 20:23:52 +03:00
ActiveRecord :: Fixtures . create_fixtures ( fixtures_directory , table_names , _class_names = { } )
2015-10-08 18:54:56 +03:00
end
end
2015-10-09 20:23:52 +03:00
2015-10-08 18:54:56 +03:00
def self . prepare
2015-10-09 20:23:52 +03:00
Role . where ( id : [ 1 , 2 ] ) . each do | r |
2015-10-08 18:54:56 +03:00
r . permissions << :view_issues
r . save
end
2015-10-09 20:23:52 +03:00
Project . where ( id : [ 1 , 2 ] ) . each do | project |
EnabledModule . create ( project : project , name : 'issue_tracking' )
2015-10-08 18:54:56 +03:00
end
end
2015-10-09 20:23:52 +03:00
end