Skip to content

Commit

Permalink
Fixed that delete watcher link was broken by r11290 (#13231).
Browse files Browse the repository at this point in the history
Deleting a watcher now use DELETE /watchers instead of POST /watchers/destroy.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11443 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jplang committed Feb 20, 2013
1 parent f8c6493 commit aca3197
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/helpers/watchers_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ def watchers_list(object)
:user_id => user}
s << ' '
s << link_to(image_tag('delete.png'), url,
:remote => true, :method => 'post', :style => "vertical-align: middle", :class => "delete")
:remote => true, :method => 'delete', :style => "vertical-align: middle", :class => "delete")
end
content << content_tag('li', s)
content << content_tag('li', s, :class => "user-#{user.id}")
end
content.present? ? content_tag('ul', content) : content
content.present? ? content_tag('ul', content, :class => 'watchers') : content
end

def watchers_checkboxes(object, users, checked=nil)
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
get 'watchers/new', :to => 'watchers#new'
post 'watchers', :to => 'watchers#create'
post 'watchers/append', :to => 'watchers#append'
post 'watchers/destroy', :to => 'watchers#destroy'
delete 'watchers', :to => 'watchers#destroy'
get 'watchers/autocomplete_for_user', :to => 'watchers#autocomplete_for_user'
# Specific routes for issue watchers API
post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue'
Expand Down
2 changes: 1 addition & 1 deletion test/functional/watchers_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_append
def test_remove_watcher
@request.session[:user_id] = 2
assert_difference('Watcher.count', -1) do
xhr :post, :destroy, :object_type => 'issue', :object_id => '2', :user_id => '3'
xhr :delete, :destroy, :object_type => 'issue', :object_id => '2', :user_id => '3'
assert_response :success
assert_match /watchers/, response.body
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/routing/watchers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_watchers
{ :controller => 'watchers', :action => 'create' }
)
assert_routing(
{ :method => 'post', :path => "/watchers/destroy" },
{ :method => 'delete', :path => "/watchers" },
{ :controller => 'watchers', :action => 'destroy' }
)
assert_routing(
Expand Down
13 changes: 13 additions & 0 deletions test/ui/issues_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,19 @@ def test_update_issue_with_form_update
assert_equal 'CF value', issue.custom_field_value(field)
end

def test_remove_issue_watcher_from_sidebar
user = User.find(3)
Watcher.create!(:watchable => Issue.find(1), :user => user)

log_user('jsmith', 'jsmith')
visit '/issues/1'
assert page.first('#sidebar').has_content?(user.name)
assert_difference 'Watcher.count', -1 do
page.first('ul.watchers .user-3 a.delete').click
end
assert page.first('#sidebar').has_no_content?(user.name)
end

def test_watch_issue_via_context_menu
log_user('jsmith', 'jsmith')
visit '/issues'
Expand Down

0 comments on commit aca3197

Please sign in to comment.