Project

General

Profile

Feature #27988 » 0001-Option-to-configure-which-trackers-can-be-set-as-sub.patch

Marius BĂLTEANU, 2018-05-05 22:52

View differences:

app/models/issue.rb
732 732
    end
733 733

  
734 734
    # Checks parent issue assignment
735
    if @invalid_parent_issue_id.present?
735
    if @invalid_parent_issue_id.present? || (@parent_issue && @parent_issue.id != parent_id_was && !valid_parent_tracker?(@parent_issue))
736 736
      errors.add :parent_issue_id, :invalid
737 737
    elsif @parent_issue
738 738
      if !valid_parent_project?(@parent_issue)
......
1434 1434
    end
1435 1435
  end
1436 1436

  
1437
  # Returns true if issue's parent is a valid
1438
  # parent tracker
1439
  def valid_parent_tracker?(issue=parent)
1440
    issue.tracker.allowed_subtask?(self.tracker_id)
1441
  end
1442

  
1437 1443
  # Returns an issue scope based on project and scope
1438 1444
  def self.cross_project_scope(project, scope=nil)
1439 1445
    if project.nil?
app/models/tracker.rb
25 25
  CORE_FIELDS_ALL = (CORE_FIELDS_UNDISABLABLE + CORE_FIELDS).freeze
26 26

  
27 27
  before_destroy :check_integrity
28
  after_save :remove_invalid_subtasks
29

  
28 30
  belongs_to :default_status, :class_name => 'IssueStatus'
29 31
  has_many :issues
30 32
  has_many :workflow_rules, :dependent => :delete_all
31 33
  has_and_belongs_to_many :projects
32 34
  has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_trackers#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
35
  has_and_belongs_to_many :subtasks, :class_name => 'TrackerSubtask', :join_table => "#{table_name_prefix}trackers_subtasks#{table_name_suffix}", :association_foreign_key => 'subtask_id', :foreign_key => 'tracker_id'
36
  has_and_belongs_to_many :parents, :class_name => 'TrackerSubtask', :join_table => "#{table_name_prefix}trackers_subtasks#{table_name_suffix}", :association_foreign_key => 'tracker_id', :foreign_key => 'subtask_id'
33 37
  acts_as_positioned
34 38

  
35 39
  validates_presence_of :default_status
......
69 73
    'core_fields',
70 74
    'position',
71 75
    'custom_field_ids',
72
    'project_ids'
76
    'project_ids',
77
    'subtask_ids'
73 78

  
74 79
  def to_s; name end
75 80

  
......
136 141
    end
137 142
  end
138 143

  
144
  def allowed_subtask?(subtask_id)
145
    self.subtasks.where(:trackers_subtasks => { :subtask_id => subtask_id }).exists?
146
  end
147

  
139 148
private
140 149
  def check_integrity
141 150
    raise Exception.new("Cannot delete tracker") if Issue.where(:tracker_id => self.id).any?
142 151
  end
152

  
153
  def remove_invalid_subtasks
154
    if self.disabled_core_fields.include?('parent_issue_id')
155
      self.parents.delete_all
156
    end
157
  end
143 158
end
app/models/tracker_subtask.rb
1
# Redmine - project management software
2
# Copyright (C) 2006-2017  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
class TrackerSubtask < Tracker
19
end
app/views/trackers/_form.html.erb
54 54
<%= hidden_field_tag('tracker[project_ids][]', '', :id => nil) %>
55 55
</fieldset>
56 56
<% end %>
57
<fieldset class="box" id="tracker_subtask_ids"><legend><%= toggle_checkboxes_link("#tracker_subtask_ids input[type=checkbox]:enabled") %><%= l(:label_subtask_plural) %></legend>
58
<% subtask_ids = @tracker.subtask_ids %>
59
<% Tracker.sorted.all.each do |tracker| %>
60
    <%= check_box_tag "tracker[subtask_ids][]",
61
                      tracker.id,
62
                      subtask_ids.include?(tracker.id),
63
                      :id => "subtask_#{tracker.id}",
64
                      :disabled => tracker.disabled_core_fields.include?('parent_issue_id')%>
65
    <label class="no-css" for="subtask_<%=tracker.id%>">
66
      <%= tracker.name %>
67
    </label>
68
<% end %>
69
<%= hidden_field_tag('tracker[subtask_ids][]', '', :id => nil) %>
70
</fieldset>
57 71
</div>
db/migrate/20180226231035_create_tracker_subtask.rb
1
class CreateTrackerSubtask < ActiveRecord::Migration[5.1]
2
  def change
3
    create_table "trackers_subtasks", :id => false, :force => true do |t|
4
      t.column "tracker_id", :integer, :default => 0, :null => false
5
      t.column "subtask_id", :integer, :default => 0, :null => false
6

  
7
      t.index [:tracker_id, :subtask_id], :unique => true
8
    end
9
  end
10
end
db/migrate/20180227191840_allow_all_trackers_as_subtasks.rb
1
class AllowAllTrackersAsSubtasks < ActiveRecord::Migration[5.1]
2
  def change
3
    trackers = Tracker.all
4
    trackers_ids = trackers.pluck(:id)
5

  
6
    trackers.each do |tracker|
7
      tracker.subtask_ids = trackers_ids
8
      tracker.save
9
    end
10
  end
11
end
test/fixtures/trackers_subtasks.yml
1
---
2
trackers_subtasks_001:
3
  tracker_id: 1
4
  subtask_id: 1
5
trackers_subtasks_002:
6
  tracker_id: 1
7
  subtask_id: 2
8
trackers_subtasks_003:
9
  tracker_id: 1
10
  subtask_id: 3
11
trackers_subtasks_004:
12
  tracker_id: 2
13
  subtask_id: 1
14
trackers_subtasks_005:
15
  tracker_id: 2
16
  subtask_id: 2
17
trackers_subtasks_006:
18
  tracker_id: 2
19
  subtask_id: 3
20
trackers_subtasks_007:
21
  tracker_id: 3
22
  subtask_id: 1
23
trackers_subtasks_008:
24
  tracker_id: 3
25
  subtask_id: 2
26
trackers_subtasks_009:
27
  tracker_id: 3
28
  subtask_id: 3
test/functional/attachments_controller_test.rb
21 21

  
22 22
class AttachmentsControllerTest < Redmine::ControllerTest
23 23
  fixtures :users, :projects, :roles, :members, :member_roles,
24
           :enabled_modules, :issues, :trackers, :attachments,
24
           :enabled_modules, :issues, :trackers, :trackers_subtasks, :attachments,
25 25
           :versions, :wiki_pages, :wikis, :documents
26 26

  
27 27
  def setup
test/functional/context_menus_controller_test.rb
20 20
class ContextMenusControllerTest < Redmine::ControllerTest
21 21
  fixtures :projects,
22 22
           :trackers,
23
           :trackers_subtasks,
23 24
           :projects_trackers,
24 25
           :roles,
25 26
           :member_roles,
test/functional/custom_fields_controller_test.rb
23 23
           :roles, :users,
24 24
           :members, :member_roles,
25 25
           :groups_users,
26
           :trackers, :projects_trackers,
26
           :trackers, :trackers_subtasks, :projects_trackers,
27 27
           :enabled_modules,
28 28
           :projects, :issues,
29 29
           :issue_statuses,
test/functional/files_controller_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class FilesControllerTest < Redmine::ControllerTest
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
21
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
22 22
           :enumerations, :users,
23 23
           :email_addresses,
24 24
           :issue_categories,
test/functional/imports_controller_test.rb
22 22
           :users, :email_addresses,
23 23
           :roles, :members, :member_roles,
24 24
           :issues, :issue_statuses,
25
           :trackers, :projects_trackers,
25
           :trackers, :trackers_subtasks, :projects_trackers,
26 26
           :versions,
27 27
           :issue_categories,
28 28
           :enumerations,
test/functional/issue_relations_controller_test.rb
29 29
           :enabled_modules,
30 30
           :enumerations,
31 31
           :trackers,
32
           :trackers_subtasks,
32 33
           :projects_trackers
33 34

  
34 35
  def setup
test/functional/issues_controller_transaction_test.rb
29 29
           :issue_statuses,
30 30
           :versions,
31 31
           :trackers,
32
           :trackers_subtasks,
32 33
           :projects_trackers,
33 34
           :issue_categories,
34 35
           :enabled_modules,
test/functional/my_controller_test.rb
19 19

  
20 20
class MyControllerTest < Redmine::ControllerTest
21 21
  fixtures :users, :email_addresses, :user_preferences, :roles, :projects, :members, :member_roles,
