feat: Fetching the portal data related to a specific custom domain (#5249)
This commit is contained in:
parent
6574407636
commit
db73d033b7
11 changed files with 74 additions and 35 deletions
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe 'Public Portals API', type: :request do
|
||||
let!(:account) { create(:account) }
|
||||
let!(:portal) { create(:portal, slug: 'test-portal', account_id: account.id) }
|
||||
let!(:portal) { create(:portal, slug: 'test-portal', account_id: account.id, custom_domain: 'www.example.com') }
|
||||
|
||||
before do
|
||||
create(:portal, slug: 'test-portal-1', account_id: account.id)
|
||||
|
@ -11,12 +11,24 @@ RSpec.describe 'Public Portals API', type: :request do
|
|||
|
||||
describe 'GET /public/api/v1/portals/{portal_slug}' do
|
||||
it 'Show portal and categories belonging to the portal' do
|
||||
get "/public/api/v1/portals/#{portal.slug}"
|
||||
get "/hc/#{portal.slug}/en"
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response['slug']).to eql 'test-portal'
|
||||
expect(json_response['meta']['articles_count']).to be 0
|
||||
end
|
||||
|
||||
it 'Throws unauthorised error for unknown domain' do
|
||||
portal.update(custom_domain: 'www.something.com')
|
||||
|
||||
get "/hc/#{portal.slug}/en"
|
||||
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
json_response = JSON.parse(response.body)
|
||||
|
||||
expect(json_response['error']).to eql "Domain: www.example.com is not registered with us. \
|
||||
Please send us an email at support@chatwoot.com with the custom domain name and account API key"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue