chore: Add a check for defined labels in SDK API (#1259)

This commit is contained in:
Pranav Raj S
2020-09-20 19:29:39 +05:30
committed by GitHub
parent cdd428f503
commit 0deb1af852
2 changed files with 24 additions and 3 deletions

View File

@@ -12,8 +12,24 @@ RSpec.describe '/api/v1/widget/labels', type: :request do
describe 'POST /api/v1/widget/labels' do
let(:params) { { website_token: web_widget.website_token, label: 'customer-support' } }
context 'with correct website token' do
it 'returns the list of labels' do
context 'with correct website token and undefined label' do
it 'does not add the label' do
post '/api/v1/widget/labels',
params: params,
headers: { 'X-Auth-Token' => token },
as: :json
expect(response).to have_http_status(:success)
expect(conversation.reload.label_list.count).to eq 0
end
end
context 'with correct website token and a defined label' do
before do
account.labels.create(title: 'customer-support')
end
it 'add the label to the conversation' do
post '/api/v1/widget/labels',
params: params,
headers: { 'X-Auth-Token' => token },