Skip to content

Commit

Permalink
Use same fixtures for all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermeindl committed Dec 10, 2024
1 parent 163f22a commit 9ded1cb
Show file tree
Hide file tree
Showing 35 changed files with 66 additions and 380 deletions.
10 changes: 0 additions & 10 deletions test/functional/account_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@
require File.expand_path '../../test_helper', __FILE__

class AccountControllerTest < Additionals::ControllerTest
fixtures :users, :groups_users, :email_addresses, :user_preferences,
:roles, :members, :member_roles,
:issues, :issue_statuses, :issue_relations,
:issues, :issue_statuses, :issue_categories,
:versions, :trackers,
:projects, :projects_trackers, :enabled_modules,
:enumerations

fixtures :hrm_user_types, :hrm_working_calendars if AdditionalsPlugin.active_hrm?

def setup
Setting.default_language = 'en'
User.current = nil
Expand Down
25 changes: 0 additions & 25 deletions test/functional/additionals_assign_to_me_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,6 @@
require File.expand_path '../../test_helper', __FILE__

class AdditionalsAssignToMeControllerTest < Additionals::ControllerTest
fixtures :projects,
:users, :email_addresses, :user_preferences,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:issue_relations,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries

test 'assign issue to user' do
session[:user_id] = 2
assert_difference 'Journal.count' do
Expand Down
25 changes: 0 additions & 25 deletions test/functional/additionals_change_status_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,6 @@
require File.expand_path '../../test_helper', __FILE__

class AdditionalsChangeStatusControllerTest < Additionals::ControllerTest
fixtures :projects,
:users, :email_addresses, :user_preferences,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:issue_relations,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries

test 'assign new status to issue' do
session[:user_id] = 2
assert_difference 'Journal.count' do
Expand Down
7 changes: 0 additions & 7 deletions test/functional/additionals_macros_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
require File.expand_path '../../test_helper', __FILE__

class AdditionalsMacrosControllerTest < Additionals::ControllerTest
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:enabled_modules

def setup
prepare_tests
end
Expand Down
2 changes: 0 additions & 2 deletions test/functional/admin_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
require File.expand_path '../../test_helper', __FILE__

class AdminControllerTest < Additionals::ControllerTest
fixtures :users, :email_addresses, :roles

def setup
User.current = nil
@request.session[:user_id] = 1
Expand Down
6 changes: 0 additions & 6 deletions test/functional/auto_completes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
require File.expand_path '../../test_helper', __FILE__

class AutoCompletesControllerTest < Additionals::ControllerTest
fixtures :projects, :email_addresses,
:enumerations, :users, :groups_users,
:roles,
:members, :member_roles,
:enabled_modules

def setup
prepare_tests
Setting.default_language = 'en'
Expand Down
16 changes: 0 additions & 16 deletions test/functional/dashboard_async_blocks_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@
require File.expand_path '../../test_helper', __FILE__

class DashboardAsyncBlocksControllerTest < Additionals::ControllerTest
fixtures :users, :email_addresses, :roles,
:enumerations,
:projects, :projects_trackers, :enabled_modules,
:members, :member_roles,
:issues, :issue_statuses, :issue_categories, :issue_relations,
:versions,
:trackers,
:workflows,
:custom_fields, :custom_values, :custom_fields_projects, :custom_fields_trackers,
:time_entries,
:watchers,
:journals, :journal_details,
:repositories, :changesets,
:queries,
:dashboards, :dashboard_roles

include Redmine::I18n

def setup
Expand Down
15 changes: 0 additions & 15 deletions test/functional/dashboards_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@
require File.expand_path '../../test_helper', __FILE__

class DashboardsControllerTest < Additionals::ControllerTest
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:dashboards, :dashboard_roles,
:queries

include CrudControllerBase

def setup
Expand Down
15 changes: 0 additions & 15 deletions test/functional/issues_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@
require File.expand_path '../../test_helper', __FILE__

class IssuesControllerTest < Additionals::ControllerTest
fixtures :users, :email_addresses, :roles,
:enumerations,
:projects, :projects_trackers, :enabled_modules,
:members, :member_roles,
:issues, :issue_statuses, :issue_categories, :issue_relations,
:versions,
:trackers,
:workflows,
:custom_fields, :custom_values, :custom_fields_projects, :custom_fields_trackers,
:time_entries,
:watchers, :attachments,
:journals, :journal_details,
:repositories, :changesets,
:queries

def setup
manager_role = roles :roles_001
manager_role.add_permission! :edit_issue_author
Expand Down
14 changes: 0 additions & 14 deletions test/functional/projects_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ class ViewDashboardBottomRenderOn < Redmine::Hook::ViewListener
end

class ProjectsControllerTest < Additionals::ControllerTest
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:dashboards, :dashboard_roles

