Feature #16045 » previous-assignee-v2.0.patch
| app/helpers/application_helper.rb | ||
|---|---|---|
| 482 | 482 |
if collection.include?(User.current) |
| 483 | 483 |
s << content_tag('option', "<< #{l(:label_me)} >>", :value => User.current.id)
|
| 484 | 484 |
end |
| 485 |
# do not add option in case of bulk and issue category edit |
|
| 486 |
unless @issue.nil? |
|
| 487 |
last_assignee = @issue.last_assigned_to |
|
| 488 |
s << content_tag('option', "<< #{l(:label_last_assignee, name: last_assignee.name)} >>", value: last_assignee.id) if last_assignee && last_assignee != User.current && collection.include?(last_assignee)
|
|
| 489 |
end |
|
| 485 | 490 |
groups = '' |
| 486 | 491 |
collection.sort.each do |element| |
| 487 | 492 |
selected_attribute = ' selected="selected"' if option_value_selected?(element, selected) || element.id.to_s == selected |
| app/models/issue.rb | ||
|---|---|---|
| 866 | 866 |
result |
| 867 | 867 |
end |
| 868 | 868 | |
| 869 |
# Returns the last assignee from the issue history |
|
| 870 |
def last_assigned_to |
|
| 871 |
journals.reverse_each do |j| |
|
| 872 |
last_assignee_change = j.detail_for_attribute 'assigned_to_id' |
|
| 873 |
return User.find_by(id: last_assignee_change.old_value.to_i) if last_assignee_change && last_assignee_change.old_value |
|
| 874 |
end |
|
| 875 |
end |
|
| 876 | ||
| 869 | 877 |
# Returns the initial status of the issue |
| 870 | 878 |
# Returns nil for a new issue |
| 871 | 879 |
def status_was |
| config/locales/en.yml | ||
|---|---|---|
| 839 | 839 |
label_disabled: disabled |
| 840 | 840 |
label_show_completed_versions: Show completed versions |
| 841 | 841 |
label_me: me |
| 842 |
label_last_assignee: "Last: %{name}"
|
|
| 842 | 843 |
label_board: Forum |
| 843 | 844 |
label_board_new: New forum |
| 844 | 845 |
label_board_plural: Forums |
| test/helpers/application_helper_test.rb | ||
|---|---|---|
| 1568 | 1568 |
assert_include '<option value="4"><< me >></option>', principals_options_for_select(users) |
| 1569 | 1569 |
end |
| 1570 | 1570 | |
| 1571 |
def test_principals_options_for_select_should_include_last_assignee_option_when_last_assignee_is_in_collection |
|
| 1572 |
set_language_if_valid 'en' |
|
| 1573 |
users = [User.find(2), User.find(3)] |
|
| 1574 |
@issue = Issue.generate!(assigned_to_id: 2) |
|
| 1575 |
@issue.init_journal(users.first, 'update') |
|
| 1576 |
@issue.assigned_to_id = 3 |
|
| 1577 |
@issue.save |
|
| 1578 | ||
| 1579 |
# when last assignee is not in collection |
|
| 1580 |
assert_not_include 'Last:', principals_options_for_select([User.find(3)]) |
|
| 1581 |
# when last assignee is not in collection |
|
| 1582 |
assert_include '<option value="2"><< Last: John Smith >></option>', principals_options_for_select(users) |
|
| 1583 |
end |
|
| 1584 | ||
| 1585 |
def test_principals_options_for_select_should_include_last_assignee_option_when_last_assignee_is_not_current_user |
|
| 1586 |
set_language_if_valid 'en' |
|
| 1587 |
users = [User.find(2), User.find(3)] |
|
| 1588 |
@issue = Issue.generate!(assigned_to_id: 2) |
|
| 1589 |
@issue.init_journal(users.first, 'update') |
|
| 1590 |
@issue.assigned_to_id = 3 |
|
| 1591 |
@issue.save |
|
| 1592 | ||
| 1593 |
# when last_assignee is current user |
|
| 1594 |
User.current = User.find(2) |
|
| 1595 |
assert_not_include 'Last:', principals_options_for_select(users) |
|
| 1596 |
# when last_assignee is not current user |
|
| 1597 |
User.current = User.find(3) |
|
| 1598 |
assert_include '<option value="2"><< Last: John Smith >></option>', principals_options_for_select(users) |
|
| 1599 |
end |
|
| 1600 | ||
| 1571 | 1601 |
def test_stylesheet_link_tag_should_pick_the_default_stylesheet |
| 1572 | 1602 |
assert_match 'href="/stylesheets/styles.css"', stylesheet_link_tag("styles")
|
| 1573 | 1603 |
end |
| test/unit/issue_test.rb | ||
|---|---|---|
| 2990 | 2990 |
assert_equal was_closed_on, issue.closed_on |
| 2991 | 2991 |
end |
| 2992 | 2992 | |
| 2993 |
def test_last_assigned_to |
|
| 2994 |
issue = Issue.generate!(assigned_to_id: 2) |
|
| 2995 |
issue.init_journal(User.find(2), 'update') |
|
| 2996 |
issue.assigned_to_id = 3 |
|
| 2997 |
issue.save |
|
| 2998 | ||
| 2999 |
assert_equal User.find(2), issue.last_assigned_to |
|
| 3000 |
end |
|
| 3001 | ||
| 2993 | 3002 |
def test_status_was_should_return_nil_for_new_issue |
| 2994 | 3003 |
issue = Issue.new |
| 2995 | 3004 |
assert_nil issue.status_was |