From 60d8a07276e18db54c32fcd24733c8adc97bf85d Mon Sep 17 00:00:00 2001 From: Araslanov Evgeny Date: Tue, 8 Oct 2019 22:41:44 +0300 Subject: [PATCH] Fix invalid body_markdown in article with video (#4258) [ci skip] --- app/controllers/articles_controller.rb | 2 +- app/services/article_with_video_creation_service.rb | 11 ++--------- .../article_with_video_creation_service_spec.rb | 1 + 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index 0e0dec43a..26dd8d58c 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -56,7 +56,7 @@ class ArticlesController < ApplicationController elsif @tag.present? skip_authorization Article.new( - body_markdown: "---\ntitle: \npublished: false\ndescription: \ntags: " + @tag.name + "\n---\n\n", + body_markdown: "---\ntitle: \npublished: false\ndescription: \ntags: #{@tag.name}\n---\n\n", processed_html: "", user_id: current_user&.id ) else diff --git a/app/services/article_with_video_creation_service.rb b/app/services/article_with_video_creation_service.rb index 3f306a867..a7665f599 100644 --- a/app/services/article_with_video_creation_service.rb +++ b/app/services/article_with_video_creation_service.rb @@ -32,15 +32,8 @@ class ArticleWithVideoCreationService def initial_article_with_params(article) if @current_user.editor_version == "v1" - article.body_markdown = <<~BODY - --- - title: Unpublished Video ~ #{rand(100_000).to_s(26)} - published: false - description: - tags: - --- - - BODY + title = "Unpublished Video ~ #{rand(100_000).to_s(26)}" + article.body_markdown = "---\ntitle: #{title}\npublished: false\ndescription: \ntags: \n---\n\n" else article.body_markdown = "" article.title = "Unpublished Video ~ #{rand(100_000).to_s(26)}" diff --git a/spec/services/article_with_video_creation_service_spec.rb b/spec/services/article_with_video_creation_service_spec.rb index 2b136e634..f65a0b574 100644 --- a/spec/services/article_with_video_creation_service_spec.rb +++ b/spec/services/article_with_video_creation_service_spec.rb @@ -14,6 +14,7 @@ RSpec.describe ArticleWithVideoCreationService, type: :service do Timecop.return test = build_stubbed(:article, user: user, video: link).attributes.symbolize_keys article = described_class.new(test, user).create! + expect(article.body_markdown.inspect).to include("description: \\ntags: \\n") expect(article.video_state).to eq("PROGRESSING") end end