Fix: Update contact validation messages (#3500)

Fixes #3476
This commit is contained in:
thedev105
2021-12-03 10:49:11 +03:00
committed by GitHub
parent d7cfe6858e
commit 6d378eb206
8 changed files with 32 additions and 29 deletions

View File

@@ -448,7 +448,19 @@ RSpec.describe 'Contacts API', type: :request do
as: :json
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['contact']['id']).to eq(other_contact.id)
expect(JSON.parse(response.body)['attributes']).to include('email')
end
it 'prevents updating with an existing phone number' do
other_contact = create(:contact, account: account, phone_number: '+12000000')
patch "/api/v1/accounts/#{account.id}/contacts/#{contact.id}",
headers: admin.create_new_auth_token,
params: valid_params[:contact].merge({ phone_number: other_contact.phone_number }),
as: :json
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['attributes']).to include('phone_number')
end
end
end