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
2022-06-23 18:03:44 +03:00
require 'minitest/reporters'
2023-02-28 15:34:03 +03:00
Minitest :: Reporters . use! [ Minitest :: Reporters :: DefaultReporter . new , Minitest :: Reporters :: JUnitReporter . new ]
2022-06-23 18:03:44 +03:00
2023-02-26 13:27:15 +03:00
require File . expand_path " #{ File . dirname __FILE__ } /../../../test/test_helper "
require File . expand_path " #{ File . dirname __FILE__ } /global_test_helper "
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
2023-09-10 13:14:42 +03:00
Role . where ( id : [ 1 , 2 ] ) . find_each do | r |
2020-07-27 11:49:23 +03:00
r . permissions << :save_dashboards
r . save
end
2023-09-10 13:14:42 +03:00
Role . where ( id : [ 1 ] ) . find_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
2022-04-21 13:11:19 +03:00
r . permissions << :show_hidden_roles_in_memberbox
2016-10-19 14:30:14 +03:00
r . save
end
2023-09-10 13:14:42 +03:00
Project . where ( id : [ 1 , 2 ] ) . find_each do | project |
2024-08-27 10:30:58 +03:00
EnabledModule . create project : , name : 'issue_tracking'
2016-10-19 14:30:14 +03:00
end
end
2024-08-05 21:20:45 +03:00
2024-10-05 17:33:56 +03:00
def smiley_test_span ( text )
" <span class= \" additionals smiley a-icon smiley-smiley \" title= \" :) \" > #{ text } </span> "
end
def svg_test_icon
'<svg class="a-s18 a-svg-icon smiley" title=":)" aria-hidden="true">' \
'<use href="/plugin_assets/additionals/images/icons.svg#icon--smiley-smiley"></use></svg>'
end
2024-10-08 13:20:24 +03:00
# for tanuki_emoji 0.11.0 or newer
# NOTE: tanuki_emoji 0.11.0 can only be used, if Redmine 5.0 suppord dropped
# (depenceny for i18n version)
def emoji_heart_tag_new
2024-10-05 17:33:56 +03:00
'<additionals-emoji title="red heart" data-name="red_heart" data-unicode-version="6.0">❤️</additionals-emoji>'
2024-08-05 21:20:45 +03:00
end
2024-10-08 13:20:24 +03:00
def emoji_heart_tag
'<additionals-emoji title="heavy black heart" data-name="heart" data-unicode-version="1.1">❤</additionals-emoji>'
end
2016-10-19 14:30:14 +03:00
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
2022-01-13 20:03:29 +03:00
include Additionals :: TestHelper
extend PluginFixturesLoader
end
class ApiTest < Redmine :: ApiTest :: Base
include Additionals :: TestHelper
2020-07-27 11:49:23 +03:00
extend PluginFixturesLoader
2018-07-23 19:17:04 +03:00
end
end