Defect #33417 ยป 33417.patch
| app/models/issue.rb | ||
|---|---|---|
| 723 | 723 |
errors.add :start_date, :earlier_than_minimum_start_date, :date => format_date(soonest_start) |
| 724 | 724 |
end |
| 725 | 725 | |
| 726 |
if fixed_version |
|
| 726 |
if project && fixed_version
|
|
| 727 | 727 |
if !assignable_versions.include?(fixed_version) |
| 728 | 728 |
errors.add :fixed_version_id, :inclusion |
| 729 | 729 |
elsif reopening? && fixed_version.closed? |
| ... | ... | |
| 738 | 738 |
end |
| 739 | 739 |
end |
| 740 | 740 | |
| 741 |
if assigned_to_id_changed? && assigned_to_id.present? |
|
| 741 |
if project && assigned_to_id_changed? && assigned_to_id.present?
|
|
| 742 | 742 |
unless assignable_users.include?(assigned_to) |
| 743 | 743 |
errors.add :assigned_to_id, :invalid |
| 744 | 744 |
end |
| ... | ... | |
| 938 | 938 | |
| 939 | 939 |
# Users the issue can be assigned to |
| 940 | 940 |
def assignable_users |
| 941 |
return [] if project.nil? |
|
| 942 | ||
| 941 | 943 |
users = project.assignable_users(tracker).to_a |
| 942 | 944 |
users << author if author && author.active? |
| 943 | 945 |
if assigned_to_id_was.present? && assignee = Principal.find_by_id(assigned_to_id_was) |
| ... | ... | |
| 949 | 951 |
# Versions that the issue can be assigned to |
| 950 | 952 |
def assignable_versions |
| 951 | 953 |
return @assignable_versions if @assignable_versions |
| 954 |
return [] if project.nil? |
|
| 952 | 955 | |
| 953 | 956 |
versions = project.shared_versions.open.to_a |
| 954 | 957 |
if fixed_version |
| test/integration/api_test/issues_test.rb | ||
|---|---|---|
| 663 | 663 |
assert_response 422 |
| 664 | 664 |
end |
| 665 | 665 | |
| 666 |
test "POST /issues.json with invalid project_id and any assigned_to_id should respond with 422" do |
|
| 667 |
post( |
|
| 668 |
'/issues.json', |
|
| 669 |
:params => {
|
|
| 670 |
:issue => {
|
|
| 671 |
:project_id => 999, |
|
| 672 |
:assigned_to_id => 1, |
|
| 673 |
:subject => 'API' |
|
| 674 |
} |
|
| 675 |
}, |
|
| 676 |
:headers => credentials('jsmith'))
|
|
| 677 |
assert_response 422 |
|
| 678 |
end |
|
| 679 | ||
| 680 |
test "POST /issues.json with invalid project_id and any fixed_version_id should respond with 422" do |
|
| 681 |
post( |
|
| 682 |
'/issues.json', |
|
| 683 |
:params => {
|
|
| 684 |
:issue => {
|
|
| 685 |
:project_id => 999, |
|
| 686 |
:fixed_version_id => 1, |
|
| 687 |
:subject => 'API' |
|
| 688 |
} |
|
| 689 |
}, |
|
| 690 |
:headers => credentials('jsmith'))
|
|
| 691 |
assert_response 422 |
|
| 692 |
end |
|
| 693 | ||
| 666 | 694 |
test "PUT /issues/:id.xml" do |
| 667 | 695 |
assert_difference('Journal.count') do
|
| 668 | 696 |
put( |