diff options
-rw-r--r-- | app/models/issue.rb | 13 | ||||
-rw-r--r-- | test/unit/issue_test.rb | 25 |
2 files changed, 10 insertions, 28 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index ee394a87b..f85ddfec4 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -800,18 +800,7 @@ class Issue < ActiveRecord::Base # Returns an array of projects that user can move issues to def self.allowed_target_projects_on_move(user=User.current) - projects = [] - if user.admin? - # admin is allowed to move issues to any active (visible) project - projects = Project.visible(user).all - elsif user.logged? - if Role.non_member.allowed_to?(:move_issues) - projects = Project.visible(user).all - else - user.memberships.each {|m| projects << m.project if m.roles.detect {|r| r.allowed_to?(:move_issues)}} - end - end - projects + Project.all(:conditions => Project.allowed_to_condition(user, :move_issues)) end private diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index bd54de705..ddebbee19 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -530,6 +530,15 @@ class IssueTest < ActiveSupport::TestCase assert issue.save end + def test_allowed_target_projects_on_move_should_include_projects_with_issue_tracking_enabled + assert_include Project.find(2), Issue.allowed_target_projects_on_move(User.find(2)) + end + + def test_allowed_target_projects_on_move_should_not_include_projects_with_issue_tracking_disabled + Project.find(2).disable_module! :issue_tracking + assert_not_include Project.find(2), Issue.allowed_target_projects_on_move(User.find(2)) + end + def test_move_to_another_project_with_same_category issue = Issue.find(1) issue.project = Project.find(2) @@ -1172,22 +1181,6 @@ class IssueTest < ActiveSupport::TestCase assert_equal 2, groups.inject(0) {|sum, group| sum + group['total'].to_i} end - context ".allowed_target_projects_on_move" do - should "return all active projects for admin users" do - User.current = User.find(1) - assert_equal Project.active.count, Issue.allowed_target_projects_on_move.size - end - - should "return allowed projects for non admin users" do - User.current = User.find(2) - Role.non_member.remove_permission! :move_issues - assert_equal 3, Issue.allowed_target_projects_on_move.size - - Role.non_member.add_permission! :move_issues - assert_equal Project.active.count, Issue.allowed_target_projects_on_move.size - end - end - def test_recently_updated_with_limit_scopes #should return the last updated issue assert_equal 1, Issue.recently_updated.with_limit(1).length |