Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

コメントを更新するAPIを実装 #82

Merged
merged 7 commits into from
Sep 1, 2024

Conversation

kuri0616
Copy link
Collaborator

対応するissue

対応内容

  • routesにcommentのupdateのルーティングを追加
  • comments_controllerにupdateアクションを追加
  • request specにupdateのテストを追加

Copy link
Contributor

@kakeru-one kakeru-one left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rikuya98
コメントしました!

context 'コンテンツが有効な場合' do
let(:memo) { create(:memo) }
let(:comment) { create(:comment, memo: memo) }
let(:valid_comment_params) { { content: Faker::Lorem.paragraph(sentence_count: 3) } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits

名前が少し冗長かなと思いました!
paramsでいいかなと!

Suggested change
let(:valid_comment_params) { { content: Faker::Lorem.paragraph(sentence_count: 3) } }
let(:params) { { content: Faker::Lorem.paragraph(sentence_count: 3) } }

context 'バリデーションエラーになる場合' do
let(:memo) { create(:memo) }
let(:comment) { create(:comment, memo: memo) }
let(:invalid_comment_params) { { content: '' } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上です


it 'コメントが更新されていないこと、422になることを確認する' do
aggregate_failures do
put "/memos/#{memo.id}/comments/#{comment.id}", params: { comment: invalid_comment_params }, as: :json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上です

context '存在しないコメントIDの場合' do
let(:memo) { create(:memo) }
let(:comment) { create(:comment, memo: memo) }
let(:valid_comment_params) { { content: Faker::Lorem.paragraph(sentence_count: 3) } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上です

context '存在しないメモIDの場合' do
let(:memo) { create(:memo) }
let(:comment) { create(:comment, memo: memo) }
let(:valid_comment_params) { { content: Faker::Lorem.paragraph(sentence_count: 3) } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上です

let(:comment) { create(:comment, memo: memo) }
let(:valid_comment_params) { { content: Faker::Lorem.paragraph(sentence_count: 3) } }

it '404が返ることを確認する' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO

itブロックの文言には結果を書くのが慣習的なので、
「確認する」までは書かなくていいかなと思いました!

Suggested change
it '404が返ることを確認する' do
it '404が返る' do

Copy link
Contributor

@kakeru-one kakeru-one left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rikuya98
LGTM!

@kuri0616 kuri0616 merged commit 9c7e078 into main Sep 1, 2024
1 check passed
@kuri0616 kuri0616 deleted the feature/#57comment-update-api branch September 1, 2024 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend バックエンドのissues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

コメント更新機能の実装
2 participants