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:
parent
e305365168
commit
09b55fd338
|
@ -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
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"raw": {
|
||||
"type": "string"
|
||||
},
|
||||
"cooked": {
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue