プロジェクト

全般

プロフィール

Vote #81138

完了

Create tracker by copy

Admin Redmine さんが4年以上前に追加. 4年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Administration_8
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
8
version_id:
152
issue_org_id:
34258
author_id:
332
assigned_to_id:
332
comments:
12
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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).


journals

I made a patch to copy the tracker and attach it.
I confirmed that this patch works fine on latest trunk@20441.
--------------------------------------------------------------------------------
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.

<pre><code class="diff">
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>
</code></pre>
--------------------------------------------------------------------------------
Setting the target version to 4.2.0.
--------------------------------------------------------------------------------
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.

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Committed the patch. Thank you.
--------------------------------------------------------------------------------
The test randomly fails due to r20492.

<pre>
$ 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
</pre>

This can be fixed by adding a fixture.

<pre><code class="diff">
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
</code></pre>
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
Go MAEDA wrote:
> The test randomly fails due to r20492.

Committed the fix in r20534.

--------------------------------------------------------------------------------


related_issues

relates,Closed,9258,Create role by copy

Admin Redmine さんが4年以上前に更新

  • カテゴリAdministration_8 にセット
  • 対象バージョン4.2.0_152 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0