##// END OF EJS Templates
Fixed that issues can be moved to projects with issue tracking disabled (#10467)....
Jean-Philippe Lang -
r9139:1294f721755f
parent child
Show More
@@ -800,18 +800,7 class Issue < ActiveRecord::Base
800
800
801 # Returns an array of projects that user can move issues to
801 # Returns an array of projects that user can move issues to
802 def self.allowed_target_projects_on_move(user=User.current)
802 def self.allowed_target_projects_on_move(user=User.current)
803 projects = []
803 Project.all(:conditions => Project.allowed_to_condition(user, :move_issues))
804 if user.admin?
805 # admin is allowed to move issues to any active (visible) project
806 projects = Project.visible(user).all
807 elsif user.logged?
808 if Role.non_member.allowed_to?(:move_issues)
809 projects = Project.visible(user).all
810 else
811 user.memberships.each {|m| projects << m.project if m.roles.detect {|r| r.allowed_to?(:move_issues)}}
812 end
813 end
814 projects
815 end
804 end
816
805
817 private
806 private
@@ -530,6 +530,15 class IssueTest < ActiveSupport::TestCase
530 assert issue.save
530 assert issue.save
531 end
531 end
532
532
533 def test_allowed_target_projects_on_move_should_include_projects_with_issue_tracking_enabled
534 assert_include Project.find(2), Issue.allowed_target_projects_on_move(User.find(2))
535 end
536
537 def test_allowed_target_projects_on_move_should_not_include_projects_with_issue_tracking_disabled
538 Project.find(2).disable_module! :issue_tracking
539 assert_not_include Project.find(2), Issue.allowed_target_projects_on_move(User.find(2))
540 end
541
533 def test_move_to_another_project_with_same_category
542 def test_move_to_another_project_with_same_category
534 issue = Issue.find(1)
543 issue = Issue.find(1)
535 issue.project = Project.find(2)
544 issue.project = Project.find(2)
@@ -1172,22 +1181,6 class IssueTest < ActiveSupport::TestCase
1172 assert_equal 2, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1181 assert_equal 2, groups.inject(0) {|sum, group| sum + group['total'].to_i}
1173 end
1182 end
1174
1183
1175 context ".allowed_target_projects_on_move" do
1176 should "return all active projects for admin users" do
1177 User.current = User.find(1)
1178 assert_equal Project.active.count, Issue.allowed_target_projects_on_move.size
1179 end
1180
1181 should "return allowed projects for non admin users" do
1182 User.current = User.find(2)
1183 Role.non_member.remove_permission! :move_issues
1184 assert_equal 3, Issue.allowed_target_projects_on_move.size
1185
1186 Role.non_member.add_permission! :move_issues
1187 assert_equal Project.active.count, Issue.allowed_target_projects_on_move.size
1188 end
1189 end
1190
1191 def test_recently_updated_with_limit_scopes
1184 def test_recently_updated_with_limit_scopes
1192 #should return the last updated issue
1185 #should return the last updated issue
1193 assert_equal 1, Issue.recently_updated.with_limit(1).length
1186 assert_equal 1, Issue.recently_updated.with_limit(1).length
General Comments 0
You need to be logged in to leave comments. Login now