21 |
21 |
|
22 |
22 |
class WatchersHelperTest < Redmine::HelperTest
|
23 |
23 |
include WatchersHelper
|
|
24 |
include AvatarsHelper
|
|
25 |
include ERB::Util
|
24 |
26 |
include Rails.application.routes.url_helpers
|
25 |
27 |
|
26 |
28 |
fixtures :users, :issues
|
... | ... | |
66 |
68 |
)
|
67 |
69 |
assert_equal expected, watcher_link(Issue.find(1), User.find(1))
|
68 |
70 |
end
|
|
71 |
|
|
72 |
def test_watchers_list_should_be_sorted_by_user_name
|
|
73 |
issue = Issue.find(1)
|
|
74 |
[1, 2, 3].shuffle.each do |user_id|
|
|
75 |
Watcher.create!(:watchable => issue, :user => User.find(user_id))
|
|
76 |
end
|
|
77 |
|
|
78 |
with_settings user_format: 'firstname_lastname' do
|
|
79 |
result1 = watchers_list(issue)
|
|
80 |
assert_select_in result1, 'ul.watchers' do
|
|
81 |
assert_select 'li', 3
|
|
82 |
assert_select 'li:nth-of-type(1)>a[href=?]', '/users/3', text: 'Dave Lopper'
|
|
83 |
assert_select 'li:nth-of-type(2)>a[href=?]', '/users/2', text: 'John Smith'
|
|
84 |
assert_select 'li:nth-of-type(3)>a[href=?]', '/users/1', text: 'Redmine Admin'
|
|
85 |
end
|
|
86 |
end
|
|
87 |
|
|
88 |
with_settings user_format: 'lastname_firstname' do
|
|
89 |
result2 = watchers_list(issue)
|
|
90 |
assert_select_in result2, 'ul.watchers' do
|
|
91 |
assert_select 'li', 3
|
|
92 |
assert_select 'li:nth-of-type(1)>a[href=?]', '/users/1', text: 'Admin Redmine'
|
|
93 |
assert_select 'li:nth-of-type(2)>a[href=?]', '/users/3', text: 'Lopper Dave'
|
|
94 |
assert_select 'li:nth-of-type(3)>a[href=?]', '/users/2', text: 'Smith John'
|
|
95 |
end
|
|
96 |
end
|
|
97 |
end
|
69 |
98 |
end
|