コミットを比較
1
コミット
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
23ee19eee7 |
@@ -314,9 +314,7 @@ class PostsController < ApplicationController
|
||||
def viewed
|
||||
return head :unauthorized unless current_user
|
||||
|
||||
UserPostView.create_or_find_by!(
|
||||
user: current_user,
|
||||
post: Post.find(params[:id]))
|
||||
current_user.viewed_posts << Post.find(params[:id])
|
||||
head :no_content
|
||||
end
|
||||
|
||||
|
||||
@@ -2559,21 +2559,6 @@ RSpec.describe 'Posts API', type: :request do
|
||||
|
||||
expect(user.reload.viewed?(post_record)).to be(true)
|
||||
end
|
||||
|
||||
it '204 and keeps one view on repeated requests' do
|
||||
sign_in_as(user)
|
||||
|
||||
expect {
|
||||
post "/posts/#{ post_record.id }/viewed"
|
||||
}.to change(UserPostView, :count).by(1)
|
||||
expect(response).to have_http_status(:no_content)
|
||||
|
||||
expect {
|
||||
post "/posts/#{ post_record.id }/viewed"
|
||||
}.not_to change(UserPostView, :count)
|
||||
expect(response).to have_http_status(:no_content)
|
||||
expect(user.reload.viewed?(post_record)).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE /posts/:id/viewed' do
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useEffect, useMemo, useState } from 'react'
|
||||
import { useLocale } from '@/lib/useLocale'
|
||||
import PostOriginalCreatedTimeField from '@/components/PostOriginalCreatedTimeField'
|
||||
import FieldError from '@/components/common/FieldError'
|
||||
import FieldWarning from '@/components/common/FieldWarning'
|
||||
import PostDurationField from '@/components/posts/PostDurationField'
|
||||
import PostTagsField from '@/components/posts/PostTagsField'
|
||||
import PostTextField from '@/components/posts/PostTextField'
|
||||
@@ -172,6 +173,9 @@ const PostEditForm: FC<Props> = ({ post, onSave }) => {
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className="max-w-xl pt-2 space-y-4">
|
||||
<FieldError messages={baseErrors}/>
|
||||
{!(post.thumbnail?.trim () || post.thumbnailBase?.trim ()) && (
|
||||
<FieldWarning
|
||||
messages={[label ('shared:labels.thumbnailMissing')]}/>)}
|
||||
|
||||
<PostTextField
|
||||
label={label ('shared:labels.title')}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする