Use cached_tag_list_array for tags (#2857)

This commit is contained in:
rhymes 2019-05-17 05:29:57 +02:00 committed by Ben Halpern
parent f3496edb1c
commit 2660ae1739
2 changed files with 10 additions and 4 deletions

View file

@ -7,7 +7,7 @@ json.published_at @article.published_at
json.readable_publish_date @article.readable_publish_date
json.social_image article_social_image_url(@article)
json.tag_list @article.cached_tag_list
json.tags @article.cached_tag_list.split(", ")
json.tags @article.cached_tag_list_array
json.slug @article.slug
json.path @article.path
json.url @article.url

View file

@ -77,14 +77,15 @@ RSpec.describe "Api::V0::Articles", type: :request do
end
describe "GET /api/articles/:id" do
let(:article) { create(:article) }
it "gets article based on ID" do
article = create(:article)
get "/api/articles/#{article.id}"
expect(JSON.parse(response.body)["title"]).to eq(article.title)
expect(json_response["title"]).to eq(article.title)
end
it "fails with an unpublished article" do
article = create(:article, published: false)
article.update_columns(published: false)
get "/api/articles/#{article.id}"
expect(response).to have_http_status(:not_found)
end
@ -93,6 +94,11 @@ RSpec.describe "Api::V0::Articles", type: :request do
get "/api/articles/99999"
expect(response).to have_http_status(:not_found)
end
it "contains tags as an array" do
get "/api/articles/#{article.id}"
expect(json_response["tags"]).to eq(article.decorate.cached_tag_list_array)
end
end
describe "POST /api/articles" do