Project

General

Profile

Actions

Defect #17202

closed

Copying Project Fails to Copy Queries with visibility == VISIBILITY_ROLES

Added by Zach Auclair almost 10 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Category:
Issues
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Issue

As a result of #1019, app/models/project.rb#copy_queries fails to copy queries into a cloned project.

To Reproduce

Against redmine version 2.5.X:

  1. Create a project
  2. In created project, create a custom query (any fields) with visiblity == Developer for all projects
  3. Clone the project to another project
  4. Observe the query to be missing in the cloned project

Proposed Solution

Special-case the roles attribute:

diff --git a/app/models/project.rb b/app/models/project.rb
index 6ced345..395e4dd 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -950,6 +950,7 @@ class Project < ActiveRecord::Base
       new_query = IssueQuery.new
       new_query.attributes = query.attributes.dup.except("id", "project_id", "sort_criteria")
       new_query.sort_criteria = query.sort_criteria if query.sort_criteria
+      new_query.roles = query.roles if query.roles && query.visibility == IssueQuery::VISIBILITY_ROLES
       new_query.project = self
       new_query.user_id = query.user_id
       self.queries << new_query

Environment

Environment:
  Redmine version                2.5.1.devel
  Ruby version                   1.8.7-p352 (2011-06-30) [x86_64-linux]
  Rails version                  3.2.18
  Environment                    production
  Database adapter               SQLite
SCM:
  Subversion                     1.6.11
  Mercurial                      2.6.3
  Git                            1.8.2.1
  Filesystem
Redmine plugins:
  no plugin installed
Actions

Also available in: Atom PDF