Give Admins the Ability to Add Co-Authors to Posts (#10252) [deploy]
* Adds second_user_id and third_user_id to Admin::Articles::Controller and Article model - Add second_user_id to #update - Add third_user_id to #update - Add second_user_id to #article_params - Add third_user_id to #article_params - Add second and third user_ids to :limited_columns_internal_select * Adds a second_user_id and third_user_id form field to _individual_article.html.erb * Adds tests around adding a co-author and multiple co-authors to an article in articles_spec.rb
This commit is contained in:
parent
7630885783
commit
751c910291
4 changed files with 36 additions and 1 deletions
|
|
@ -45,6 +45,8 @@ module Admin
|
|||
article.boosted_additional_articles = article_params[:boosted_additional_articles].to_s == "true"
|
||||
article.boosted_dev_digest_email = article_params[:boosted_dev_digest_email].to_s == "true"
|
||||
article.user_id = article_params[:user_id].to_i
|
||||
article.second_user_id = article_params[:second_user_id].to_i
|
||||
article.third_user_id = article_params[:third_user_id].to_i
|
||||
article.update!(article_params)
|
||||
render body: nil
|
||||
end
|
||||
|
|
@ -129,6 +131,8 @@ module Admin
|
|||
main_image_background_hex_color
|
||||
featured_number
|
||||
user_id
|
||||
second_user_id
|
||||
third_user_id
|
||||
last_buffered]
|
||||
params.require(:article).permit(allowed_params)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class Article < ApplicationRecord
|
|||
:video_thumbnail_url, :video_closed_caption_track_url, :social_image,
|
||||
:published_from_feed, :crossposted_at, :published_at, :featured_number,
|
||||
:last_buffered, :facebook_last_buffered, :created_at, :body_markdown,
|
||||
:email_digest_eligible, :processed_html)
|
||||
:email_digest_eligible, :processed_html, :second_user_id, :third_user_id)
|
||||
}
|
||||
|
||||
scope :boosted_via_additional_articles, lambda {
|
||||
|
|
|
|||
|
|
@ -85,6 +85,16 @@
|
|||
<input id="author_id_<%= article.id %>" class="form-control" size="6" name="article[user_id]"
|
||||
value="<%= article.user_id %>">
|
||||
</div>
|
||||
<div class="form-group col">
|
||||
<label for="second_author_id_<%= article.id %>">Second Author ID:</label>
|
||||
<input id="second_author_id_<%= article.id %>" class="form-control" size="6" name="article[second_user_id]"
|
||||
value="<%= article.second_user_id %>">
|
||||
</div>
|
||||
<div class="form-group col">
|
||||
<label for="third_author_id_<%= article.id %>">Third Author ID:</label>
|
||||
<input id="third_author_id_<%= article.id %>" class="form-control" size="6" name="article[third_user_id]"
|
||||
value="<%= article.third_user_id %>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-check col">
|
||||
|
|
|
|||
|
|
@ -5,4 +5,25 @@ RSpec.describe "/admin/articles", type: :request do
|
|||
it_behaves_like "an InternalPolicy dependant request", Article do
|
||||
let(:request) { get "/admin/articles" }
|
||||
end
|
||||
|
||||
context "when updating an Article via /admin/articles" do
|
||||
let(:super_admin) { create(:user, :super_admin) }
|
||||
let(:article) { create(:article) }
|
||||
|
||||
before { sign_in super_admin }
|
||||
|
||||
it "allows an Admin to add a co-author to an individual article" do
|
||||
get request
|
||||
expect do
|
||||
article.update_columns(second_user_id: 1)
|
||||
end.to change(article, :second_user_id).from(nil).to(1)
|
||||
end
|
||||
|
||||
it "allows an Admin to add co-authora to an individual article" do
|
||||
article.update_columns(second_user_id: 2, third_user_id: 3)
|
||||
get request
|
||||
expect(article.second_user_id).to eq(2)
|
||||
expect(article.third_user_id).to eq(3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue