summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-09-20 11:38:01 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-09-20 11:38:01 +0000
commit671fce04dec6c27b8089bc7492cb67bbf4e6277c (patch)
treed6612c8ac79fd061f9e286590a8fdc1507bf52c5
parenta5de0fec9e97a7951a0bef465451d0a1d16bf7b4 (diff)
downloadredmine-671fce04dec6c27b8089bc7492cb67bbf4e6277c.tar.gz
redmine-671fce04dec6c27b8089bc7492cb67bbf4e6277c.zip
Don't propose projects without trackers when editing an issue (#20463).
git-svn-id: http://svn.redmine.org/redmine/trunk@14613 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/issue.rb2
-rw-r--r--app/models/project.rb3
-rw-r--r--test/unit/issue_test.rb6
3 files changed, 10 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 13299b60e..70573dd95 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1386,7 +1386,7 @@ class Issue < ActiveRecord::Base
if current_project
condition = ["(#{condition}) OR #{Project.table_name}.id = ?", current_project.id]
end
- Project.where(condition)
+ Project.where(condition).having_trackers
end
private
diff --git a/app/models/project.rb b/app/models/project.rb
index 62db1854f..25f0d3fc5 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -110,6 +110,9 @@ class Project < ActiveRecord::Base
end
}
scope :sorted, lambda {order(:lft)}
+ scope :having_trackers, lambda {
+ where("#{Project.table_name}.id IN (SELECT DISTINCT project_id FROM #{table_name_prefix}projects_trackers#{table_name_suffix})")
+ }
def initialize(attributes=nil, *args)
super
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 9a8afd66d..bed63b767 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -1331,6 +1331,12 @@ class IssueTest < ActiveSupport::TestCase
assert_not_include Project.find(2), Issue.allowed_target_projects(User.find(2))
end
+ def test_allowed_target_projects_should_not_include_projects_without_trackers
+ project = Project.generate!(:tracker_ids => [])
+ assert project.trackers.empty?
+ assert_not_include project, Issue.allowed_target_projects(User.find(1))
+ end
+
def test_move_to_another_project_with_same_category
issue = Issue.find(1)
issue.project = Project.find(2)