]> source.dussan.org Git - redmine.git/commitdiff
Add watching users to a ticket should switch "watch" link to "unwatch" if own user...
authorGo MAEDA <maeda@farend.jp>
Sun, 25 Jul 2021 02:27:54 +0000 (02:27 +0000)
committerGo MAEDA <maeda@farend.jp>
Sun, 25 Jul 2021 02:27:54 +0000 (02:27 +0000)
Patch by Takenori TAKAKI.

git-svn-id: http://svn.redmine.org/redmine/trunk@21079 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/watchers/create.js.erb
app/views/watchers/destroy.js.erb
test/system/issues_test.rb

index 7541d20ff9da80875344bd7d92a8027ebe2bbd64..b0421bc3a34abef3019cf0ef117a3395d51df7e0 100644 (file)
@@ -4,8 +4,6 @@ $('#ajax-modal').html(
                 :locals => {:watchables => @watchables, :users => @users})) %>');
 
 <% if @watchables.size == 1 %>
-  $('#watchers').html(
-    '<%= escape_javascript(
-           render(:partial => 'watchers/watchers',
-                  :locals => {:watched => @watchables.first})) %>');
+  <%= render(:partial => 'watchers/set_watcher',
+             :locals => {:watched => @watchables, :user => User.current}) %>
 <% end %>
index 413797dc298d30765da11845c4e8a54b6cb782cb..12553e8e5946f78881d55c35989a62cadf56ed87 100644 (file)
@@ -1,3 +1,4 @@
 <% if @watchables.size == 1 %>
-$('#watchers').html('<%= escape_javascript(render(:partial => 'watchers/watchers', :locals => {:watched => @watchables.first})) %>');
+  <%= render(:partial => 'watchers/set_watcher',
+            :locals => {:watched => @watchables, :user => User.current}) %>
 <% end %>
index 1d77a982982f4ebf569fb7887a2cf2cc078c8e39..4f4939a9b3e8d9865ffe036bb5c94be572a39518 100644 (file)
@@ -290,6 +290,21 @@ class IssuesSystemTest < ApplicationSystemTestCase
     assert issue1.reload.watched_by?(jsmith)
   end
 
+  def test_change_watch_or_unwatch_icon_from_sidebar
+    user = User.find(2)
+    log_user('jsmith', 'jsmith')
+    visit '/issues/1'
+    assert page.has_css?('#content .contextual .issue-1-watcher.icon-fav-off')
+    # add watcher 'jsmith' from sidebar
+    page.find('#watchers .contextual a', :text => 'Add').click
+    page.find('#users_for_watcher label', :text => 'John Smith').click
+    page.find('#new-watcher-form p.buttons input[type=submit]').click
+    assert page.has_css?('#content .contextual .issue-1-watcher.icon-fav')
+    # remove watcher 'jsmith' from sidebar
+    page.find('#watchers ul li.user-2 a.delete').click
+    assert page.has_css?('#content .contextual .issue-1-watcher.icon-fav-off')
+  end
+
   def test_bulk_watch_issues_via_context_menu
     log_user('jsmith', 'jsmith')
     visit '/issues'