feat: Added portal logo and the updated the JSON (#4996)
This commit is contained in:
@@ -18,8 +18,8 @@ RSpec.describe Article, type: :model do
|
||||
describe 'search' do
|
||||
let!(:account) { create(:account) }
|
||||
let(:user) { create(:user, account_ids: [account.id], role: :agent) }
|
||||
let!(:portal_1) { create(:portal, account_id: account.id) }
|
||||
let!(:portal_2) { create(:portal, account_id: account.id) }
|
||||
let!(:portal_1) { create(:portal, account_id: account.id, config: { allowed_locales: %w[en es] }) }
|
||||
let!(:portal_2) { create(:portal, account_id: account.id, config: { allowed_locales: %w[en es] }) }
|
||||
let!(:category_1) { create(:category, slug: 'category_1', locale: 'en', portal_id: portal_1.id) }
|
||||
let!(:category_2) { create(:category, slug: 'category_2', locale: 'es', portal_id: portal_1.id) }
|
||||
let!(:category_3) { create(:category, slug: 'category_3', locale: 'es', portal_id: portal_2.id) }
|
||||
|
||||
@@ -15,11 +15,24 @@ RSpec.describe Category, type: :model do
|
||||
it { is_expected.to have_many(:related_categories) }
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
let!(:account) { create(:account) }
|
||||
let(:user) { create(:user, account_ids: [account.id], role: :agent) }
|
||||
let!(:portal) { create(:portal, account_id: account.id, config: { allowed_locales: ['en'] }) }
|
||||
|
||||
it 'returns erros when locale is not allowed in the portal' do
|
||||
category = create(:category, slug: 'category_1', locale: 'en', portal_id: portal.id)
|
||||
expect(category).to be_valid
|
||||
category.update(locale: 'es')
|
||||
expect(category.errors.full_messages[0]).to eq("Locale es of category is not part of portal's [\"en\"].")
|
||||
end
|
||||
end
|
||||
|
||||
describe 'search' do
|
||||
let!(:account) { create(:account) }
|
||||
let(:user) { create(:user, account_ids: [account.id], role: :agent) }
|
||||
let!(:portal_1) { create(:portal, account_id: account.id) }
|
||||
let!(:portal_2) { create(:portal, account_id: account.id) }
|
||||
let!(:portal_1) { create(:portal, account_id: account.id, config: { allowed_locales: %w[en es] }) }
|
||||
let!(:portal_2) { create(:portal, account_id: account.id, config: { allowed_locales: %w[en es] }) }
|
||||
|
||||
before do
|
||||
create(:category, slug: 'category_1', locale: 'en', portal_id: portal_1.id)
|
||||
|
||||
@@ -15,4 +15,22 @@ RSpec.describe Portal, type: :model do
|
||||
it { is_expected.to have_many(:portal_members) }
|
||||
it { is_expected.to have_many(:members) }
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
let!(:account) { create(:account) }
|
||||
let!(:portal) { create(:portal, account_id: account.id) }
|
||||
|
||||
context 'when set portal config' do
|
||||
it 'Adds default allowed_locales en' do
|
||||
expect(portal.config).to be_present
|
||||
expect(portal.config['allowed_locales']).to eq(['en'])
|
||||
end
|
||||
|
||||
it 'Does not allow any other config than allowed_locales' do
|
||||
portal.update(config: { 'some_other_key': 'test_value' })
|
||||
expect(portal).not_to be_valid
|
||||
expect(portal.errors.full_messages[0]).to eq('Cofig in portal on some_other_key is not supported.')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user