Advertisement
sas2job

Untitled

Jul 19th, 2022
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. > в Модели Комментарии нет связи author там связь называется user (можно посмотреть в scheme.rb)
  2. Всё так
  3. create_table "comments", force: :cascade do |t|
  4. t.text "body", default: "", null: false
  5. t.bigint "user_id", null: false
  6. < ... >
  7. t.index ["user_id"], name: "index_comments_on_user_id"
  8. end
  9. Тем не менее не понятно
  10. Парамсы берутся из factories.
  11. Далее запускаем тест
  12. it "create a new comment" do
  13. post comments_path, params: { commentable_type: comment.class, commentable_id: comment.id }
  14. expect(Comment.first.body).to eq(comment)
  15. end
  16. и он падает на
  17. 1) Comments POST /comments/ user is sign in create a new comment
  18. Failure/Error: params.require(:comment).permit(:body, :commentable_type, :commentable_id)
  19.  
  20. ActionController::ParameterMissing:
  21. param is missing or the value is empty: comment
  22. Did you mean? commentable_id
  23. commentable_type
  24. controller
  25. action
  26. # ./app/controllers/comments_controller.rb:36:in `comment_params'
  27. # ./app/controllers/comments_controller.rb:32:in `load_commentable!'
  28. # ./spec/requests/comments_spec.rb:21:in `block (4 levels) in <top (required)>'
  29. При дебаге вижу только юзера
  30. pry(#<RSpec::ExampleGroups::Comments::POSTComments::UserIsSignIn>)> User.all
  31. => [#<User id: 1557, email: "maynard.batz@bauch-rowe.name", first_name: "Esteban", last_name: "Dach", created_at: "2022-07-19 18:36:44.366152000 +0000", updated_at: "2022-07-19 18:36:44.366152000 +0000", username: "@lala", online: false>]
  32. [2] pry(#<RSpec::ExampleGroups::Comments::POSTComments::UserIsSignIn>)> Task.all
  33. => []
  34. [3] pry(#<RSpec::ExampleGroups::Comments::POSTComments::UserIsSignIn>)> Project.all
  35. => []
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement