From 04a810d7395ea490a2019dd44a0d9d92e26b3928 Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Tue, 20 Aug 2019 13:18:38 -0400 Subject: [PATCH] Fix video image redirect issue (#3778) --- app/controllers/articles_controller.rb | 7 +++++-- spec/requests/articles_update_spec.rb | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index fd17a3eaf..a50431c2d 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -145,7 +145,6 @@ class ArticlesController < ApplicationController end updated = @article.update(article_params_json.merge(edited_at: edited_at_date)) handle_notifications(updated) - respond_to do |format| format.html do # TODO: JSON should probably not be returned in the format.html section @@ -157,6 +156,10 @@ class ArticlesController < ApplicationController redirect_to(params[:destination]) return end + if params[:article][:video_thumbnail_url] + redirect_to(@article.path + "/edit") + return + end render json: { status: 200 } end @@ -256,7 +259,7 @@ class ArticlesController < ApplicationController %i[body_markdown] else %i[ - title body_markdown main_image published description + title body_markdown main_image published description video_thumbnail_url tag_list canonical_url series collection_id archived ] end diff --git a/spec/requests/articles_update_spec.rb b/spec/requests/articles_update_spec.rb index 9693aea5a..c78163636 100644 --- a/spec/requests/articles_update_spec.rb +++ b/spec/requests/articles_update_spec.rb @@ -100,4 +100,12 @@ RSpec.describe "ArticlesUpdate", type: :request do } expect(article.notifications.size).to eq 0 end + + it "changes video_thumbnail_url effectively" do + put "/articles/#{article.id}", params: { + article: { video_thumbnail_url: "https://i.imgur.com/HPiu7N4.jpg" } + } + expect(response).to redirect_to "#{article.path}/edit" + expect(article.reload.video_thumbnail_url).to include "https://i.imgur.com/HPiu7N4.jpg" + end end