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
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 has_one :pending_post, serializer: TopicPendingPostSerializer, root: false, embed: :objects
def post 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.draft_sequence = DraftSequence.current(scope.user, object.post.topic.draft_key)
post_serializer.as_json post_serializer.as_json
end end

View File

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

View File

@@ -997,6 +997,7 @@ describe PostsController do
expect(response.status).to eq(200) expect(response.status).to eq(200)
parsed = response.parsed_body parsed = response.parsed_body
expect(parsed['post']).to be_present expect(parsed['post']).to be_present
expect(parsed['post']['raw']).to eq('this is the test content')
expect(parsed['post']['cooked']).to be_present expect(parsed['post']['cooked']).to be_present
end end