feat: Link help center portal to an Inbox (#6903)

This commit is contained in:
Tejaswini Chile
2023-04-24 12:49:52 +05:30
committed by GitHub
parent f825a22997
commit e3193dcabc
11 changed files with 77 additions and 3 deletions

View File

@@ -429,7 +429,8 @@ RSpec.describe 'Inboxes API', type: :request do
context 'when it is an authenticated user' do
let(:admin) { create(:user, account: account, role: :administrator) }
let(:valid_params) { { name: 'new test inbox', enable_auto_assignment: false } }
let!(:portal) { create(:portal, account_id: account.id) }
let(:valid_params) { { name: 'new test inbox', enable_auto_assignment: false, portal_id: portal.id } }
it 'will not update inbox for agent' do
agent = create(:user, account: account, role: :agent)
@@ -450,6 +451,7 @@ RSpec.describe 'Inboxes API', type: :request do
expect(response).to have_http_status(:success)
expect(inbox.reload.enable_auto_assignment).to be_falsey
expect(inbox.reload.portal_id).to eq(portal.id)
expect(JSON.parse(response.body)['name']).to eq 'new test inbox'
end

View File

@@ -197,11 +197,19 @@ RSpec.describe Inbox do
describe '#update' do
let!(:inbox) { FactoryBot.create(:inbox) }
let!(:portal) { FactoryBot.create(:portal) }
before do
allow(Rails.configuration.dispatcher).to receive(:dispatch)
end
it 'set portal id in inbox' do
inbox.portal_id = portal.id
inbox.save
expect(inbox.portal).to eq(portal)
end
it 'resets cache key if there is an update in the channel' do
channel = inbox.channel
channel.update(widget_color: '#fff')

View File

@@ -14,6 +14,7 @@ RSpec.describe Portal, type: :model do
it { is_expected.to have_many(:articles) }
it { is_expected.to have_many(:portal_members) }
it { is_expected.to have_many(:members) }
it { is_expected.to have_many(:inboxes) }
end
describe 'validations' do