Pārlūkot izejas kodu

Fixed that issues can be moved to projects with issue tracking disabled (#10467).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9267 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/1.4.0
Jean-Philippe Lang pirms 12 gadiem
vecāks
revīzija
1294f72175
2 mainītis faili ar 10 papildinājumiem un 28 dzēšanām
  1. 1
    12
      app/models/issue.rb
  2. 9
    16
      test/unit/issue_test.rb

+ 1
- 12
app/models/issue.rb Parādīt failu

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

+ 9
- 16
test/unit/issue_test.rb Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt