fix: Add all articles count to article API (#5497)
This commit is contained in:
@@ -5,4 +5,9 @@ end
|
|||||||
json.meta do
|
json.meta do
|
||||||
json.current_page @current_page
|
json.current_page @current_page
|
||||||
json.articles_count @articles_count
|
json.articles_count @articles_count
|
||||||
|
json.all_articles_count @articles_count
|
||||||
|
json.archived_articles_count @articles.archived.size
|
||||||
|
json.published_count @articles.published.size
|
||||||
|
json.draft_articles_count @articles.draft.size
|
||||||
|
json.mine_articles_count @articles.search_by_author(current_user.id).size if current_user.present?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -195,6 +195,8 @@ RSpec.describe 'Api::V1::Accounts::Articles', type: :request do
|
|||||||
json_response = JSON.parse(response.body)
|
json_response = JSON.parse(response.body)
|
||||||
expect(json_response['payload'].count).to be 1
|
expect(json_response['payload'].count).to be 1
|
||||||
expect(json_response['meta']['articles_count']).to be 2
|
expect(json_response['meta']['articles_count']).to be 2
|
||||||
|
expect(json_response['meta']['all_articles_count']).to be 2
|
||||||
|
expect(json_response['meta']['mine_articles_count']).to be 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user