22
  :issues, :issue_statuses, :trackers, :enumerations, :custom_fields, :auth_sources, :queries
22
  :issues, :issue_statuses, :trackers, :trackers_subtasks, :enumerations, :custom_fields, :auth_sources, :queries
23 23

  
24 24
  def setup
25 25
    @request.session[:user_id] = 2
test/functional/previews_controller_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class PreviewsControllerTest < Redmine::ControllerTest
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
21
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
22 22
           :enumerations, :users, :issue_categories,
23 23
           :projects_trackers,
24 24
           :roles,
test/functional/projects_controller_test.rb
20 20
class ProjectsControllerTest < Redmine::ControllerTest
21 21
  fixtures :projects, :versions, :users, :email_addresses, :roles, :members,
22 22
           :member_roles, :issues, :journals, :journal_details,
23
           :trackers, :projects_trackers, :issue_statuses,
23
           :trackers, :trackers_subtasks, :projects_trackers, :issue_statuses,
24 24
           :enabled_modules, :enumerations, :boards, :messages,
25 25
           :attachments, :custom_fields, :custom_values, :time_entries,
26 26
           :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
test/functional/queries_controller_test.rb
21 21
  fixtures :projects, :enabled_modules,
22 22
           :users, :email_addresses,
23 23
           :members, :member_roles, :roles,
24
           :trackers, :issue_statuses, :issue_categories, :enumerations, :versions,
24
           :trackers, :trackers_subtasks, :issue_statuses, :issue_categories, :enumerations, :versions,
25 25
           :issues, :custom_fields, :custom_values,
26 26
           :queries
27 27

  
test/functional/reports_controller_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class ReportsControllerTest < Redmine::ControllerTest
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
21
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
22 22
           :enumerations, :users, :issue_categories,
23 23
           :projects_trackers,
24 24
           :roles,
test/functional/repositories_controller_test.rb
20 20
class RepositoriesControllerTest < Redmine::RepositoryControllerTest
21 21
  fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, :enabled_modules,
22 22
           :repositories, :issues, :issue_statuses, :changesets, :changes,
23
           :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
23
           :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers, :trackers_subtasks
24 24

  
25 25
  def setup
26 26
    super
test/functional/repositories_subversion_controller_test.rb
22 22

  
23 23
  fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, :enabled_modules,
24 24
           :repositories, :issues, :issue_statuses, :changesets, :changes,
25
           :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
25
           :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers, :trackers_subtasks
26 26

  
27 27
  PRJ_ID = 3
28 28
  NUM_REV = 11
test/functional/roles_controller_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class RolesControllerTest < Redmine::ControllerTest
21
  fixtures :roles, :users, :members, :member_roles, :workflows, :trackers
21
  fixtures :roles, :users, :members, :member_roles, :workflows, :trackers, :trackers_subtasks
22 22

  
23 23
  def setup
24 24
    User.current = nil
test/functional/search_controller_test.rb
20 20
class SearchControllerTest < Redmine::ControllerTest
21 21
  fixtures :projects, :projects_trackers,
22 22
           :enabled_modules, :roles, :users, :members, :member_roles,
23
           :issues, :trackers, :issue_statuses, :enumerations,
23
           :issues, :trackers, :trackers_subtasks, :issue_statuses, :enumerations,
24 24
           :workflows,
25 25
           :custom_fields, :custom_values,
26 26
           :custom_fields_projects, :custom_fields_trackers,
test/functional/search_custom_fields_visibility_test.rb
26 26
           :member_roles,
27 27
           :issue_statuses,
28 28
           :trackers,
29
           :trackers_subtasks,
29 30
           :projects_trackers,
30 31
           :enabled_modules,
31 32
           :enumerations,
test/functional/settings_controller_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class SettingsControllerTest < Redmine::ControllerTest
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
21
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
22 22
           :users
23 23

  
24 24
  def setup
test/functional/timelog_report_test.rb
23 23

  
24 24
  fixtures :projects, :enabled_modules, :roles, :members, :member_roles,
25 25
           :email_addresses,
26
           :issues, :time_entries, :users, :trackers, :enumerations,
26
           :issues, :time_entries, :users, :trackers, :trackers_subtasks, :enumerations,
27 27
           :issue_statuses, :custom_fields, :custom_values,
28 28
           :projects_trackers, :custom_fields_trackers,
29 29
           :custom_fields_projects
test/functional/trackers_controller_test.rb
240 240
    assert_equal [], tracker.core_fields
241 241
    assert_equal [], tracker.custom_field_ids.sort
242 242
  end
243

  
244
  def test_tracker_with_parent_task_field_disabled_should_be_shown_as_disabled_in_subtasks_section
245
    tracker = Tracker.find(1)
246
    tracker.core_fields = %w(assigned_to_id due_date)
247
    tracker.save!
248

  
249
    get :edit, :params => {:id => 3}
250
    assert_response :success
251

  
252
    assert_select 'input[id=?][disabled=?]', 'subtask_1', 'disabled'
253
  end
243 254
end
test/functional/versions_controller_test.rb
19 19

  
20 20
class VersionsControllerTest < Redmine::ControllerTest
21 21
  fixtures :projects, :enabled_modules,
22
           :trackers, :projects_trackers,
22
           :trackers, :trackers_subtasks, :projects_trackers,
23 23
           :versions, :issue_statuses, :issue_categories, :enumerations,
24 24
           :issues,
25 25
           :users, :email_addresses,
test/functional/workflows_controller_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class WorkflowsControllerTest < Redmine::ControllerTest
21
  fixtures :roles, :trackers, :workflows, :users, :issue_statuses
21
  fixtures :roles, :trackers, :trackers_subtasks, :workflows, :users, :issue_statuses
22 22

  
23 23
  def setup
24 24
    User.current = nil
test/integration/admin_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class AdminTest < Redmine::IntegrationTest
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
21
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
22 22
           :enumerations, :users, :issue_categories,
23 23
           :projects_trackers,
24 24
           :roles,
test/integration/api_test/disabled_rest_api_test.rb
18 18
require File.expand_path('../../../test_helper', __FILE__)
19 19

  
20 20
class Redmine::ApiTest::DisabledRestApiTest < Redmine::ApiTest::Base
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
21
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
22 22
           :enumerations, :users, :issue_categories,
23 23
           :projects_trackers,
24 24
           :roles,
test/integration/api_test/issue_relations_test.rb
18 18
require File.expand_path('../../../test_helper', __FILE__)
19 19

  
20 20
class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
21
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
22 22
           :enumerations, :users, :issue_categories,
23 23
           :projects_trackers,
24 24
           :roles,
test/integration/api_test/issues_test.rb
28 28
    :issue_relations,
29 29
    :versions,
30 30
    :trackers,
31
    :trackers_subtasks,
31 32
    :projects_trackers,
32 33
    :issue_categories,
33 34
    :enabled_modules,
test/integration/api_test/jsonp_test.rb
18 18
require File.expand_path('../../../test_helper', __FILE__)
19 19

  
20 20
class Redmine::ApiTest::JsonpTest < Redmine::ApiTest::Base
21
  fixtures :trackers
21
  fixtures :trackers, :trackers_subtasks
22 22

  
23 23
  def test_should_ignore_jsonp_callback_with_jsonp_disabled
24 24
    with_settings :jsonp_enabled => '0' do
test/integration/api_test/news_test.rb
18 18
require File.expand_path('../../../test_helper', __FILE__)
19 19

  
20 20
class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
21
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
22 22
           :enumerations, :users, :issue_categories,
23 23
           :projects_trackers,
24 24
           :roles,
test/integration/api_test/projects_test.rb
19 19

  
20 20
class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
21 21
  fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details,
22
           :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
22
           :trackers, :trackers_subtasks, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
23 23
           :attachments, :custom_fields, :custom_values, :time_entries, :issue_categories
24 24

  
25 25
  def setup
test/integration/api_test/search_test.rb
20 20
class Redmine::ApiTest::SearchTest < Redmine::ApiTest::Base
21 21
  fixtures :projects, :projects_trackers,
22 22
           :enabled_modules, :roles, :users, :members, :member_roles,
23
           :issues, :trackers, :issue_statuses, :enumerations,
23
           :issues, :trackers, :trackers_subtasks, :issue_statuses, :enumerations,
24 24
           :workflows,
25 25
           :custom_fields, :custom_values,
26 26
           :custom_fields_projects, :custom_fields_trackers,
test/integration/api_test/trackers_test.rb
18 18
require File.expand_path('../../../test_helper', __FILE__)
19 19

  
20 20
class Redmine::ApiTest::TrackersTest < Redmine::ApiTest::Base
21
  fixtures :trackers
