Use Rails helpers for the delete menu item

Instead of creating id and routes manually, use the helpers that Rails
provides in order to do this for us.
This commit is contained in:
Matt Rogers 2015-02-18 08:24:08 -06:00
parent 3bef4daacc
commit 6677af6f8f
2 changed files with 6 additions and 1 deletions

View file

@ -166,7 +166,7 @@ module TodosHelper
t('todos.delete'),
{:controller => 'todos', :action => 'destroy', :id => todo.id},
:class => "icon_delete_item",
:id => "delete_#{dom_id(todo)}",
:id => dom_id(todo, "delete"),
:x_confirm_message => t('todos.confirm_delete', :description => todo.description),
:title => t('todos.delete_action'));
end

View file

@ -7,4 +7,9 @@ class TodosHelpersTest < ActionView::TestCase
html = remote_edit_button(todos(:call_bill))
assert_equal "<a class=\"icon edit_item\" href=\"/todos/1/edit\" id=\"icon_edit_todo_1\" title=\"Edit the action &#39;Call Bill Gates to find out how much he makes per day&#39;\"><img align=\"absmiddle\" alt=\"Edit\" class=\"edit_item\" id=\"edit_icon_todo_1\" src=\"/images/blank.png\" /></a>", html
end
test "remote_delete_menu" do
html = remote_delete_menu_item(todos(:call_bill))
assert_equal "<a class=\"icon_delete_item\" href=\"/todos/1\" id=\"delete_todo_1\" title=\"Delete action\" x_confirm_message=\"Are you sure that you want to delete the action &#39;Call Bill Gates to find out how much he makes per day&#39;?\">Delete</a>", html
end
end