@@ -45,23 +45,27 module WatchersHelper | |||||
45 | # Returns a comma separated list of users watching the given object |
|
45 | # Returns a comma separated list of users watching the given object | |
46 | def watchers_list(object) |
|
46 | def watchers_list(object) | |
47 | remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project) |
|
47 | remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project) | |
|
48 | content = ''.html_safe | |||
48 | lis = object.watcher_users.collect do |user| |
|
49 | lis = object.watcher_users.collect do |user| | |
49 | s = avatar(user, :size => "16").to_s + link_to_user(user, :class => 'user').to_s |
|
50 | s = ''.html_safe | |
|
51 | s << avatar(user, :size => "16").to_s | |||
|
52 | s << link_to_user(user, :class => 'user') | |||
50 | if remove_allowed |
|
53 | if remove_allowed | |
51 | url = {:controller => 'watchers', |
|
54 | url = {:controller => 'watchers', | |
52 | :action => 'destroy', |
|
55 | :action => 'destroy', | |
53 | :object_type => object.class.to_s.underscore, |
|
56 | :object_type => object.class.to_s.underscore, | |
54 | :object_id => object.id, |
|
57 | :object_id => object.id, | |
55 | :user_id => user} |
|
58 | :user_id => user} | |
56 | s += ' ' + link_to_remote(image_tag('delete.png'), |
|
59 | s << ' ' | |
|
60 | s << link_to_remote(image_tag('delete.png'), | |||
57 | {:url => url}, |
|
61 | {:url => url}, | |
58 | :href => url_for(url), |
|
62 | :href => url_for(url), | |
59 | :style => "vertical-align: middle", |
|
63 | :style => "vertical-align: middle", | |
60 | :class => "delete") |
|
64 | :class => "delete") | |
61 | end |
|
65 | end | |
62 |
content_tag |
|
66 | content << content_tag('li', s) | |
63 | end |
|
67 | end | |
64 | (lis.empty? ? "" : "<ul>#{ lis.join("\n") }</ul>").html_safe |
|
68 | content.present? ? content_tag('ul', content) : content | |
65 | end |
|
69 | end | |
66 |
|
70 | |||
67 | def watchers_checkboxes(object, users, checked=nil) |
|
71 | def watchers_checkboxes(object, users, checked=nil) |
@@ -1126,6 +1126,36 class IssuesControllerTest < ActionController::TestCase | |||||
1126 | assert_tag 'a', :attributes => {:href => "/projects/ecookbook/repository/revisions/3"} |
|
1126 | assert_tag 'a', :attributes => {:href => "/projects/ecookbook/repository/revisions/3"} | |
1127 | end |
|
1127 | end | |
1128 |
|
1128 | |||
|
1129 | def test_show_should_display_watchers | |||
|
1130 | @request.session[:user_id] = 2 | |||
|
1131 | Issue.find(1).add_watcher User.find(2) | |||
|
1132 | ||||
|
1133 | get :show, :id => 1 | |||
|
1134 | assert_select 'div#watchers ul' do | |||
|
1135 | assert_select 'li' do | |||
|
1136 | assert_select 'a[href=/users/2]' | |||
|
1137 | assert_select 'a img[alt=Delete]' | |||
|
1138 | end | |||
|
1139 | end | |||
|
1140 | end | |||
|
1141 | ||||
|
1142 | def test_show_should_display_watchers_with_gravatars | |||
|
1143 | @request.session[:user_id] = 2 | |||
|
1144 | Issue.find(1).add_watcher User.find(2) | |||
|
1145 | ||||
|
1146 | with_settings :gravatar_enabled => '1' do | |||
|
1147 | get :show, :id => 1 | |||
|
1148 | end | |||
|
1149 | ||||
|
1150 | assert_select 'div#watchers ul' do | |||
|
1151 | assert_select 'li' do | |||
|
1152 | assert_select 'img.gravatar' | |||
|
1153 | assert_select 'a[href=/users/2]' | |||
|
1154 | assert_select 'a img[alt=Delete]' | |||
|
1155 | end | |||
|
1156 | end | |||
|
1157 | end | |||
|
1158 | ||||
1129 | def test_show_with_multi_custom_field |
|
1159 | def test_show_with_multi_custom_field | |
1130 | field = CustomField.find(1) |
|
1160 | field = CustomField.find(1) | |
1131 | field.update_attribute :multiple, true |
|
1161 | field.update_attribute :multiple, true |
General Comments 0
You need to be logged in to leave comments.
Login now