はじまりの大地
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
require "test_helper"
|
||||
|
||||
class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@post = posts(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get posts_url, as: :json
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create post" do
|
||||
assert_difference("Post.count") do
|
||||
post posts_url, params: { post: { body: @post.body, title: @post.title } }, as: :json
|
||||
end
|
||||
|
||||
assert_response :created
|
||||
end
|
||||
|
||||
test "should show post" do
|
||||
get post_url(@post), as: :json
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update post" do
|
||||
patch post_url(@post), params: { post: { body: @post.body, title: @post.title } }, as: :json
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should destroy post" do
|
||||
assert_difference("Post.count", -1) do
|
||||
delete post_url(@post), as: :json
|
||||
end
|
||||
|
||||
assert_response :no_content
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user