Defect #38458 ยป test-for-38458-note-2.patch
| app/helpers/watchers_helper.rb | ||
|---|---|---|
|
def watchers_list(object)
|
||
|
remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project)
|
||
|
content = ''.html_safe
|
||
|
lis = object.watcher_users.collect do |user|
|
||
|
lis = object.watcher_users.sorted.collect do |user|
|
||
|
s = ''.html_safe
|
||
|
s << avatar(user, :size => "16").to_s
|
||
|
s << link_to_principal(user, class: user.class.to_s.downcase)
|
||
| test/helpers/watchers_helper_test.rb | ||
|---|---|---|
|
class WatchersHelperTest < Redmine::HelperTest
|
||
|
include WatchersHelper
|
||
|
include AvatarsHelper
|
||
|
include ERB::Util
|
||
|
include Rails.application.routes.url_helpers
|
||
|
fixtures :users, :issues
|
||
| ... | ... | |
|
)
|
||
|
assert_equal expected, watcher_link(Issue.find(1), User.find(1))
|
||
|
end
|
||
|
def test_watchers_list_should_be_sorted_by_user_name
|
||
|
issue = Issue.find(1)
|
||
|
[1, 2, 3].shuffle.each do |user_id|
|
||
|
Watcher.create!(:watchable => issue, :user => User.find(user_id))
|
||
|
end
|
||
|
with_settings user_format: 'firstname_lastname' do
|
||
|
result1 = watchers_list(issue)
|
||
|
assert_select_in result1, 'ul.watchers' do
|
||
|
assert_select 'li', 3
|
||
|
assert_select 'li:nth-of-type(1)>a[href=?]', '/users/3', text: 'Dave Lopper'
|
||
|
assert_select 'li:nth-of-type(2)>a[href=?]', '/users/2', text: 'John Smith'
|
||
|
assert_select 'li:nth-of-type(3)>a[href=?]', '/users/1', text: 'Redmine Admin'
|
||
|
end
|
||
|
end
|
||
|
with_settings user_format: 'lastname_firstname' do
|
||
|
result2 = watchers_list(issue)
|
||
|
assert_select_in result2, 'ul.watchers' do
|
||
|
assert_select 'li', 3
|
||
|
assert_select 'li:nth-of-type(1)>a[href=?]', '/users/1', text: 'Admin Redmine'
|
||
|
assert_select 'li:nth-of-type(2)>a[href=?]', '/users/3', text: 'Lopper Dave'
|
||
|
assert_select 'li:nth-of-type(3)>a[href=?]', '/users/2', text: 'Smith John'
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||