Navigation Menu

Skip to content

Commit

Permalink
FIX: Update post's raw from server response (#13438)
Browse files Browse the repository at this point in the history
This fix is similar to ea2833d, but
this time raw text is updated after the post is created.
  • Loading branch information
nbianca committed Jun 18, 2021
1 parent e305365 commit 09b55fd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/serializers/new_post_result_serializer.rb
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions spec/requests/api/schemas/json/topic_create_response.json
Expand Up @@ -19,6 +19,9 @@
"created_at": {
"type": "string"
},
"raw": {
"type": "string"
},
"cooked": {
"type": "string"
},
Expand Down
3 changes: 2 additions & 1 deletion spec/requests/posts_controller_spec.rb
Expand Up @@ -989,14 +989,15 @@

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
}

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

Expand Down

0 comments on commit 09b55fd

Please sign in to comment.