chore: Add missing locale info in portal API (#5177)

This commit is contained in:
Tejaswini Chile 2022-08-03 10:33:48 +05:30 committed by GitHub
parent 11fe3f071e
commit 4152883f38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View file

@ -7,7 +7,15 @@ json.name portal.name
json.page_title portal.page_title
json.slug portal.slug
json.archived portal.archived
json.config portal.config
json.config do
json.allowed_locales do
json.array! portal.config['allowed_locales'].each do |locale|
json.partial! 'api/v1/models/portal_config.json.jbuilder', locale: locale, portal: portal
end
end
end
json.logo portal.file_base_data if portal.logo.present?
json.portal_members do

View file

@ -0,0 +1,3 @@
json.code locale
json.articles_count portal.articles.search({ locale: locale }).size
json.categories_count portal.categories.search_by_locale(locale).size

View file

@ -115,7 +115,8 @@ RSpec.describe 'Api::V1::Accounts::Portals', type: :request do
expect(response).to have_http_status(:success)
json_response = JSON.parse(response.body)
expect(json_response['name']).to eql(portal_params[:portal][:name])
expect(json_response['config']).to eql({ 'allowed_locales' => %w[en es], 'default_locale' => 'en' })
expect(json_response['config']).to eql({ 'allowed_locales' => [{ 'articles_count' => 0, 'categories_count' => 0, 'code' => 'en' },
{ 'articles_count' => 0, 'categories_count' => 0, 'code' => 'es' }] })
end
it 'archive portal' do