Fix video image redirect issue (#3778)

This commit is contained in:
Ben Halpern 2019-08-20 13:18:38 -04:00 committed by GitHub
parent 5deb668ecd
commit 04a810d739
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -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

View file

@ -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