ぼざクリ タグ広場 https://hub.nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
856 B

  1. require "test_helper"
  2. class PostsControllerTest < ActionDispatch::IntegrationTest
  3. setup do
  4. @post = posts(:one)
  5. end
  6. test "should get index" do
  7. get posts_url, as: :json
  8. assert_response :success
  9. end
  10. test "should create post" do
  11. assert_difference("Post.count") do
  12. post posts_url, params: { post: { body: @post.body, title: @post.title } }, as: :json
  13. end
  14. assert_response :created
  15. end
  16. test "should show post" do
  17. get post_url(@post), as: :json
  18. assert_response :success
  19. end
  20. test "should update post" do
  21. patch post_url(@post), params: { post: { body: @post.body, title: @post.title } }, as: :json
  22. assert_response :success
  23. end
  24. test "should destroy post" do
  25. assert_difference("Post.count", -1) do
  26. delete post_url(@post), as: :json
  27. end
  28. assert_response :no_content
  29. end
  30. end