FIX: Update post's raw from server response (#13438)

This fix is similar to ea2833d0d8, but
this time raw text is updated after the post is created.
This commit is contained in:
Bianca Nenciu 2021-06-18 16:26:57 +03:00 committed by GitHub
parent e305365168
commit 09b55fd338
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -13,7 +13,7 @@ class NewPostResultSerializer < ApplicationSerializer
has_one :pending_post, serializer: TopicPendingPostSerializer, root: false, embed: :objects
def post
post_serializer = PostSerializer.new(object.post, scope: scope, root: false)
post_serializer = PostSerializer.new(object.post, scope: scope, root: false, add_raw: true)
post_serializer.draft_sequence = DraftSequence.current(scope.user, object.post.topic.draft_key)
post_serializer.as_json
end

View File

@ -19,6 +19,9 @@
"created_at": {
"type": "string"
},
"raw": {
"type": "string"
},
"cooked": {
"type": "string"
},

View File

@ -989,7 +989,7 @@ describe PostsController do
it "returns the nested post with a param" do
post "/posts.json", params: {
raw: 'this is the test content',
raw: 'this is the test content ',
title: 'this is the test title for the topic',
nested_post: true
}
@ -997,6 +997,7 @@ describe PostsController do
expect(response.status).to eq(200)
parsed = response.parsed_body
expect(parsed['post']).to be_present
expect(parsed['post']['raw']).to eq('this is the test content')
expect(parsed['post']['cooked']).to be_present
end