feat: Added portal logo and the updated the JSON (#4996)

This commit is contained in:
Tejaswini Chile
2022-07-11 12:43:24 +05:30
committed by GitHub
parent 9d4b77533e
commit 23ac1c0334
10 changed files with 101 additions and 11 deletions

View File

@@ -3,7 +3,7 @@ require 'rails_helper'
RSpec.describe 'Api::V1::Accounts::Categories', type: :request do
let(:account) { create(:account) }
let(:agent) { create(:user, account: account, role: :agent) }
let!(:portal) { create(:portal, name: 'test_portal', account_id: account.id) }
let!(:portal) { create(:portal, name: 'test_portal', account_id: account.id, config: { allowed_locales: %w[en es] }) }
let!(:category) { create(:category, name: 'category', portal: portal, account_id: account.id, slug: 'category_slug') }
let!(:category_to_associate) do
create(:category, name: 'associated category', portal: portal, account_id: account.id, slug: 'associated_category_slug')

View File

@@ -67,11 +67,14 @@ RSpec.describe 'Api::V1::Accounts::Portals', type: :request do
context 'when it is an authenticated user' do
it 'creates portal' do
file = fixture_file_upload(Rails.root.join('spec/assets/avatar.png'), 'image/png')
portal_params = {
portal: {
name: 'test_portal',
slug: 'test_kbase'
}
},
logo: file
}
post "/api/v1/accounts/#{account.id}/portals",
params: portal_params,
@@ -80,6 +83,7 @@ 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('test_portal')
expect(json_response['logo']['filename']).to eql('avatar.png')
end
end
end
@@ -97,7 +101,8 @@ RSpec.describe 'Api::V1::Accounts::Portals', type: :request do
it 'updates portal' do
portal_params = {
portal: {
name: 'updated_test_portal'
name: 'updated_test_portal',
config: { 'allowed_locales' => %w[en es] }
}
}
@@ -110,6 +115,7 @@ 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] })
end
it 'archive portal' do