Scaffold Todo
This commit is contained in:
48
test/controllers/todos_controller_test.rb
Normal file
48
test/controllers/todos_controller_test.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
require "test_helper"
|
||||
|
||||
class TodosControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@todo = todos(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get todos_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_todo_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create todo" do
|
||||
assert_difference("Todo.count") do
|
||||
post todos_url, params: { todo: { description: @todo.description, name: @todo.name } }
|
||||
end
|
||||
|
||||
assert_redirected_to todo_url(Todo.last)
|
||||
end
|
||||
|
||||
test "should show todo" do
|
||||
get todo_url(@todo)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get edit_todo_url(@todo)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update todo" do
|
||||
patch todo_url(@todo), params: { todo: { description: @todo.description, name: @todo.name } }
|
||||
assert_redirected_to todo_url(@todo)
|
||||
end
|
||||
|
||||
test "should destroy todo" do
|
||||
assert_difference("Todo.count", -1) do
|
||||
delete todo_url(@todo)
|
||||
end
|
||||
|
||||
assert_redirected_to todos_url
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user