Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > в Модели Комментарии нет связи author там связь называется user (можно посмотреть в scheme.rb)
- Всё так
- create_table "comments", force: :cascade do |t|
- t.text "body", default: "", null: false
- t.bigint "user_id", null: false
- < ... >
- t.index ["user_id"], name: "index_comments_on_user_id"
- end
- Тем не менее не понятно
- Парамсы берутся из factories.
- Далее запускаем тест
- it "create a new comment" do
- post comments_path, params: { commentable_type: comment.class, commentable_id: comment.id }
- expect(Comment.first.body).to eq(comment)
- end
- и он падает на
- 1) Comments POST /comments/ user is sign in create a new comment
- Failure/Error: params.require(:comment).permit(:body, :commentable_type, :commentable_id)
- ActionController::ParameterMissing:
- param is missing or the value is empty: comment
- Did you mean? commentable_id
- commentable_type
- controller
- action
- # ./app/controllers/comments_controller.rb:36:in `comment_params'
- # ./app/controllers/comments_controller.rb:32:in `load_commentable!'
- # ./spec/requests/comments_spec.rb:21:in `block (4 levels) in <top (required)>'
- При дебаге вижу только юзера
- pry(#<RSpec::ExampleGroups::Comments::POSTComments::UserIsSignIn>)> User.all
- => [#<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>]
- [2] pry(#<RSpec::ExampleGroups::Comments::POSTComments::UserIsSignIn>)> Task.all
- => []
- [3] pry(#<RSpec::ExampleGroups::Comments::POSTComments::UserIsSignIn>)> Project.all
- => []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement