提交 0db68fd1 编写于 作者: J José Valim

Change functional tests to make use of a setup block.

上级 e13c1794
require 'test_helper'
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
setup do
@<%= file_name %> = <%= table_name %>(:one)
end
<% unless options[:singleton] -%>
test "should get index" do
get :index
......@@ -16,30 +20,30 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
test "should create <%= file_name %>" do
assert_difference('<%= class_name %>.count') do
post :create, :<%= file_name %> => <%= table_name %>(:one).attributes
post :create, :<%= file_name %> => @<%= file_name %>.attributes
end
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
end
test "should show <%= file_name %>" do
get :show, :id => <%= table_name %>(:one).to_param
get :show, :id => @<%= file_name %>.to_param
assert_response :success
end
test "should get edit" do
get :edit, :id => <%= table_name %>(:one).to_param
get :edit, :id => @<%= file_name %>.to_param
assert_response :success
end
test "should update <%= file_name %>" do
put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => <%= table_name %>(:one).attributes
put :update, :id => @<%= file_name %>.to_param, :<%= file_name %> => @<%= file_name %>.attributes
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
end
test "should destroy <%= file_name %>" do
assert_difference('<%= class_name %>.count', -1) do
delete :destroy, :id => <%= table_name %>(:one).to_param
delete :destroy, :id => @<%= file_name %>.to_param
end
assert_redirected_to <%= table_name %>_path
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册