def setup
Setting.default_language = 'en'
User.current = nil
Expand Down
9 changes: 0 additions & 9 deletions test/functional/reports_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
require File.expand_path '../../test_helper', __FILE__

class ReportsControllerTest < Additionals::ControllerTest
fixtures :users, :groups_users, :email_addresses, :user_preferences,
:roles, :members, :member_roles,
:projects, :trackers, :issue_statuses, :issues,
:enumerations, :issue_categories,
:projects_trackers,
:roles, :member_roles, :members,
:enabled_modules, :workflows,
:versions

def setup
prepare_tests
end
Expand Down
10 changes: 0 additions & 10 deletions test/functional/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ class ViewUsersShowInfoRenderOn < Redmine::Hook::ViewListener
end

class UsersControllerTest < Additionals::ControllerTest
fixtures :users, :groups_users, :email_addresses, :user_preferences,
:roles, :members, :member_roles,
:issues, :issue_statuses, :issue_relations,
:issues, :issue_statuses, :issue_categories,
:versions, :trackers,
:projects, :projects_trackers, :enabled_modules,
:enumerations

fixtures :hrm_user_types, :hrm_working_calendars if AdditionalsPlugin.active_hrm?

include Redmine::I18n

def setup
Expand Down
3 changes: 0 additions & 3 deletions test/functional/welcome_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ class ViewDashboardBottomRenderOn < Redmine::Hook::ViewListener
end

class WelcomeControllerTest < Additionals::ControllerTest
fixtures :projects, :news, :users, :members,
:dashboards, :dashboard_roles

def setup
Setting.default_language = 'en'
User.current = nil
Expand Down
17 changes: 0 additions & 17 deletions test/functional/wiki_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,6 @@
require File.expand_path '../../test_helper', __FILE__

class WikiControllerTest < Additionals::ControllerTest
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:trackers,
:groups_users,
:projects_trackers,
:enabled_modules,
:issue_statuses,
:issues,
:enumerations,
:custom_fields,
:custom_values,
:custom_fields_trackers,
:wikis

WIKI_MACRO_USER_ID = 2

def setup
Expand Down
48 changes: 48 additions & 0 deletions test/global_fixtures_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# frozen_string_literal: true

module Additionals
module GlobalFixturesHelper
def plugin_fixture_path
"#{File.dirname __FILE__}/fixtures"
end

def fixtures(*table_names)
return super if table_names.first == :all

dir = plugin_fixture_path
table_names.each do |x|
ActiveRecord::FixtureSet.create_fixtures dir, x if File.exist? File.join(dir, "#{x}.yml")
end

super
end

def fixtures_list
if use_transactional_tests
redmine_fixtures_list + plugin_fixtures_list
else
# if use_transactional_tests = false custom fixtures in plugin directory does not work
redmine_fixtures_list
end
end

# NOTE: overwrite it for custom fixtures
def plugin_fixtures_list
[]
end

def redmine_fixtures_list
%i[users groups_users user_preferences email_addresses roles enumerations
auth_sources tokens enabled_modules
projects projects_trackers
members member_roles news
issues issue_statuses issue_categories issue_relations
journals journal_details watchers attachments
custom_fields custom_values custom_fields_projects custom_fields_trackers
versions trackers workflows time_entries
repositories changesets changes
wikis wiki_pages wiki_contents wiki_content_versions
queries]
end
end
end
21 changes: 0 additions & 21 deletions test/integration/api_test/issues_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,6 @@

module ApiTest
class IssuesTest < Additionals::ApiTest
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:issue_relations,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:time_entries,
:journals,
:journal_details,
:queries

test 'GET /issues.xml should contain metadata' do
get '/issues.xml'

Expand Down
12 changes: 0 additions & 12 deletions test/integration/api_test/projects_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@

module ApiTest
class ProjectsTest < Additionals::ApiTest
fixtures :users, :email_addresses, :roles,
:enumerations,
:projects, :projects_trackers, :enabled_modules,
:members, :member_roles,
:issues, :issue_statuses, :issue_categories,
:journals, :journal_details,
:trackers,
:attachments,
:custom_fields, :custom_values,
:time_entries,
:dashboards, :dashboard_roles

test 'GET /projects.xml should return projects' do
get '/projects.xml',
headers: credentials('jsmith')
Expand Down
16 changes: 0 additions & 16 deletions test/integration/common_views_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@
require File.expand_path '../../test_helper', __FILE__

class CommonViewsTest < Additionals::IntegrationTest
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:trackers,
:projects_trackers,
:enabled_modules,
:issue_statuses,
:issue_categories,
:issues,
:enumerations,
:custom_fields,
:custom_values,
:custom_fields_trackers

def setup
prepare_tests
end
Expand Down
Loading

0 comments on commit 9ded1cb

Please sign in to comment.