Feature #34258

Create tracker by copy

Added by Go MAEDA 4 months ago. Updated 3 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Administration
Target version:4.2.0
Resolution:Fixed

Description

When there are many custom fields or projects, configuring a new tracker is painful work. Imagine that there are 300 custom fields in your Redmine instance. You have to check/uncheck 300 checkboxes.

It can be mitigated if Redmine has a feature to copy existing tracker. The feature to copy a role is already exists (#9258).

34258-copy-tracker.patch Magnifier (6.13 KB) Takenori TAKAKI, 2020-11-20 09:06


Related issues

Related to Redmine - Feature #9258: Create role by copy Closed 2011-09-16

Associated revisions

Revision 20492
Added by Go MAEDA 3 months ago

Create tracker by copy (#34258).

Patch by Takenori TAKAKI.

Revision 20534
Added by Go MAEDA 3 months ago

Fix random test failure due to r20492 (#34258).

History

#1 Updated by Takenori TAKAKI 3 months ago

I made a patch to copy the tracker and attach it.
I confirmed that this patch works fine on latest trunk@20441.

#2 Updated by Go MAEDA 3 months ago

  • Target version set to Candidate for next major release

Thank you for posting the patch. I think the following change to the patch is necessary to fix an issue that the selection of "Copy workflow from" is cleared after validation error.

diff --git a/app/views/trackers/_form.html.erb b/app/views/trackers/_form.html.erb
index b7c4b773f..2ccd225e6 100644
--- a/app/views/trackers/_form.html.erb
+++ b/app/views/trackers/_form.html.erb
@@ -39,7 +39,7 @@

 <% if @tracker.new_record? && @trackers.any? %>
 <p><label for="copy_workflow_from"><%= l(:label_copy_workflow_from) %></label>
-<%= select_tag(:copy_workflow_from, content_tag("option") + options_from_collection_for_select(@trackers, :id, :name, @copy_from.try(:id))) %></p>
+<%= select_tag(:copy_workflow_from, content_tag("option") + options_from_collection_for_select(@trackers, :id, :name, params[:copy_workflow_from] || @copy_from.try(:id))) %></p>
 <% end %>
 <!--[eoform:tracker]-->
 </div>

#3 Updated by Go MAEDA 3 months ago

  • Target version changed from Candidate for next major release to 4.2.0

Setting the target version to 4.2.0.

#4 Updated by Takenori TAKAKI 3 months ago

Go MAEDA wrote:

Thank you for posting the patch. I think the following change to the patch is necessary to fix an issue that the selection of "Copy workflow from" is cleared after validation error.

Thank you for pointing out.
I confirmed that the proposed code solves the problem in case of Validation error.

#5 Updated by Go MAEDA 3 months ago

  • Related to Feature #841: Ability to copy an existing workflow when creating a new role added

#6 Updated by Go MAEDA 3 months ago

  • Subject changed from Ability to copy an existing tracker when creating a new tracker to Create tracker by copy
  • Description updated (diff)

#7 Updated by Go MAEDA 3 months ago

  • Related to deleted (Feature #841: Ability to copy an existing workflow when creating a new role)

#8 Updated by Go MAEDA 3 months ago

#9 Updated by Go MAEDA 3 months ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you.

#10 Updated by Go MAEDA 3 months ago

  • Status changed from Closed to Reopened

The test randomly fails due to r20492.

$ bin/rake db:reset RAILS_ENV=test
$ bin/rails test test/unit/tracker_test.rb:65
Run options: --seed 57984

# Running:

E

Error:
TrackerTest#test_copy_from_should_copy_custom_fields:
ActiveRecord::RecordNotFound: Couldn't find all IssueCustomFields with 'id': (1, 2, 6) [WHERE "custom_fields"."type" IN ('IssueCustomField')] (found 0 results, but was looking for 3). Couldn't find IssueCustomFields with ids 1, 2, 6.
    test/object_helpers.rb:68:in `generate'
    test/object_helpers.rb:76:in `generate!'
    test/unit/tracker_test.rb:66:in `test_copy_from_should_copy_custom_fields'

bin/rails test test/unit/tracker_test.rb:65

This can be fixed by adding a fixture.

diff --git a/test/unit/tracker_test.rb b/test/unit/tracker_test.rb
index 1f3447da7..d4b383ea3 100644
--- a/test/unit/tracker_test.rb
+++ b/test/unit/tracker_test.rb
@@ -20,7 +20,7 @@
 require File.expand_path('../../test_helper', __FILE__)

 class TrackerTest < ActiveSupport::TestCase
-  fixtures :trackers, :workflows, :issue_statuses, :roles, :issues, :projects, :projects_trackers, :enabled_modules
+  fixtures :trackers, :workflows, :issue_statuses, :roles, :issues, :custom_fields, :projects, :projects_trackers, :enabled_modules

   def setup
     User.current = nil

#11 Updated by Takenori TAKAKI 3 months ago

Thanks Go MAEDA.
I could also confirm that the test fails in the environment where the database was rebuilt.
As you pointed out, I missed the addition of fixture on my patch.

#12 Updated by Go MAEDA 3 months ago

  • Status changed from Reopened to Closed

Go MAEDA wrote:

The test randomly fails due to r20492.

Committed the fix in r20534.

Also available in: Atom PDF