Defect #44042 ยป 0001-Fix-watchers-section-in-sidebar-incorrectly-updated-.patch
| app/views/issues/show.html.erb | ||
|---|---|---|
| 166 | 166 | |
| 167 | 167 |
<% if User.current.allowed_to?(:add_issue_watchers, @project) || |
| 168 | 168 |
(@issue.watchers.present? && User.current.allowed_to?(:view_issue_watchers, @project)) %> |
| 169 |
<div id="watchers"> |
|
| 169 |
<div id="watchers" data-watchable-id="<%= @issue.id %>">
|
|
| 170 | 170 |
<%= render :partial => 'watchers/watchers', :locals => {:watched => @issue} %>
|
| 171 | 171 |
</div> |
| 172 | 172 |
<% end %> |
| app/views/watchers/_set_watcher.js.erb | ||
|---|---|---|
| 1 | 1 |
<% selector = ".#{watcher_css(watched)}" %>
|
| 2 | 2 |
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link(watched, user) %>")});
|
| 3 |
<% if watched.first.is_a?(Issue) %> |
|
| 4 |
$('#watchers[data-watchable-id="<%= watched.first.id %>"]').html('<%= escape_javascript(render(:partial => 'watchers/watchers', :locals => {:watched => watched.first})) %>');
|
|
| 5 |
<% else %> |
|
| 3 | 6 |
$('#watchers').html('<%= escape_javascript(render(:partial => 'watchers/watchers', :locals => {:watched => watched.first})) %>');
|
| 7 |
<% end %> |
|
| test/functional/watchers_controller_test.rb | ||
|---|---|---|
| 65 | 65 |
assert Issue.find(3).watched_by?(User.find(3)) |
| 66 | 66 |
end |
| 67 | 67 | |
| 68 |
def test_watch_an_issue_should_use_data_attribute_selector_for_watchers_sidebar |
|
| 69 |
@request.session[:user_id] = 2 |
|
| 70 |
post :watch, :params => {:object_type => 'issue', :object_id => '1'}, :xhr => true
|
|
| 71 |
assert_response :success |
|
| 72 |
assert_include "$('#watchers[data-watchable-id=\"1\"]')", response.body
|
|
| 73 |
assert_not_include "$('#watchers').html(", response.body
|
|
| 74 |
end |
|
| 75 | ||
| 76 |
def test_watch_a_message_should_not_use_data_attribute_selector_for_watchers_sidebar |
|
| 77 |
@request.session[:user_id] = 2 |
|
| 78 |
post :watch, :params => {:object_type => 'message', :object_id => '1'}, :xhr => true
|
|
| 79 |
assert_response :success |
|
| 80 |
assert_include "$('#watchers').html(", response.body
|
|
| 81 |
end |
|
| 82 | ||
| 68 | 83 |
def test_watch_a_news_module_should_add_watcher |
| 69 | 84 |
@request.session[:user_id] = 7 |
| 70 | 85 |
assert_not_nil m = Project.find(1).enabled_module('news')
|