Feature #16045 » previous-assignee-v4.patch
app/helpers/application_helper.rb | ||
---|---|---|
672 | 672 |
if collection.include?(User.current) |
673 | 673 |
s << content_tag('option', "<< #{l(:label_me)} >>", :value => User.current.id) |
674 | 674 |
end |
675 |
# do not add option in case of bulk and issue category edit |
|
676 |
if @issue.present? |
|
677 |
prior_assignee = @issue.prior_assigned_to |
|
678 |
if prior_assignee && prior_assignee != User.current && collection.include?(prior_assignee) |
|
679 |
s << content_tag('option', |
|
680 |
"<< #{l(:label_previous_assignee, name: prior_assignee.name)} >>", |
|
681 |
value: prior_assignee.id) |
|
682 |
end |
|
683 |
end |
|
684 | ||
675 | 685 |
groups = +'' |
676 | 686 |
collection.sort.each do |element| |
677 | 687 |
if option_value_selected?(element, selected) || element.id.to_s == selected |
app/models/issue.rb | ||
---|---|---|
925 | 925 |
result |
926 | 926 |
end |
927 | 927 | |
928 |
# Returns the assignee immediately prior to the current one from the issue history |
|
929 |
def prior_assigned_to |
|
930 |
prior_assigned_to_id = |
|
931 |
journals.joins(:details) |
|
932 |
.where(details: {prop_key: 'assigned_to_id'}) |
|
933 |
.where.not(details: {old_value: nil}) |
|
934 |
.order(id: :desc) |
|
935 |
.pick(:old_value) |
|
936 | ||
937 |
prior_assigned_to_id && Principal.find_by(id: prior_assigned_to_id) |
|
938 |
end |
|
939 | ||
928 | 940 |
# Returns the initial status of the issue |
929 | 941 |
# Returns nil for a new issue |
930 | 942 |
def status_was |
config/locales/en.yml | ||
---|---|---|
909 | 909 |
label_optional: optional |
910 | 910 |
label_show_completed_versions: Show completed versions |
911 | 911 |
label_me: me |
912 |
label_previous_assignee: "Previous: %{name}" |
|
912 | 913 |
label_board: Forum |
913 | 914 |
label_board_new: New forum |
914 | 915 |
label_board_plural: Forums |
test/helpers/application_helper_test.rb | ||
---|---|---|
2070 | 2070 |
principals_options_for_select(users) |
2071 | 2071 |
end |
2072 | 2072 | |
2073 |
def test_principals_options_for_select_should_include_previous_assignee_option_when_previous_assignee_is_in_collection |
|
2074 |
set_language_if_valid 'en' |
|
2075 |
users = [User.find(2), User.find(3)] |
|
2076 |
@issue = Issue.generate!(assigned_to_id: 2) |
|
2077 |
@issue.init_journal(users.first, 'update') |
|
2078 |
@issue.assigned_to_id = 3 |
|
2079 |
@issue.save |
|
2080 | ||
2081 |
# when previous assignee is not in collection |
|
2082 |
assert_not_include 'Previous:', principals_options_for_select([User.find(3)]) |
|
2083 |
# when previous assignee is not in collection |
|
2084 |
assert_include '<option value="2"><< Previous: John Smith >></option>', principals_options_for_select(users) |
|
2085 |
end |
|
2086 | ||
2087 |
def test_principals_options_for_select_should_include_previous_assignee_option_when_previous_assignee_is_not_current_user |
|
2088 |
set_language_if_valid 'en' |
|
2089 |
users = [User.find(2), User.find(3)] |
|
2090 |
@issue = Issue.generate!(assigned_to_id: 2) |
|
2091 |
@issue.init_journal(users.first, 'update') |
|
2092 |
@issue.assigned_to_id = 3 |
|
2093 |
@issue.save |
|
2094 | ||
2095 |
# when previous_assignee is current user |
|
2096 |
User.current = User.find(2) |
|
2097 |
assert_not_include 'Previous:', principals_options_for_select(users) |
|
2098 |
# when previous_assignee is not current user |
|
2099 |
User.current = User.find(3) |
|
2100 |
assert_include '<option value="2"><< Previous: John Smith >></option>', principals_options_for_select(users) |
|
2101 |
end |
|
2102 | ||
2073 | 2103 |
def test_stylesheet_link_tag_should_pick_the_default_stylesheet |
2074 | 2104 |
assert_match 'href="/assets/styles.css"', stylesheet_link_tag("styles") |
2075 | 2105 |
end |
test/unit/issue_test.rb | ||
---|---|---|
3247 | 3247 |
assert_equal was_closed_on, issue.closed_on |
3248 | 3248 |
end |
3249 | 3249 | |
3250 |
def test_prior_assigned_to |
|
3251 |
issue = Issue.generate!(assigned_to_id: 2) |
|
3252 |
issue.init_journal(User.find(2), 'update') |
|
3253 |
issue.assigned_to_id = 3 |
|
3254 |
issue.save |
|
3255 | ||
3256 |
assert_equal User.find(2), issue.prior_assigned_to |
|
3257 |
end |
|
3258 | ||
3259 |
def test_prior_assigned_to_should_return_nil |
|
3260 |
issue = Issue.generate!(assigned_to_id: 2) |
|
3261 |
issue.assigned_to_id = 3 |
|
3262 |
issue.save |
|
3263 | ||
3264 |
assert_equal 0, issue.journals.count |
|
3265 |
assert_nil issue.prior_assigned_to |
|
3266 |
end |
|
3267 | ||
3250 | 3268 |
def test_status_was_should_return_nil_for_new_issue |
3251 | 3269 |
issue = Issue.new |
3252 | 3270 |
assert_nil issue.status_was |