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
This commit is contained in:
Jean-Philippe Lang
2015-09-20 11:38:01 +00:00
parent a5de0fec9e
commit 671fce04de
3 changed files with 10 additions and 1 deletions

View File

@@ -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

View File

@@ -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

View File

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