Feature #16045 » previous-assignee-v4.patch
| app/helpers/application_helper.rb | ||
|---|---|---|
|
if collection.include?(User.current)
|
||
|
s << content_tag('option', "<< #{l(:label_me)} >>", :value => User.current.id)
|
||
|
end
|
||
|
# do not add option in case of bulk and issue category edit
|
||
|
if @issue.present?
|
||
|
prior_assignee = @issue.prior_assigned_to
|
||
|
if prior_assignee && prior_assignee != User.current && collection.include?(prior_assignee)
|
||
|
s << content_tag('option',
|
||
|
"<< #{l(:label_previous_assignee, name: prior_assignee.name)} >>",
|
||
|
value: prior_assignee.id)
|
||
|
end
|
||
|
end
|
||
|
groups = +''
|
||
|
collection.sort.each do |element|
|
||
|
if option_value_selected?(element, selected) || element.id.to_s == selected
|
||
| app/models/issue.rb | ||
|---|---|---|
|
result
|
||
|
end
|
||
|
# Returns the assignee immediately prior to the current one from the issue history
|
||
|
def prior_assigned_to
|
||
|
prior_assigned_to_id =
|
||
|
journals.joins(:details)
|
||
|
.where(details: {prop_key: 'assigned_to_id'})
|
||
|
.where.not(details: {old_value: nil})
|
||
|
.order(id: :desc)
|
||
|
.pick(:old_value)
|
||
|
prior_assigned_to_id && Principal.find_by(id: prior_assigned_to_id)
|
||
|
end
|
||
|
# Returns the initial status of the issue
|
||
|
# Returns nil for a new issue
|
||
|
def status_was
|
||
| config/locales/en.yml | ||
|---|---|---|
|
label_optional: optional
|
||
|
label_show_completed_versions: Show completed versions
|
||
|
label_me: me
|
||
|
label_previous_assignee: "Previous: %{name}"
|
||
|
label_board: Forum
|
||
|
label_board_new: New forum
|
||
|
label_board_plural: Forums
|
||
| test/helpers/application_helper_test.rb | ||
|---|---|---|
|
principals_options_for_select(users)
|
||
|
end
|
||
|
def test_principals_options_for_select_should_include_previous_assignee_option_when_previous_assignee_is_in_collection
|
||
|
set_language_if_valid 'en'
|
||
|
users = [User.find(2), User.find(3)]
|
||
|
@issue = Issue.generate!(assigned_to_id: 2)
|
||
|
@issue.init_journal(users.first, 'update')
|
||
|
@issue.assigned_to_id = 3
|
||
|
@issue.save
|
||
|
# when previous assignee is not in collection
|
||
|
assert_not_include 'Previous:', principals_options_for_select([User.find(3)])
|
||
|
# when previous assignee is not in collection
|
||
|
assert_include '<option value="2"><< Previous: John Smith >></option>', principals_options_for_select(users)
|
||
|
end
|
||
|
def test_principals_options_for_select_should_include_previous_assignee_option_when_previous_assignee_is_not_current_user
|
||
|
set_language_if_valid 'en'
|
||
|
users = [User.find(2), User.find(3)]
|
||
|
@issue = Issue.generate!(assigned_to_id: 2)
|
||
|
@issue.init_journal(users.first, 'update')
|
||
|
@issue.assigned_to_id = 3
|
||
|
@issue.save
|
||
|
# when previous_assignee is current user
|
||
|
User.current = User.find(2)
|
||
|
assert_not_include 'Previous:', principals_options_for_select(users)
|
||
|
# when previous_assignee is not current user
|
||
|
User.current = User.find(3)
|
||
|
assert_include '<option value="2"><< Previous: John Smith >></option>', principals_options_for_select(users)
|
||
|
end
|
||
|
def test_stylesheet_link_tag_should_pick_the_default_stylesheet
|
||
|
assert_match 'href="/assets/styles.css"', stylesheet_link_tag("styles")
|
||
|
end
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
assert_equal was_closed_on, issue.closed_on
|
||
|
end
|
||
|
def test_prior_assigned_to
|
||
|
issue = Issue.generate!(assigned_to_id: 2)
|
||
|
issue.init_journal(User.find(2), 'update')
|
||
|
issue.assigned_to_id = 3
|
||
|
issue.save
|
||
|
assert_equal User.find(2), issue.prior_assigned_to
|
||
|
end
|
||
|
def test_prior_assigned_to_should_return_nil
|
||
|
issue = Issue.generate!(assigned_to_id: 2)
|
||
|
issue.assigned_to_id = 3
|
||
|
issue.save
|
||
|
assert_equal 0, issue.journals.count
|
||
|
assert_nil issue.prior_assigned_to
|
||
|
end
|
||
|
def test_status_was_should_return_nil_for_new_issue
|
||
|
issue = Issue.new
|
||
|
assert_nil issue.status_was
|
||