diff --git a/spec/requests/epp/contact/delete/used_spec.rb b/spec/requests/epp/contact/delete/used_spec.rb new file mode 100644 index 0000000000..f6db6b65b2 --- /dev/null +++ b/spec/requests/epp/contact/delete/used_spec.rb @@ -0,0 +1,49 @@ +require 'rails_helper' + +RSpec.describe 'EPP contact:delete' do + let(:user) { create(:api_user, registrar: registrar) } + let(:registrar) { create(:registrar) } + let!(:registrant) { create(:registrant, registrar: registrar, code: 'TEST') } + let(:request) { post '/epp/command/delete', frame: request_xml } + let(:request_xml) { <<-XML + + + + + + test + + + + + XML + } + + before do + sign_in_to_epp_area(user: user) + end + + context 'when contact is used' do + let!(:domain) { create(:domain, registrant: registrant) } + + specify do + request + expect(response).to have_code_of(2305) + end + + it 'does not delete contact' do + expect { request }.to_not change { Contact.count } + end + end + + context 'when contact is not used' do + specify do + request + expect(response).to have_code_of(1000) + end + + it 'deletes contact' do + expect { request }.to change { Contact.count }.from(1).to(0) + end + end +end