Fix improper archive redirect (#3064)

This commit is contained in:
Ben Halpern 2019-06-06 17:03:59 -04:00 committed by GitHub
parent 141c8f27d2
commit a3a9f51103
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View file

@ -68,6 +68,8 @@ function handleFormSubmit(e) {
if (xhr.status === 200) {
onXhrSuccess(form, article, values);
var message = values.commit === 'Mute Notifications' ? 'Notifications Muted' : 'Notifications Restored';
article.querySelector('.dashboard-meta-details').innerHTML = message;
} else {
article.querySelector('.dashboard-meta-details').innerHTML =
'Failed to update article.';

View file

@ -146,6 +146,10 @@ class ArticlesController < ApplicationController
respond_to do |format|
format.html do
if article_params_json[:archived] && @article.archived #just to get archived working
render json: @article.to_json(only: [:id], methods: [:current_state_path])
return
end
# NOTE: destination is used by /dashboard/organization when it re-assigns an article
# not a great solution but for now it will do
redirect_to(params[:destination] || @article.path)
@ -241,7 +245,7 @@ class ArticlesController < ApplicationController
else
%i[
title body_markdown main_image published description
tag_list canonical_url series collection_id
tag_list canonical_url series collection_id archived
]
end

View file

@ -75,4 +75,11 @@ RSpec.describe "ArticlesUpdate", type: :request do
expect(article.reload.user).to eq(other_user)
expect(article.organization_id).to eq(admin_org_id)
end
it "archives" do
put "/articles/#{article.id}", params: {
article: { archived: true }
}
expect(article.archived).to eq(false)
end
end