mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -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
|
||||||
|
|||||||
@@ -19,6 +19,9 @@
|
|||||||
"created_at": {
|
"created_at": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"raw": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"cooked": {
|
"cooked": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user