21
  fixtures :trackers, :trackers_subtasks
22 22

  
23 23
  test "GET /trackers.xml should return trackers" do
24 24
    get '/trackers.xml'
test/integration/application_test.rb
20 20
class ApplicationTest < Redmine::IntegrationTest
21 21
  include Redmine::I18n
22 22

  
23
  fixtures :projects, :trackers, :issue_statuses, :issues,
23
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
24 24
           :enumerations, :users, :issue_categories,
25 25
           :projects_trackers,
26 26
           :roles,
test/integration/attachments_test.rb
21 21
  fixtures :projects, :enabled_modules,
22 22
           :users, :email_addresses,
23 23
           :roles, :members, :member_roles,
24
           :trackers, :projects_trackers,
24
           :trackers, :trackers_subtasks, :projects_trackers,
25 25
           :issues, :issue_statuses, :enumerations,
26 26
           :attachments
27 27

  
test/integration/feeds_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class FeedsTest < Redmine::IntegrationTest
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
21
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
22 22
           :enumerations, :users, :issue_categories,
23 23
           :projects_trackers, :enabled_modules,
24 24
           :roles, :member_roles, :members
test/integration/issues_test.rb
24 24
           :members,
25 25
           :member_roles,
26 26
           :trackers,
27
           :trackers_subtasks,
27 28
           :projects_trackers,
28 29
           :enabled_modules,
29 30
           :issue_statuses,
test/integration/layout_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class LayoutTest < Redmine::IntegrationTest
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
21
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
22 22
           :enumerations, :users, :issue_categories,
23 23
           :projects_trackers,
24 24
           :roles,
test/integration/lib/redmine/field_format/attachment_format_test.rb
24 24
           :members,
25 25
           :member_roles,
26 26
           :trackers,
27
           :trackers_subtasks,
27 28
           :projects_trackers,
28 29
           :enabled_modules,
29 30
           :issue_statuses,
test/integration/lib/redmine/menu_manager_test.rb
20 20
class MenuManagerTest < Redmine::IntegrationTest
21 21
  include Redmine::I18n
22 22

  
23
  fixtures :projects, :trackers, :issue_statuses, :issues,
23
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
24 24
           :enumerations, :users, :issue_categories,
25 25
           :projects_trackers,
26 26
           :roles,
test/object_helpers.rb
65 65
    @generated_tracker_name.succ!
66 66
    tracker = Tracker.new(attributes)
67 67
    tracker.name = @generated_tracker_name.dup if tracker.name.blank?
68
    tracker.subtask_ids = [1, 2, 3, tracker.id]
68 69
    tracker.default_status ||= IssueStatus.order(:position).first || IssueStatus.generate!
69 70
    yield tracker if block_given?
70 71
    tracker
......
76 77
    tracker
77 78
  end
78 79

  
80
  def Tracker.add_subtasks(tracker, subtask_ids)
81
    tracker.subtask_ids = subtask_ids
82
    tracker.save!
83
  end
84

  
79 85
  def Role.generate!(attributes={})
80 86
    @generated_role_name ||= 'Role 0'
81 87
    @generated_role_name.succ!
test/unit/activity_test.rb
19 19

  
20 20
class ActivityTest < ActiveSupport::TestCase
21 21
  fixtures :projects, :versions, :attachments, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details,
22
           :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages, :time_entries,
22
           :trackers, :trackers_subtasks, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages, :time_entries,
23 23
           :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
24 24

  
25 25
  def setup
test/unit/attachment_test.rb
21 21

  
22 22
class AttachmentTest < ActiveSupport::TestCase
23 23
  fixtures :users, :email_addresses, :projects, :roles, :members, :member_roles,
24
           :enabled_modules, :issues, :trackers, :attachments
24
           :enabled_modules, :issues, :trackers, :trackers_subtasks, :attachments
25 25

  
26 26
  def setup
27 27
    set_tmp_attachments_directory
test/unit/attachment_transaction_test.rb
21 21

  
22 22
class AttachmentTest < ActiveSupport::TestCase
23 23
  fixtures :users, :email_addresses, :projects, :roles, :members, :member_roles,
24
           :enabled_modules, :issues, :trackers, :attachments
24
           :enabled_modules, :issues, :trackers, :trackers_subtasks, :attachments
25 25

  
26 26
  self.use_transactional_tests = false
27 27

  
test/unit/changeset_test.rb
29 29
           :custom_fields, :custom_values,
30 30
           :users, :members, :member_roles,
31 31
           :email_addresses,
32
           :trackers, :projects_trackers,
32
           :trackers, :trackers_subtasks, :projects_trackers,
33 33
           :enabled_modules, :roles
34 34

  
35 35
  def test_ref_keywords_any
test/unit/custom_field_test.rb
19 19

  
20 20
class CustomFieldTest < ActiveSupport::TestCase
21 21
  fixtures :custom_fields, :roles, :projects,
22
           :trackers, :issue_statuses,
22
           :trackers, :trackers_subtasks, :issue_statuses,
23 23
           :issues
24 24

  
25 25
  def test_create
test/unit/enabled_module_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class EnabledModuleTest < ActiveSupport::TestCase
21
  fixtures :projects, :trackers, :issue_statuses, :wikis
21
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :wikis
22 22

  
23 23
  def test_enabling_wiki_should_create_a_wiki
24 24
    CustomField.delete_all
test/unit/group_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class GroupTest < ActiveSupport::TestCase
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
21
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
22 22
           :enumerations, :users,
23 23
           :projects_trackers,
24 24
           :roles,
test/unit/issue_import_test.rb
22 22
           :users, :email_addresses,
23 23
           :roles, :members, :member_roles,
24 24
           :issues, :issue_statuses,
25
           :trackers, :projects_trackers,
25
           :trackers, :trackers_subtasks, :projects_trackers,
26 26
           :versions,
27 27
           :issue_categories,
28 28
           :enumerations,
test/unit/issue_nested_set_concurrency_test.rb
19 19

  
20 20
class IssueNestedSetConcurrencyTest < ActiveSupport::TestCase
21 21
  fixtures :projects, :users,
22
           :trackers, :projects_trackers,
22
           :trackers, :trackers_subtasks, :projects_trackers,
23 23
           :enabled_modules,
24 24
           :issue_statuses,
25 25
           :enumerations
test/unit/issue_nested_set_test.rb
19 19

  
20 20
class IssueNestedSetTest < ActiveSupport::TestCase
21 21
  fixtures :projects, :users, :roles,
22
           :trackers, :projects_trackers,
22
           :trackers, :trackers_subtasks, :projects_trackers,
23 23
           :issue_statuses, :issue_categories, :issue_relations,
24 24
           :enumerations,
25 25
           :issues
test/unit/issue_relation_test.rb
29 29
           :enabled_modules,
30 30
           :enumerations,
31 31
           :trackers,
32
           :trackers_subtasks,
32 33
           :projects_trackers
33 34

  
34 35
  include Redmine::I18n
test/unit/issue_subtasking_test.rb
19 19

  
20 20
class IssueSubtaskingTest < ActiveSupport::TestCase
21 21
  fixtures :projects, :users, :roles, :members, :member_roles,
22
           :trackers, :projects_trackers,
22
           :trackers,:trackers_subtasks, :projects_trackers,
23 23
           :issue_statuses, :issue_categories, :enumerations,
24 24
           :issues,
25 25
           :enabled_modules,
......
350 350
    assert !child.save
351 351
    assert_include I18n.t("activerecord.errors.messages.open_issue_with_closed_parent"), child.errors.full_messages
352 352
  end
353

  
354
  def test_parent_issue_with_invalid_subtask_should_not_validate
355
    tracker = Tracker.find(1)
356
    tracker.subtask_ids = [1, 3]
357

  
358
    parent = Issue.generate!(:status_id => 5, :tracker_id => 1)
359
    child = Issue.generate!(:tracker_id => 2)
360

  
361
    child.parent_issue_id = parent.id
362
    assert !child.save
363
    assert_include 'Parent task is invalid', child.errors.full_messages
364
  end
353 365
end
test/unit/issue_test.rb
20 20
class IssueTest < ActiveSupport::TestCase
21 21
  fixtures :projects, :users, :email_addresses, :user_preferences, :members, :member_roles, :roles,
22 22
           :groups_users,
23
           :trackers, :projects_trackers,
23
           :trackers, :trackers_subtasks, :projects_trackers,
24 24
           :enabled_modules,
25 25
           :versions,
26 26
           :issue_statuses, :issue_categories, :issue_relations, :workflows,
test/unit/issue_transaction_test.rb
19 19

  
20 20
class IssueTransactionTest < ActiveSupport::TestCase
21 21
  fixtures :projects, :users, :members, :member_roles, :roles,
22
           :trackers, :projects_trackers,
22
           :trackers, :trackers_subtasks, :projects_trackers,
23 23
           :versions,
24 24
           :issue_statuses, :issue_categories, :issue_relations, :workflows,
25 25
           :enumerations,
test/unit/journal_test.rb
23 23
           :users, :members, :member_roles, :roles, :enabled_modules,
24 24
           :groups_users, :email_addresses,
25 25
           :enumerations,
26
           :projects_trackers, :trackers, :custom_fields
26
           :projects_trackers, :trackers, :trackers_subtasks, :custom_fields
27 27

  
28 28
  def setup
29 29
    @journal = Journal.find 1
test/unit/lib/redmine/helpers/gantt_test.rb
109 109
    create_gantt
110 110
    @project.enabled_module_names = [:issue_tracking]
111 111
    @tracker = Tracker.generate!
112
    Tracker.add_subtasks(@tracker, [1, 2, 3, @tracker.id])
112 113
    @project.trackers << @tracker
113 114
    @version = Version.generate!(:effective_date => (today + 7), :sharing => 'none')
114 115
    @project.versions << @version
test/unit/mail_handler_test.rb
24 24
           :members, :member_roles, :users,
25 25
           :email_addresses, :user_preferences,
26 26
           :issues, :issue_statuses,
27
           :workflows, :trackers, :projects_trackers,
27
           :workflows, :trackers, :trackers_subtasks, :projects_trackers,
28 28
           :versions, :enumerations, :issue_categories,
29 29
           :custom_fields, :custom_fields_trackers, :custom_fields_projects,
30 30
           :boards, :messages
test/unit/mailer_test.rb
25 25
  fixtures :projects, :enabled_modules, :issues, :users, :email_addresses, :user_preferences, :members,
26 26
           :member_roles, :roles, :documents, :attachments, :news,
27 27
           :tokens, :journals, :journal_details, :changesets,
28
           :trackers, :projects_trackers,
28
           :trackers, :trackers_subtasks, :projects_trackers,
29 29
           :issue_statuses, :enumerations, :messages, :boards, :repositories,
30 30
           :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions,
31 31
           :versions,
test/unit/project_members_inheritance_test.rb
19 19

  
20 20
class ProjectMembersInheritanceTest < ActiveSupport::TestCase
21 21
  fixtures :roles, :users,
22
           :projects, :trackers, :issue_statuses
22
           :projects, :trackers, :trackers_subtasks, :issue_statuses
23 23

  
24 24
  def setup
25 25
    @parent = Project.generate!
test/unit/project_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class ProjectTest < ActiveSupport::TestCase
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
21
  fixtures :projects, :trackers, :trackers_subtasks, :issue_statuses, :issues,
22 22
           :journals, :journal_details,
23 23
           :enumerations, :users, :issue_categories,
24 24
           :projects_trackers,
test/unit/query_test.rb
23 23
  include Redmine::I18n
24 24

  
25 25
  fixtures :projects, :enabled_modules, :users, :members,
26
           :member_roles, :roles, :trackers, :issue_statuses,
26
           :member_roles, :roles, :trackers, :trackers_subtasks, :issue_statuses,
27 27
           :issue_categories, :enumerations, :issues,
28 28
           :watchers, :custom_fields, :custom_values, :versions,
29 29
           :queries,
test/unit/repository_test.rb
20 20
class RepositoryTest < ActiveSupport::TestCase
21 21
  fixtures :projects,
22 22
           :trackers,
23
           :trackers_subtasks,
23 24
           :projects_trackers,
24 25
           :enabled_modules,
25 26
           :repositories,
test/unit/role_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class RoleTest < ActiveSupport::TestCase
21
  fixtures :roles, :workflows, :trackers
21
  fixtures :roles, :workflows, :trackers, :trackers_subtasks
22 22

  
23 23
  def test_sorted_scope
24 24
    assert_equal Role.all.sort, Role.sorted.to_a
test/unit/search_test.rb
29 29
           :enabled_modules,
30 30
           :issues,
31 31
           :trackers,
32
           :trackers_subtasks,
32 33
           :issue_statuses,
33 34
           :enumerations,
34 35
           :journals,
test/unit/time_entry_activity_test.rb
21 21
  fixtures :enumerations, :time_entries, :custom_fields,
22 22
           :issues, :projects, :users,
23 23
           :members, :roles, :member_roles,
24
           :trackers, :issue_statuses,
24
           :trackers, :trackers_subtasks, :issue_statuses,
25 25
           :projects_trackers,
26 26
           :issue_categories,
27 27
           :groups_users,
test/unit/time_entry_query_test.rb
20 20
class TimeEntryQueryTest < ActiveSupport::TestCase
21 21
  fixtures :issues, :projects, :users,
22 22
           :members, :roles, :member_roles,
23
           :trackers, :issue_statuses,
23
           :trackers, :trackers_subtasks, :issue_statuses,
24 24
           :projects_trackers,
25 25
           :journals, :journal_details,
26 26
           :issue_categories, :enumerations,
test/unit/tracker_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class TrackerTest < ActiveSupport::TestCase
21
  fixtures :trackers, :workflows, :issue_statuses, :roles, :issues, :projects, :projects_trackers
21
  fixtures :trackers, :trackers_subtasks,  :workflows, :issue_statuses, :roles, :issues, :projects, :projects_trackers
22 22

  
23 23
  def test_sorted_scope
24 24
    assert_equal Tracker.all.sort, Tracker.sorted.to_a
......
128 128
      end
129 129
    end
130 130
  end
131

  
132
  def test_allowed_subtask_should_return_true_if_the_tracker_can_be_a_subtask
133
    assert Tracker.find(1).allowed_subtask?(2)
134
  end
135

  
136
  def test_allowed_subtask_should_return_false_if_the_tracker_cannot_be_a_subtask
137
    tracker = Tracker.find(1)
138
    tracker.subtask_ids = [1, 3]
139

  
140
    assert_equal false, tracker.allowed_subtask?(2)
141
  end
142

  
143
  def test_disabling_parent_field_should_remove_all_invalid_subtasks
144
    tracker = Tracker.find(1)
145
    tracker.core_fields -= ['parent_issue_id']
146
    tracker.save
147

  
148
    assert_equal [2, 3], Tracker.find(2).subtask_ids
149
    assert_equal [2, 3], Tracker.find(3).subtask_ids
150
  end
131 151
end
test/unit/user_test.rb
19 19

  
20 20
class UserTest < ActiveSupport::TestCase
21 21
  fixtures :users, :email_addresses, :members, :projects, :roles, :member_roles, :auth_sources,
22
            :trackers, :issue_statuses,
22
            :trackers, :trackers_subtasks, :issue_statuses,
23 23
            :projects_trackers,
24 24
            :watchers,
25 25
            :issue_categories, :enumerations, :issues,
test/unit/version_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class VersionTest < ActiveSupport::TestCase
21
  fixtures :projects, :users, :issues, :issue_statuses, :trackers,
21
  fixtures :projects, :users, :issues, :issue_statuses, :trackers, :trackers_subtasks,
22 22
           :enumerations, :versions, :projects_trackers
23 23

  
24 24
  def test_create
test/unit/watcher_test.rb
19 19

  
20 20
class WatcherTest < ActiveSupport::TestCase
21 21
  fixtures :projects, :users, :email_addresses, :members, :member_roles, :roles, :enabled_modules,
22
           :issues, :issue_statuses, :enumerations, :trackers, :projects_trackers,
22
           :issues, :issue_statuses, :enumerations, :trackers, :trackers_subtasks, :projects_trackers,
23 23
           :boards, :messages,
24 24
           :wikis, :wiki_pages,
25 25
           :watchers
test/unit/workflow_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class WorkflowTest < ActiveSupport::TestCase
21
  fixtures :roles, :trackers, :issue_statuses
21
  fixtures :roles, :trackers, :trackers_subtasks, :issue_statuses
22 22

  
23 23
  def test_copy
24 24
    WorkflowTransition.delete_all
test/unit/workflow_transition_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class WorkflowTransitionTest < ActiveSupport::TestCase
21
  fixtures :roles, :trackers, :issue_statuses
21
  fixtures :roles, :trackers, :trackers_subtasks, :issue_statuses
22 22

  
23 23
  def setup
24 24
    WorkflowTransition.delete_all
(4-4/7)